analyzer: fix feasibility false +ve on jumps through function ptrs [PR107582]
[platform/upstream/gcc.git] / gcc / tree.h
1 /* Definitions for the ubiquitous 'tree' type for GNU compilers.
2    Copyright (C) 1989-2022 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 it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
10
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 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
20 #ifndef GCC_TREE_H
21 #define GCC_TREE_H
22
23 #include "tree-core.h"
24 #include "options.h"
25
26 /* Convert a target-independent built-in function code to a combined_fn.  */
27
28 inline combined_fn
29 as_combined_fn (built_in_function fn)
30 {
31   return combined_fn (int (fn));
32 }
33
34 /* Convert an internal function code to a combined_fn.  */
35
36 inline combined_fn
37 as_combined_fn (internal_fn fn)
38 {
39   return combined_fn (int (fn) + int (END_BUILTINS));
40 }
41
42 /* Return true if CODE is a target-independent built-in function.  */
43
44 inline bool
45 builtin_fn_p (combined_fn code)
46 {
47   return int (code) < int (END_BUILTINS);
48 }
49
50 /* Return the target-independent built-in function represented by CODE.
51    Only valid if builtin_fn_p (CODE).  */
52
53 inline built_in_function
54 as_builtin_fn (combined_fn code)
55 {
56   gcc_checking_assert (builtin_fn_p (code));
57   return built_in_function (int (code));
58 }
59
60 /* Return true if CODE is an internal function.  */
61
62 inline bool
63 internal_fn_p (combined_fn code)
64 {
65   return int (code) >= int (END_BUILTINS);
66 }
67
68 /* Return the internal function represented by CODE.  Only valid if
69    internal_fn_p (CODE).  */
70
71 inline internal_fn
72 as_internal_fn (combined_fn code)
73 {
74   gcc_checking_assert (internal_fn_p (code));
75   return internal_fn (int (code) - int (END_BUILTINS));
76 }
77
78 /* Helper to transparently allow tree codes and builtin function codes
79    exist in one storage entity.  */
80 class code_helper
81 {
82 public:
83   code_helper () {}
84   code_helper (tree_code code) : rep ((int) code) {}
85   code_helper (combined_fn fn) : rep (-(int) fn) {}
86   code_helper (internal_fn fn) : rep (-(int) as_combined_fn (fn)) {}
87   explicit operator tree_code () const { return (tree_code) rep; }
88   explicit operator combined_fn () const { return (combined_fn) -rep; }
89   explicit operator internal_fn () const;
90   explicit operator built_in_function () const;
91   bool is_tree_code () const { return rep > 0; }
92   bool is_fn_code () const { return rep < 0; }
93   bool is_internal_fn () const;
94   bool is_builtin_fn () const;
95   int get_rep () const { return rep; }
96   bool operator== (const code_helper &other) { return rep == other.rep; }
97   bool operator!= (const code_helper &other) { return rep != other.rep; }
98   bool operator== (tree_code c) { return rep == code_helper (c).rep; }
99   bool operator!= (tree_code c) { return rep != code_helper (c).rep; }
100
101 private:
102   int rep;
103 };
104
105 inline code_helper::operator internal_fn () const
106 {
107   return as_internal_fn (combined_fn (*this));
108 }
109
110 inline code_helper::operator built_in_function () const
111 {
112   return as_builtin_fn (combined_fn (*this));
113 }
114
115 inline bool
116 code_helper::is_internal_fn () const
117 {
118   return is_fn_code () && internal_fn_p (combined_fn (*this));
119 }
120
121 inline bool
122 code_helper::is_builtin_fn () const
123 {
124   return is_fn_code () && builtin_fn_p (combined_fn (*this));
125 }
126
127 /* Macros for initializing `tree_contains_struct'.  */
128 #define MARK_TS_BASE(C)                                 \
129   (tree_contains_struct[C][TS_BASE] = true)
130
131 #define MARK_TS_TYPED(C)                                \
132   (MARK_TS_BASE (C),                                    \
133    tree_contains_struct[C][TS_TYPED] = true)
134
135 #define MARK_TS_COMMON(C)                               \
136   (MARK_TS_TYPED (C),                                   \
137    tree_contains_struct[C][TS_COMMON] = true)
138
139 #define MARK_TS_TYPE_COMMON(C)                          \
140   (MARK_TS_COMMON (C),                                  \
141    tree_contains_struct[C][TS_TYPE_COMMON] = true)
142
143 #define MARK_TS_TYPE_WITH_LANG_SPECIFIC(C)              \
144   (MARK_TS_TYPE_COMMON (C),                             \
145    tree_contains_struct[C][TS_TYPE_WITH_LANG_SPECIFIC] = true)
146
147 #define MARK_TS_TYPE_NON_COMMON(C)                      \
148   (MARK_TS_TYPE_WITH_LANG_SPECIFIC (C),                 \
149    tree_contains_struct[C][TS_TYPE_NON_COMMON] = true)  \
150
151 #define MARK_TS_DECL_MINIMAL(C)                         \
152   (MARK_TS_COMMON (C),                                  \
153    tree_contains_struct[C][TS_DECL_MINIMAL] = true)
154
155 #define MARK_TS_DECL_COMMON(C)                          \
156   (MARK_TS_DECL_MINIMAL (C),                            \
157    tree_contains_struct[C][TS_DECL_COMMON] = true)
158
159 #define MARK_TS_DECL_WRTL(C)                            \
160   (MARK_TS_DECL_COMMON (C),                             \
161    tree_contains_struct[C][TS_DECL_WRTL] = true)
162
163 #define MARK_TS_DECL_WITH_VIS(C)                        \
164   (MARK_TS_DECL_WRTL (C),                               \
165    tree_contains_struct[C][TS_DECL_WITH_VIS] = true)
166
167 #define MARK_TS_DECL_NON_COMMON(C)                      \
168   (MARK_TS_DECL_WITH_VIS (C),                           \
169    tree_contains_struct[C][TS_DECL_NON_COMMON] = true)
170
171 #define MARK_TS_EXP(C)                                  \
172   (MARK_TS_TYPED (C),                                   \
173    tree_contains_struct[C][TS_EXP] = true)
174
175 /* Returns the string representing CLASS.  */
176
177 #define TREE_CODE_CLASS_STRING(CLASS)\
178         tree_code_class_strings[(int) (CLASS)]
179
180 #define TREE_CODE_CLASS(CODE)   tree_code_type[(int) (CODE)]
181
182 /* Nonzero if NODE represents an exceptional code.  */
183
184 #define EXCEPTIONAL_CLASS_P(NODE)\
185         (TREE_CODE_CLASS (TREE_CODE (NODE)) == tcc_exceptional)
186
187 /* Nonzero if NODE represents a constant.  */
188
189 #define CONSTANT_CLASS_P(NODE)\
190         (TREE_CODE_CLASS (TREE_CODE (NODE)) == tcc_constant)
191
192 /* Nonzero if NODE represents a constant, or is a location wrapper
193    around such a node.  */
194
195 #define CONSTANT_CLASS_OR_WRAPPER_P(NODE)\
196         (CONSTANT_CLASS_P (tree_strip_any_location_wrapper (NODE)))
197
198 /* Nonzero if NODE represents a type.  */
199
200 #define TYPE_P(NODE)\
201         (TREE_CODE_CLASS (TREE_CODE (NODE)) == tcc_type)
202
203 /* Nonzero if NODE represents a declaration.  */
204
205 #define DECL_P(NODE)\
206         (TREE_CODE_CLASS (TREE_CODE (NODE)) == tcc_declaration)
207
208 /* True if NODE designates a variable declaration.  */
209 #define VAR_P(NODE) \
210   (TREE_CODE (NODE) == VAR_DECL)
211
212 /* Nonzero if DECL represents a VAR_DECL or FUNCTION_DECL.  */
213
214 #define VAR_OR_FUNCTION_DECL_P(DECL)\
215   (TREE_CODE (DECL) == VAR_DECL || TREE_CODE (DECL) == FUNCTION_DECL)
216
217 /* Nonzero if NODE represents a INDIRECT_REF.  Keep these checks in
218    ascending code order.  */
219
220 #define INDIRECT_REF_P(NODE)\
221   (TREE_CODE (NODE) == INDIRECT_REF)
222
223 /* Nonzero if NODE represents a reference.  */
224
225 #define REFERENCE_CLASS_P(NODE)\
226         (TREE_CODE_CLASS (TREE_CODE (NODE)) == tcc_reference)
227
228 /* Nonzero if NODE represents a comparison.  */
229
230 #define COMPARISON_CLASS_P(NODE)\
231         (TREE_CODE_CLASS (TREE_CODE (NODE)) == tcc_comparison)
232
233 /* Nonzero if NODE represents a unary arithmetic expression.  */
234
235 #define UNARY_CLASS_P(NODE)\
236         (TREE_CODE_CLASS (TREE_CODE (NODE)) == tcc_unary)
237
238 /* Nonzero if NODE represents a binary arithmetic expression.  */
239
240 #define BINARY_CLASS_P(NODE)\
241         (TREE_CODE_CLASS (TREE_CODE (NODE)) == tcc_binary)
242
243 /* Nonzero if NODE represents a statement expression.  */
244
245 #define STATEMENT_CLASS_P(NODE)\
246         (TREE_CODE_CLASS (TREE_CODE (NODE)) == tcc_statement)
247
248 /* Nonzero if NODE represents a function call-like expression with a
249    variable-length operand vector.  */
250
251 #define VL_EXP_CLASS_P(NODE)\
252         (TREE_CODE_CLASS (TREE_CODE (NODE)) == tcc_vl_exp)
253
254 /* Nonzero if NODE represents any other expression.  */
255
256 #define EXPRESSION_CLASS_P(NODE)\
257         (TREE_CODE_CLASS (TREE_CODE (NODE)) == tcc_expression)
258
259 /* Returns nonzero iff NODE represents a type or declaration.  */
260
261 #define IS_TYPE_OR_DECL_P(NODE)\
262         (TYPE_P (NODE) || DECL_P (NODE))
263
264 /* Returns nonzero iff CLASS is the tree-code class of an
265    expression.  */
266
267 #define IS_EXPR_CODE_CLASS(CLASS)\
268         ((CLASS) >= tcc_reference && (CLASS) <= tcc_expression)
269
270 /* Returns nonzero iff NODE is an expression of some kind.  */
271
272 #define EXPR_P(NODE) IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (NODE)))
273
274 #define TREE_CODE_LENGTH(CODE)  tree_code_length[(int) (CODE)]
275
276
277 /* Helper macros for math builtins.  */
278
279 #define CASE_FLT_FN(FN) case FN: case FN##F: case FN##L
280 #define CASE_FLT_FN_FLOATN_NX(FN)                          \
281   case FN##F16: case FN##F32: case FN##F64: case FN##F128: \
282   case FN##F32X: case FN##F64X: case FN##F128X
283 #define CASE_FLT_FN_REENT(FN) case FN##_R: case FN##F_R: case FN##L_R
284 #define CASE_INT_FN(FN) case FN: case FN##L: case FN##LL: case FN##IMAX
285
286 #define NULL_TREE (tree) NULL
287
288 /* Define accessors for the fields that all tree nodes have
289    (though some fields are not used for all kinds of nodes).  */
290
291 /* The tree-code says what kind of node it is.
292    Codes are defined in tree.def.  */
293 #define TREE_CODE(NODE) ((enum tree_code) (NODE)->base.code)
294 #define TREE_SET_CODE(NODE, VALUE) ((NODE)->base.code = (VALUE))
295
296 /* When checking is enabled, errors will be generated if a tree node
297    is accessed incorrectly. The macros die with a fatal error.  */
298 #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
299
300 #define TREE_CHECK(T, CODE) \
301 (tree_check ((T), __FILE__, __LINE__, __FUNCTION__, (CODE)))
302
303 #define TREE_NOT_CHECK(T, CODE) \
304 (tree_not_check ((T), __FILE__, __LINE__, __FUNCTION__, (CODE)))
305
306 #define TREE_CHECK2(T, CODE1, CODE2) \
307 (tree_check2 ((T), __FILE__, __LINE__, __FUNCTION__, (CODE1), (CODE2)))
308
309 #define TREE_NOT_CHECK2(T, CODE1, CODE2) \
310 (tree_not_check2 ((T), __FILE__, __LINE__, __FUNCTION__, (CODE1), (CODE2)))
311
312 #define TREE_CHECK3(T, CODE1, CODE2, CODE3) \
313 (tree_check3 ((T), __FILE__, __LINE__, __FUNCTION__, (CODE1), (CODE2), (CODE3)))
314
315 #define TREE_NOT_CHECK3(T, CODE1, CODE2, CODE3) \
316 (tree_not_check3 ((T), __FILE__, __LINE__, __FUNCTION__, \
317                                (CODE1), (CODE2), (CODE3)))
318
319 #define TREE_CHECK4(T, CODE1, CODE2, CODE3, CODE4) \
320 (tree_check4 ((T), __FILE__, __LINE__, __FUNCTION__, \
321                            (CODE1), (CODE2), (CODE3), (CODE4)))
322
323 #define TREE_NOT_CHECK4(T, CODE1, CODE2, CODE3, CODE4) \
324 (tree_not_check4 ((T), __FILE__, __LINE__, __FUNCTION__, \
325                                (CODE1), (CODE2), (CODE3), (CODE4)))
326
327 #define TREE_CHECK5(T, CODE1, CODE2, CODE3, CODE4, CODE5) \
328 (tree_check5 ((T), __FILE__, __LINE__, __FUNCTION__, \
329                            (CODE1), (CODE2), (CODE3), (CODE4), (CODE5)))
330
331 #define TREE_NOT_CHECK5(T, CODE1, CODE2, CODE3, CODE4, CODE5) \
332 (tree_not_check5 ((T), __FILE__, __LINE__, __FUNCTION__, \
333                                (CODE1), (CODE2), (CODE3), (CODE4), (CODE5)))
334
335 #define CONTAINS_STRUCT_CHECK(T, STRUCT) \
336 (contains_struct_check ((T), (STRUCT), __FILE__, __LINE__, __FUNCTION__))
337
338 #define TREE_CLASS_CHECK(T, CLASS) \
339 (tree_class_check ((T), (CLASS), __FILE__, __LINE__, __FUNCTION__))
340
341 #define TREE_RANGE_CHECK(T, CODE1, CODE2) \
342 (tree_range_check ((T), (CODE1), (CODE2), __FILE__, __LINE__, __FUNCTION__))
343
344 #define OMP_CLAUSE_SUBCODE_CHECK(T, CODE) \
345 (omp_clause_subcode_check ((T), (CODE), __FILE__, __LINE__, __FUNCTION__))
346
347 #define OMP_CLAUSE_RANGE_CHECK(T, CODE1, CODE2) \
348 (omp_clause_range_check ((T), (CODE1), (CODE2), \
349                                       __FILE__, __LINE__, __FUNCTION__))
350
351 /* These checks have to be special cased.  */
352 #define EXPR_CHECK(T) \
353 (expr_check ((T), __FILE__, __LINE__, __FUNCTION__))
354
355 /* These checks have to be special cased.  */
356 #define NON_TYPE_CHECK(T) \
357 (non_type_check ((T), __FILE__, __LINE__, __FUNCTION__))
358
359 /* These checks have to be special cased.  */
360 #define ANY_INTEGRAL_TYPE_CHECK(T) \
361 (any_integral_type_check ((T), __FILE__, __LINE__, __FUNCTION__))
362
363 #define TREE_INT_CST_ELT_CHECK(T, I) \
364 (*tree_int_cst_elt_check ((T), (I), __FILE__, __LINE__, __FUNCTION__))
365
366 #define TREE_VEC_ELT_CHECK(T, I) \
367 (*(CONST_CAST2 (tree *, typeof (T)*, \
368      tree_vec_elt_check ((T), (I), __FILE__, __LINE__, __FUNCTION__))))
369
370 #define OMP_CLAUSE_ELT_CHECK(T, I) \
371 (*(omp_clause_elt_check ((T), (I), __FILE__, __LINE__, __FUNCTION__)))
372
373 /* Special checks for TREE_OPERANDs.  */
374 #define TREE_OPERAND_CHECK(T, I) \
375 (*(CONST_CAST2 (tree*, typeof (T)*, \
376      tree_operand_check ((T), (I), __FILE__, __LINE__, __FUNCTION__))))
377
378 #define TREE_OPERAND_CHECK_CODE(T, CODE, I) \
379 (*(tree_operand_check_code ((T), (CODE), (I), \
380                                          __FILE__, __LINE__, __FUNCTION__)))
381
382 /* Nodes are chained together for many purposes.
383    Types are chained together to record them for being output to the debugger
384    (see the function `chain_type').
385    Decls in the same scope are chained together to record the contents
386    of the scope.
387    Statement nodes for successive statements used to be chained together.
388    Often lists of things are represented by TREE_LIST nodes that
389    are chained together.  */
390
391 #define TREE_CHAIN(NODE) \
392 (CONTAINS_STRUCT_CHECK (NODE, TS_COMMON)->common.chain)
393
394 /* In all nodes that are expressions, this is the data type of the expression.
395    In POINTER_TYPE nodes, this is the type that the pointer points to.
396    In ARRAY_TYPE nodes, this is the type of the elements.
397    In VECTOR_TYPE nodes, this is the type of the elements.  */
398 #define TREE_TYPE(NODE) \
399 (CONTAINS_STRUCT_CHECK (NODE, TS_TYPED)->typed.type)
400
401 extern void tree_contains_struct_check_failed (const_tree,
402                                                const enum tree_node_structure_enum,
403                                                const char *, int, const char *)
404   ATTRIBUTE_NORETURN ATTRIBUTE_COLD;
405
406 extern void tree_check_failed (const_tree, const char *, int, const char *,
407                                ...) ATTRIBUTE_NORETURN ATTRIBUTE_COLD;
408 extern void tree_not_check_failed (const_tree, const char *, int, const char *,
409                                    ...) ATTRIBUTE_NORETURN ATTRIBUTE_COLD;
410 extern void tree_class_check_failed (const_tree, const enum tree_code_class,
411                                      const char *, int, const char *)
412     ATTRIBUTE_NORETURN ATTRIBUTE_COLD;
413 extern void tree_range_check_failed (const_tree, const char *, int,
414                                      const char *, enum tree_code,
415                                      enum tree_code)
416     ATTRIBUTE_NORETURN ATTRIBUTE_COLD;
417 extern void tree_not_class_check_failed (const_tree,
418                                          const enum tree_code_class,
419                                          const char *, int, const char *)
420     ATTRIBUTE_NORETURN ATTRIBUTE_COLD;
421 extern void tree_int_cst_elt_check_failed (int, int, const char *,
422                                            int, const char *)
423     ATTRIBUTE_NORETURN ATTRIBUTE_COLD;
424 extern void tree_vec_elt_check_failed (int, int, const char *,
425                                        int, const char *)
426     ATTRIBUTE_NORETURN ATTRIBUTE_COLD;
427 extern void phi_node_elt_check_failed (int, int, const char *,
428                                        int, const char *)
429     ATTRIBUTE_NORETURN ATTRIBUTE_COLD;
430 extern void tree_operand_check_failed (int, const_tree,
431                                        const char *, int, const char *)
432     ATTRIBUTE_NORETURN ATTRIBUTE_COLD;
433 extern void omp_clause_check_failed (const_tree, const char *, int,
434                                      const char *, enum omp_clause_code)
435     ATTRIBUTE_NORETURN ATTRIBUTE_COLD;
436 extern void omp_clause_operand_check_failed (int, const_tree, const char *,
437                                              int, const char *)
438     ATTRIBUTE_NORETURN ATTRIBUTE_COLD;
439 extern void omp_clause_range_check_failed (const_tree, const char *, int,
440                                const char *, enum omp_clause_code,
441                                enum omp_clause_code)
442     ATTRIBUTE_NORETURN ATTRIBUTE_COLD;
443
444 #else /* not ENABLE_TREE_CHECKING, or not gcc */
445
446 #define CONTAINS_STRUCT_CHECK(T, ENUM)          (T)
447 #define TREE_CHECK(T, CODE)                     (T)
448 #define TREE_NOT_CHECK(T, CODE)                 (T)
449 #define TREE_CHECK2(T, CODE1, CODE2)            (T)
450 #define TREE_NOT_CHECK2(T, CODE1, CODE2)        (T)
451 #define TREE_CHECK3(T, CODE1, CODE2, CODE3)     (T)
452 #define TREE_NOT_CHECK3(T, CODE1, CODE2, CODE3) (T)
453 #define TREE_CHECK4(T, CODE1, CODE2, CODE3, CODE4) (T)
454 #define TREE_NOT_CHECK4(T, CODE1, CODE2, CODE3, CODE4) (T)
455 #define TREE_CHECK5(T, CODE1, CODE2, CODE3, CODE4, CODE5) (T)
456 #define TREE_NOT_CHECK5(T, CODE1, CODE2, CODE3, CODE4, CODE5) (T)
457 #define TREE_CLASS_CHECK(T, CODE)               (T)
458 #define TREE_RANGE_CHECK(T, CODE1, CODE2)       (T)
459 #define EXPR_CHECK(T)                           (T)
460 #define NON_TYPE_CHECK(T)                       (T)
461 #define TREE_INT_CST_ELT_CHECK(T, I)            ((T)->int_cst.val[I])
462 #define TREE_VEC_ELT_CHECK(T, I)                ((T)->vec.a[I])
463 #define TREE_OPERAND_CHECK(T, I)                ((T)->exp.operands[I])
464 #define TREE_OPERAND_CHECK_CODE(T, CODE, I)     ((T)->exp.operands[I])
465 #define OMP_CLAUSE_ELT_CHECK(T, i)              ((T)->omp_clause.ops[i])
466 #define OMP_CLAUSE_RANGE_CHECK(T, CODE1, CODE2) (T)
467 #define OMP_CLAUSE_SUBCODE_CHECK(T, CODE)       (T)
468 #define ANY_INTEGRAL_TYPE_CHECK(T)              (T)
469
470 #define TREE_CHAIN(NODE) ((NODE)->common.chain)
471 #define TREE_TYPE(NODE) ((NODE)->typed.type)
472
473 #endif
474
475 #define TREE_BLOCK(NODE)                (tree_block (NODE))
476 #define TREE_SET_BLOCK(T, B)            (tree_set_block ((T), (B)))
477
478 #include "tree-check.h"
479
480 #define TYPE_CHECK(T)           TREE_CLASS_CHECK (T, tcc_type)
481 #define DECL_MINIMAL_CHECK(T)   CONTAINS_STRUCT_CHECK (T, TS_DECL_MINIMAL)
482 #define DECL_COMMON_CHECK(T)    CONTAINS_STRUCT_CHECK (T, TS_DECL_COMMON)
483 #define DECL_WRTL_CHECK(T)      CONTAINS_STRUCT_CHECK (T, TS_DECL_WRTL)
484 #define DECL_WITH_VIS_CHECK(T)  CONTAINS_STRUCT_CHECK (T, TS_DECL_WITH_VIS)
485 #define DECL_NON_COMMON_CHECK(T) CONTAINS_STRUCT_CHECK (T, TS_DECL_NON_COMMON)
486 #define CST_CHECK(T)            TREE_CLASS_CHECK (T, tcc_constant)
487 #define STMT_CHECK(T)           TREE_CLASS_CHECK (T, tcc_statement)
488 #define VL_EXP_CHECK(T)         TREE_CLASS_CHECK (T, tcc_vl_exp)
489 #define FUNC_OR_METHOD_CHECK(T) TREE_CHECK2 (T, FUNCTION_TYPE, METHOD_TYPE)
490 #define PTR_OR_REF_CHECK(T)     TREE_CHECK2 (T, POINTER_TYPE, REFERENCE_TYPE)
491
492 #define RECORD_OR_UNION_CHECK(T)        \
493   TREE_CHECK3 (T, RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE)
494 #define NOT_RECORD_OR_UNION_CHECK(T) \
495   TREE_NOT_CHECK3 (T, RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE)
496 #define ARRAY_OR_INTEGER_TYPE_CHECK(T)  \
497   TREE_CHECK2 (T, ARRAY_TYPE, INTEGER_TYPE)
498
499 #define NUMERICAL_TYPE_CHECK(T)                                 \
500   TREE_CHECK5 (T, INTEGER_TYPE, ENUMERAL_TYPE, BOOLEAN_TYPE, REAL_TYPE, \
501                FIXED_POINT_TYPE)
502
503 /* Here is how primitive or already-canonicalized types' hash codes
504    are made.  */
505 #define TYPE_HASH(TYPE) (TYPE_UID (TYPE))
506
507 /* A simple hash function for an arbitrary tree node.  This must not be
508    used in hash tables which are saved to a PCH.  */
509 #define TREE_HASH(NODE) ((size_t) (NODE) & 0777777)
510
511 /* Tests if CODE is a conversion expr (NOP_EXPR or CONVERT_EXPR).  */
512 #define CONVERT_EXPR_CODE_P(CODE)                               \
513   ((CODE) == NOP_EXPR || (CODE) == CONVERT_EXPR)
514
515 /* Similarly, but accept an expression instead of a tree code.  */
516 #define CONVERT_EXPR_P(EXP)     CONVERT_EXPR_CODE_P (TREE_CODE (EXP))
517
518 /* Generate case for NOP_EXPR, CONVERT_EXPR.  */
519
520 #define CASE_CONVERT                                            \
521   case NOP_EXPR:                                                \
522   case CONVERT_EXPR
523
524 /* Given an expression as a tree, strip any conversion that generates
525    no instruction.  Accepts both tree and const_tree arguments since
526    we are not modifying the tree itself.  */
527
528 #define STRIP_NOPS(EXP) \
529   (EXP) = tree_strip_nop_conversions (CONST_CAST_TREE (EXP))
530
531 /* Like STRIP_NOPS, but don't let the signedness change either.  */
532
533 #define STRIP_SIGN_NOPS(EXP) \
534   (EXP) = tree_strip_sign_nop_conversions (CONST_CAST_TREE (EXP))
535
536 /* Like STRIP_NOPS, but don't alter the TREE_TYPE either.  */
537
538 #define STRIP_TYPE_NOPS(EXP) \
539   while ((CONVERT_EXPR_P (EXP)                                  \
540           || TREE_CODE (EXP) == NON_LVALUE_EXPR)                \
541          && TREE_OPERAND (EXP, 0) != error_mark_node            \
542          && (TREE_TYPE (EXP)                                    \
543              == TREE_TYPE (TREE_OPERAND (EXP, 0))))             \
544     (EXP) = TREE_OPERAND (EXP, 0)
545
546 /* Remove unnecessary type conversions according to
547    tree_ssa_useless_type_conversion.  */
548
549 #define STRIP_USELESS_TYPE_CONVERSION(EXP) \
550   (EXP) = tree_ssa_strip_useless_type_conversions (EXP)
551
552 /* Remove any VIEW_CONVERT_EXPR or NON_LVALUE_EXPR that's purely
553    in use to provide a location_t.  */
554
555 #define STRIP_ANY_LOCATION_WRAPPER(EXP) \
556   (EXP) = tree_strip_any_location_wrapper (CONST_CAST_TREE (EXP))
557
558 /* Nonzero if TYPE represents a vector type.  */
559
560 #define VECTOR_TYPE_P(TYPE) (TREE_CODE (TYPE) == VECTOR_TYPE)
561
562 /* Nonzero if TYPE represents a vector of booleans.  */
563
564 #define VECTOR_BOOLEAN_TYPE_P(TYPE)                             \
565   (TREE_CODE (TYPE) == VECTOR_TYPE                      \
566    && TREE_CODE (TREE_TYPE (TYPE)) == BOOLEAN_TYPE)
567
568 /* Nonzero if TYPE represents an integral type.  Note that we do not
569    include COMPLEX types here.  Keep these checks in ascending code
570    order.  */
571
572 #define INTEGRAL_TYPE_P(TYPE)  \
573   (TREE_CODE (TYPE) == ENUMERAL_TYPE  \
574    || TREE_CODE (TYPE) == BOOLEAN_TYPE \
575    || TREE_CODE (TYPE) == INTEGER_TYPE)
576
577 /* Nonzero if TYPE represents an integral type, including complex
578    and vector integer types.  */
579
580 #define ANY_INTEGRAL_TYPE_P(TYPE)               \
581   (INTEGRAL_TYPE_P (TYPE)                       \
582    || ((TREE_CODE (TYPE) == COMPLEX_TYPE        \
583         || VECTOR_TYPE_P (TYPE))                \
584        && INTEGRAL_TYPE_P (TREE_TYPE (TYPE))))
585
586 /* Nonzero if TYPE represents a non-saturating fixed-point type.  */
587
588 #define NON_SAT_FIXED_POINT_TYPE_P(TYPE) \
589   (TREE_CODE (TYPE) == FIXED_POINT_TYPE && !TYPE_SATURATING (TYPE))
590
591 /* Nonzero if TYPE represents a saturating fixed-point type.  */
592
593 #define SAT_FIXED_POINT_TYPE_P(TYPE) \
594   (TREE_CODE (TYPE) == FIXED_POINT_TYPE && TYPE_SATURATING (TYPE))
595
596 /* Nonzero if TYPE represents a fixed-point type.  */
597
598 #define FIXED_POINT_TYPE_P(TYPE)        (TREE_CODE (TYPE) == FIXED_POINT_TYPE)
599
600 /* Nonzero if TYPE represents a scalar floating-point type.  */
601
602 #define SCALAR_FLOAT_TYPE_P(TYPE) (TREE_CODE (TYPE) == REAL_TYPE)
603
604 /* Nonzero if TYPE represents a complex floating-point type.  */
605
606 #define COMPLEX_FLOAT_TYPE_P(TYPE)      \
607   (TREE_CODE (TYPE) == COMPLEX_TYPE     \
608    && TREE_CODE (TREE_TYPE (TYPE)) == REAL_TYPE)
609
610 /* Nonzero if TYPE represents a vector integer type.  */
611                 
612 #define VECTOR_INTEGER_TYPE_P(TYPE)                     \
613   (VECTOR_TYPE_P (TYPE)                                 \
614    && TREE_CODE (TREE_TYPE (TYPE)) == INTEGER_TYPE)
615
616
617 /* Nonzero if TYPE represents a vector floating-point type.  */
618
619 #define VECTOR_FLOAT_TYPE_P(TYPE)       \
620   (VECTOR_TYPE_P (TYPE)                 \
621    && TREE_CODE (TREE_TYPE (TYPE)) == REAL_TYPE)
622
623 /* Nonzero if TYPE represents a floating-point type, including complex
624    and vector floating-point types.  The vector and complex check does
625    not use the previous two macros to enable early folding.  */
626
627 #define FLOAT_TYPE_P(TYPE)                      \
628   (SCALAR_FLOAT_TYPE_P (TYPE)                   \
629    || ((TREE_CODE (TYPE) == COMPLEX_TYPE        \
630         || VECTOR_TYPE_P (TYPE))                \
631        && SCALAR_FLOAT_TYPE_P (TREE_TYPE (TYPE))))
632
633 /* Nonzero if TYPE represents a decimal floating-point type.  */
634 #define DECIMAL_FLOAT_TYPE_P(TYPE)              \
635   (SCALAR_FLOAT_TYPE_P (TYPE)                   \
636    && DECIMAL_FLOAT_MODE_P (TYPE_MODE (TYPE)))
637
638 /* Nonzero if TYPE is a record or union type.  */
639 #define RECORD_OR_UNION_TYPE_P(TYPE)            \
640   (TREE_CODE (TYPE) == RECORD_TYPE              \
641    || TREE_CODE (TYPE) == UNION_TYPE            \
642    || TREE_CODE (TYPE) == QUAL_UNION_TYPE)
643
644 /* Nonzero if TYPE represents an aggregate (multi-component) type.
645    Keep these checks in ascending code order.  */
646
647 #define AGGREGATE_TYPE_P(TYPE) \
648   (TREE_CODE (TYPE) == ARRAY_TYPE || RECORD_OR_UNION_TYPE_P (TYPE))
649
650 /* Nonzero if TYPE represents a pointer or reference type.
651    (It should be renamed to INDIRECT_TYPE_P.)  Keep these checks in
652    ascending code order.  */
653
654 #define POINTER_TYPE_P(TYPE) \
655   (TREE_CODE (TYPE) == POINTER_TYPE || TREE_CODE (TYPE) == REFERENCE_TYPE)
656
657 /* Nonzero if TYPE represents a pointer to function.  */
658 #define FUNCTION_POINTER_TYPE_P(TYPE) \
659   (POINTER_TYPE_P (TYPE) && TREE_CODE (TREE_TYPE (TYPE)) == FUNCTION_TYPE)
660
661 /* Nonzero if this type is a complete type.  */
662 #define COMPLETE_TYPE_P(NODE) (TYPE_SIZE (NODE) != NULL_TREE)
663
664 /* Nonzero if this type is the (possibly qualified) void type.  */
665 #define VOID_TYPE_P(NODE) (TREE_CODE (NODE) == VOID_TYPE)
666
667 /* Nonzero if this type is complete or is cv void.  */
668 #define COMPLETE_OR_VOID_TYPE_P(NODE) \
669   (COMPLETE_TYPE_P (NODE) || VOID_TYPE_P (NODE))
670
671 /* Nonzero if this type is complete or is an array with unspecified bound.  */
672 #define COMPLETE_OR_UNBOUND_ARRAY_TYPE_P(NODE) \
673   (COMPLETE_TYPE_P (TREE_CODE (NODE) == ARRAY_TYPE ? TREE_TYPE (NODE) : (NODE)))
674
675 #define FUNC_OR_METHOD_TYPE_P(NODE) \
676   (TREE_CODE (NODE) == FUNCTION_TYPE || TREE_CODE (NODE) == METHOD_TYPE)
677
678 #define OPAQUE_TYPE_P(NODE) \
679     (TREE_CODE (NODE) == OPAQUE_TYPE)
680
681 /* Define many boolean fields that all tree nodes have.  */
682
683 /* In VAR_DECL, PARM_DECL and RESULT_DECL nodes, nonzero means address
684    of this is needed.  So it cannot be in a register.
685    In a FUNCTION_DECL it has no meaning.
686    In LABEL_DECL nodes, it means a goto for this label has been seen
687    from a place outside all binding contours that restore stack levels.
688    In an artificial SSA_NAME that points to a stack partition with at least
689    two variables, it means that at least one variable has TREE_ADDRESSABLE.
690    In ..._TYPE nodes, it means that objects of this type must be fully
691    addressable.  This means that pieces of this object cannot go into
692    register parameters, for example.  If this a function type, this
693    means that the value must be returned in memory.
694    In CONSTRUCTOR nodes, it means object constructed must be in memory.
695    In IDENTIFIER_NODEs, this means that some extern decl for this name
696    had its address taken.  That matters for inline functions.
697    In a STMT_EXPR, it means we want the result of the enclosed expression.  */
698 #define TREE_ADDRESSABLE(NODE) ((NODE)->base.addressable_flag)
699
700 /* Set on a CALL_EXPR if the call is in a tail position, ie. just before the
701    exit of a function.  Calls for which this is true are candidates for tail
702    call optimizations.  */
703 #define CALL_EXPR_TAILCALL(NODE) \
704   (CALL_EXPR_CHECK (NODE)->base.addressable_flag)
705
706 /* Set on a CALL_EXPR if the call has been marked as requiring tail call
707    optimization for correctness.  */
708 #define CALL_EXPR_MUST_TAIL_CALL(NODE) \
709   (CALL_EXPR_CHECK (NODE)->base.static_flag)
710
711 /* Used as a temporary field on a CASE_LABEL_EXPR to indicate that the
712    CASE_LOW operand has been processed.  */
713 #define CASE_LOW_SEEN(NODE) \
714   (CASE_LABEL_EXPR_CHECK (NODE)->base.addressable_flag)
715
716 #define PREDICT_EXPR_OUTCOME(NODE) \
717   ((enum prediction) (PREDICT_EXPR_CHECK (NODE)->base.addressable_flag))
718 #define SET_PREDICT_EXPR_OUTCOME(NODE, OUTCOME) \
719   (PREDICT_EXPR_CHECK (NODE)->base.addressable_flag = (int) OUTCOME)
720 #define PREDICT_EXPR_PREDICTOR(NODE) \
721   ((enum br_predictor)tree_to_shwi (TREE_OPERAND (PREDICT_EXPR_CHECK (NODE), 0)))
722
723 /* In a VAR_DECL, nonzero means allocate static storage.
724    In a FUNCTION_DECL, nonzero if function has been defined.
725    In a CONSTRUCTOR, nonzero means allocate static storage.  */
726 #define TREE_STATIC(NODE) ((NODE)->base.static_flag)
727
728 /* In an ADDR_EXPR, nonzero means do not use a trampoline.  */
729 #define TREE_NO_TRAMPOLINE(NODE) (ADDR_EXPR_CHECK (NODE)->base.static_flag)
730
731 /* In a TARGET_EXPR or WITH_CLEANUP_EXPR, means that the pertinent cleanup
732    should only be executed if an exception is thrown, not on normal exit
733    of its scope.  */
734 #define CLEANUP_EH_ONLY(NODE) ((NODE)->base.static_flag)
735
736 /* In a TRY_CATCH_EXPR, means that the handler should be considered a
737    separate cleanup in honor_protect_cleanup_actions.  */
738 #define TRY_CATCH_IS_CLEANUP(NODE) \
739   (TRY_CATCH_EXPR_CHECK (NODE)->base.static_flag)
740
741 /* Used as a temporary field on a CASE_LABEL_EXPR to indicate that the
742    CASE_HIGH operand has been processed.  */
743 #define CASE_HIGH_SEEN(NODE) \
744   (CASE_LABEL_EXPR_CHECK (NODE)->base.static_flag)
745
746 /* Used to mark scoped enums.  */
747 #define ENUM_IS_SCOPED(NODE) (ENUMERAL_TYPE_CHECK (NODE)->base.static_flag)
748
749 /* Determines whether an ENUMERAL_TYPE has defined the list of constants. */
750 #define ENUM_IS_OPAQUE(NODE) (ENUMERAL_TYPE_CHECK (NODE)->base.private_flag)
751
752 /* In an expr node (usually a conversion) this means the node was made
753    implicitly and should not lead to any sort of warning.  In a decl node,
754    warnings concerning the decl should be suppressed.  This is used at
755    least for used-before-set warnings, and it set after one warning is
756    emitted.  */
757 #define TREE_NO_WARNING(NODE) ((NODE)->base.nowarning_flag)
758
759 /* Nonzero if we should warn about the change in empty class parameter
760    passing ABI in this TU.  */
761 #define TRANSLATION_UNIT_WARN_EMPTY_P(NODE) \
762   (TRANSLATION_UNIT_DECL_CHECK (NODE)->decl_common.decl_flag_0)
763
764 /* Nonzero if this type is "empty" according to the particular psABI.  */
765 #define TYPE_EMPTY_P(NODE) (TYPE_CHECK (NODE)->type_common.empty_flag)
766
767 /* Used to indicate that this TYPE represents a compiler-generated entity.  */
768 #define TYPE_ARTIFICIAL(NODE) (TYPE_CHECK (NODE)->base.nowarning_flag)
769
770 /* True if the type is indivisible at the source level, i.e. if its
771    component parts cannot be accessed directly.  This is used to suppress
772    normal GNU extensions for target-specific vector types.  */
773 #define TYPE_INDIVISIBLE_P(NODE) (TYPE_CHECK (NODE)->type_common.indivisible_p)
774
775 /* True if this is a stdarg function with no named arguments (C2x
776    (...) prototype, where arguments can be accessed with va_start and
777    va_arg), as opposed to an unprototyped function.  */
778 #define TYPE_NO_NAMED_ARGS_STDARG_P(NODE) \
779   (TYPE_CHECK (NODE)->type_common.no_named_args_stdarg_p)
780
781 /* In an IDENTIFIER_NODE, this means that assemble_name was called with
782    this string as an argument.  */
783 #define TREE_SYMBOL_REFERENCED(NODE) \
784   (IDENTIFIER_NODE_CHECK (NODE)->base.static_flag)
785
786 /* Nonzero in a pointer or reference type means the data pointed to
787    by this type can alias anything.  */
788 #define TYPE_REF_CAN_ALIAS_ALL(NODE) \
789   (PTR_OR_REF_CHECK (NODE)->base.static_flag)
790
791 /* In an INTEGER_CST, REAL_CST, COMPLEX_CST, or VECTOR_CST, this means
792    there was an overflow in folding.  */
793
794 #define TREE_OVERFLOW(NODE) (CST_CHECK (NODE)->base.public_flag)
795
796 /* TREE_OVERFLOW can only be true for EXPR of CONSTANT_CLASS_P.  */
797
798 #define TREE_OVERFLOW_P(EXPR) \
799  (CONSTANT_CLASS_P (EXPR) && TREE_OVERFLOW (EXPR))
800
801 /* In a VAR_DECL, FUNCTION_DECL, NAMESPACE_DECL or TYPE_DECL,
802    nonzero means name is to be accessible from outside this translation unit.
803    In an IDENTIFIER_NODE, nonzero means an external declaration
804    accessible from outside this translation unit was previously seen
805    for this name in an inner scope.  */
806 #define TREE_PUBLIC(NODE) ((NODE)->base.public_flag)
807
808 /* In a _TYPE, indicates whether TYPE_CACHED_VALUES contains a vector
809    of cached values, or is something else.  */
810 #define TYPE_CACHED_VALUES_P(NODE) (TYPE_CHECK (NODE)->base.public_flag)
811
812 /* In a SAVE_EXPR, indicates that the original expression has already
813    been substituted with a VAR_DECL that contains the value.  */
814 #define SAVE_EXPR_RESOLVED_P(NODE) \
815   (SAVE_EXPR_CHECK (NODE)->base.public_flag)
816
817 /* Set on a CALL_EXPR if this stdarg call should be passed the argument
818    pack.  */
819 #define CALL_EXPR_VA_ARG_PACK(NODE) \
820   (CALL_EXPR_CHECK (NODE)->base.public_flag)
821
822 /* In any expression, decl, or constant, nonzero means it has side effects or
823    reevaluation of the whole expression could produce a different value.
824    This is set if any subexpression is a function call, a side effect or a
825    reference to a volatile variable.  In a ..._DECL, this is set only if the
826    declaration said `volatile'.  This will never be set for a constant.  */
827 #define TREE_SIDE_EFFECTS(NODE) \
828   (NON_TYPE_CHECK (NODE)->base.side_effects_flag)
829
830 /* In a LABEL_DECL, nonzero means this label had its address taken
831    and therefore can never be deleted and is a jump target for
832    computed gotos.  */
833 #define FORCED_LABEL(NODE) (LABEL_DECL_CHECK (NODE)->base.side_effects_flag)
834
835 /* Whether a case or a user-defined label is allowed to fall through to.
836    This is used to implement -Wimplicit-fallthrough.  */
837 #define FALLTHROUGH_LABEL_P(NODE) \
838   (LABEL_DECL_CHECK (NODE)->base.private_flag)
839
840 /* Set on the artificial label created for break; stmt from a switch.
841    This is used to implement -Wimplicit-fallthrough.  */
842 #define SWITCH_BREAK_LABEL_P(NODE) \
843   (LABEL_DECL_CHECK (NODE)->base.protected_flag)
844
845 /* Set on label that is known not to be jumped to, it can be only
846    reached by falling through from previous statements.
847    This is used to implement -Wimplicit-fallthrough.  */
848 #define UNUSED_LABEL_P(NODE) \
849   (LABEL_DECL_CHECK (NODE)->base.default_def_flag)
850
851 /* Nonzero means this expression is volatile in the C sense:
852    its address should be of type `volatile WHATEVER *'.
853    In other words, the declared item is volatile qualified.
854    This is used in _DECL nodes and _REF nodes.
855    On a FUNCTION_DECL node, this means the function does not
856    return normally.  This is the same effect as setting
857    the attribute noreturn on the function in C.
858
859    In a ..._TYPE node, means this type is volatile-qualified.
860    But use TYPE_VOLATILE instead of this macro when the node is a type,
861    because eventually we may make that a different bit.
862
863    If this bit is set in an expression, so is TREE_SIDE_EFFECTS.  */
864 #define TREE_THIS_VOLATILE(NODE) ((NODE)->base.volatile_flag)
865
866 /* Nonzero means this node will not trap.  In an INDIRECT_REF, means
867    accessing the memory pointed to won't generate a trap.  However,
868    this only applies to an object when used appropriately: it doesn't
869    mean that writing a READONLY mem won't trap.
870
871    In ARRAY_REF and ARRAY_RANGE_REF means that we know that the index
872    (or slice of the array) always belongs to the range of the array.
873    I.e. that the access will not trap, provided that the access to
874    the base to the array will not trap.  */
875 #define TREE_THIS_NOTRAP(NODE) \
876   (TREE_CHECK5 (NODE, INDIRECT_REF, MEM_REF, TARGET_MEM_REF, ARRAY_REF, \
877                 ARRAY_RANGE_REF)->base.nothrow_flag)
878
879 /* In a VAR_DECL, PARM_DECL or FIELD_DECL, or any kind of ..._REF node,
880    nonzero means it may not be the lhs of an assignment.
881    Nonzero in a FUNCTION_DECL means this function should be treated
882    as "const" function (can only read its arguments).  */
883 #define TREE_READONLY(NODE) (NON_TYPE_CHECK (NODE)->base.readonly_flag)
884
885 /* Value of expression is constant.  Always on in all ..._CST nodes.  May
886    also appear in an expression or decl where the value is constant.  */
887 #define TREE_CONSTANT(NODE) (NON_TYPE_CHECK (NODE)->base.constant_flag)
888
889 /* Nonzero if NODE, a type, has had its sizes gimplified.  */
890 #define TYPE_SIZES_GIMPLIFIED(NODE) \
891   (TYPE_CHECK (NODE)->base.constant_flag)
892
893 /* In a decl (most significantly a FIELD_DECL), means an unsigned field.  */
894 #define DECL_UNSIGNED(NODE) \
895   (DECL_COMMON_CHECK (NODE)->base.u.bits.unsigned_flag)
896
897 /* In integral and pointer types, means an unsigned type.  */
898 #define TYPE_UNSIGNED(NODE) (TYPE_CHECK (NODE)->base.u.bits.unsigned_flag)
899
900 /* Same as TYPE_UNSIGNED but converted to SIGNOP.  */
901 #define TYPE_SIGN(NODE) ((signop) TYPE_UNSIGNED (NODE))
902
903 /* True if overflow wraps around for the given integral or pointer type.  That
904    is, TYPE_MAX + 1 == TYPE_MIN.  */
905 #define TYPE_OVERFLOW_WRAPS(TYPE) \
906   (POINTER_TYPE_P (TYPE)                                        \
907    ? flag_wrapv_pointer                                         \
908    : (ANY_INTEGRAL_TYPE_CHECK(TYPE)->base.u.bits.unsigned_flag  \
909       || flag_wrapv))
910
911 /* True if overflow is undefined for the given integral or pointer type.
912    We may optimize on the assumption that values in the type never overflow.
913
914    IMPORTANT NOTE: Any optimization based on TYPE_OVERFLOW_UNDEFINED
915    must issue a warning based on warn_strict_overflow.  In some cases
916    it will be appropriate to issue the warning immediately, and in
917    other cases it will be appropriate to simply set a flag and let the
918    caller decide whether a warning is appropriate or not.  */
919 #define TYPE_OVERFLOW_UNDEFINED(TYPE)                           \
920   (POINTER_TYPE_P (TYPE)                                        \
921    ? !flag_wrapv_pointer                                        \
922    : (!ANY_INTEGRAL_TYPE_CHECK(TYPE)->base.u.bits.unsigned_flag \
923       && !flag_wrapv && !flag_trapv))
924
925 /* True if overflow for the given integral type should issue a
926    trap.  */
927 #define TYPE_OVERFLOW_TRAPS(TYPE) \
928   (!ANY_INTEGRAL_TYPE_CHECK(TYPE)->base.u.bits.unsigned_flag && flag_trapv)
929
930 /* True if an overflow is to be preserved for sanitization.  */
931 #define TYPE_OVERFLOW_SANITIZED(TYPE)                   \
932   (INTEGRAL_TYPE_P (TYPE)                               \
933    && !TYPE_OVERFLOW_WRAPS (TYPE)                       \
934    && (flag_sanitize & SANITIZE_SI_OVERFLOW))
935
936 /* Nonzero in a VAR_DECL or STRING_CST means assembler code has been written.
937    Nonzero in a FUNCTION_DECL means that the function has been compiled.
938    This is interesting in an inline function, since it might not need
939    to be compiled separately.
940    Nonzero in a RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE, ENUMERAL_TYPE
941    or TYPE_DECL if the debugging info for the type has been written.
942    In a BLOCK node, nonzero if reorder_blocks has already seen this block.
943    In an SSA_NAME node, nonzero if the SSA_NAME occurs in an abnormal
944    PHI node.  */
945 #define TREE_ASM_WRITTEN(NODE) ((NODE)->base.asm_written_flag)
946
947 /* Nonzero in a _DECL if the name is used in its scope.
948    Nonzero in an expr node means inhibit warning if value is unused.
949    In IDENTIFIER_NODEs, this means that some extern decl for this name
950    was used.
951    In a BLOCK, this means that the block contains variables that are used.  */
952 #define TREE_USED(NODE) ((NODE)->base.used_flag)
953
954 /* In a FUNCTION_DECL, nonzero means a call to the function cannot
955    throw an exception.  In a CALL_EXPR, nonzero means the call cannot
956    throw.  We can't easily check the node type here as the C++
957    frontend also uses this flag (for AGGR_INIT_EXPR).  */
958 #define TREE_NOTHROW(NODE) ((NODE)->base.nothrow_flag)
959
960 /* In a CALL_EXPR, means that it's safe to use the target of the call
961    expansion as the return slot for a call that returns in memory.  */
962 #define CALL_EXPR_RETURN_SLOT_OPT(NODE) \
963   (CALL_EXPR_CHECK (NODE)->base.private_flag)
964
965 /* In a RESULT_DECL, PARM_DECL and VAR_DECL, means that it is
966    passed by invisible reference (and the TREE_TYPE is a pointer to the true
967    type).  */
968 #define DECL_BY_REFERENCE(NODE) \
969   (TREE_CHECK3 (NODE, VAR_DECL, PARM_DECL, \
970                 RESULT_DECL)->decl_common.decl_by_reference_flag)
971
972 /* In VAR_DECL and PARM_DECL, set when the decl has been used except for
973    being set.  */
974 #define DECL_READ_P(NODE) \
975   (TREE_CHECK2 (NODE, VAR_DECL, PARM_DECL)->decl_common.decl_read_flag)
976
977 /* In VAR_DECL or RESULT_DECL, set when significant code movement precludes
978    attempting to share the stack slot with some other variable.  */
979 #define DECL_NONSHAREABLE(NODE) \
980   (TREE_CHECK2 (NODE, VAR_DECL, \
981                 RESULT_DECL)->decl_common.decl_nonshareable_flag)
982
983 /* In a PARM_DECL, set for Fortran hidden string length arguments that some
984    buggy callers don't pass to the callee.  */
985 #define DECL_HIDDEN_STRING_LENGTH(NODE) \
986   (TREE_CHECK (NODE, PARM_DECL)->decl_common.decl_nonshareable_flag)
987
988 /* In a CALL_EXPR, means that the call is the jump from a thunk to the
989    thunked-to function.  Be careful to avoid using this macro when one of the
990    next two applies instead.  */
991 #define CALL_FROM_THUNK_P(NODE) (CALL_EXPR_CHECK (NODE)->base.protected_flag)
992
993 /* In a CALL_EXPR, if the function being called is BUILT_IN_ALLOCA, means that
994    it has been built for the declaration of a variable-sized object and, if the
995    function being called is BUILT_IN_MEMCPY, means that it has been built for
996    the assignment of a variable-sized object.  */
997 #define CALL_ALLOCA_FOR_VAR_P(NODE) \
998   (CALL_EXPR_CHECK (NODE)->base.protected_flag)
999
1000 /* In a CALL_EXPR, if the function being called is DECL_IS_OPERATOR_NEW_P or
1001    DECL_IS_OPERATOR_DELETE_P, true for allocator calls from C++ new or delete
1002    expressions.  Not set for C++20 destroying delete operators.  */
1003 #define CALL_FROM_NEW_OR_DELETE_P(NODE) \
1004   (CALL_EXPR_CHECK (NODE)->base.protected_flag)
1005
1006 /* Used in classes in C++.  */
1007 #define TREE_PRIVATE(NODE) ((NODE)->base.private_flag)
1008 /* Used in classes in C++. */
1009 #define TREE_PROTECTED(NODE) ((NODE)->base.protected_flag)
1010
1011 /* True if reference type NODE is a C++ rvalue reference.  */
1012 #define TYPE_REF_IS_RVALUE(NODE) \
1013   (REFERENCE_TYPE_CHECK (NODE)->base.private_flag)
1014
1015 /* Nonzero in a _DECL if the use of the name is defined as a
1016    deprecated feature by __attribute__((deprecated)).  */
1017 #define TREE_DEPRECATED(NODE) \
1018   ((NODE)->base.deprecated_flag)
1019
1020 /* Nonzero in a _DECL if the use of the name is defined as an
1021    unavailable feature by __attribute__((unavailable)).  */
1022 #define TREE_UNAVAILABLE(NODE) \
1023   ((NODE)->base.u.bits.unavailable_flag)
1024
1025 /* Nonzero indicates an IDENTIFIER_NODE that names an anonymous
1026    aggregate, (as created by anon_aggr_name_format).  */
1027 #define IDENTIFIER_ANON_P(NODE) \
1028   (IDENTIFIER_NODE_CHECK (NODE)->base.private_flag)
1029
1030 /* Nonzero in an IDENTIFIER_NODE if the name is a local alias, whose
1031    uses are to be substituted for uses of the TREE_CHAINed identifier.  */
1032 #define IDENTIFIER_TRANSPARENT_ALIAS(NODE) \
1033   (IDENTIFIER_NODE_CHECK (NODE)->base.deprecated_flag)
1034
1035 /* In an aggregate type, indicates that the scalar fields of the type are
1036    stored in reverse order from the target order.  This effectively
1037    toggles BYTES_BIG_ENDIAN and WORDS_BIG_ENDIAN within the type.  */
1038 #define TYPE_REVERSE_STORAGE_ORDER(NODE) \
1039   (TREE_CHECK4 (NODE, RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE, ARRAY_TYPE)->base.u.bits.saturating_flag)
1040
1041 /* In a non-aggregate type, indicates a saturating type.  */
1042 #define TYPE_SATURATING(NODE) \
1043   (TREE_NOT_CHECK4 (NODE, RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE, ARRAY_TYPE)->base.u.bits.saturating_flag)
1044
1045 /* In a BIT_FIELD_REF and MEM_REF, indicates that the reference is to a group
1046    of bits stored in reverse order from the target order.  This effectively
1047    toggles both BYTES_BIG_ENDIAN and WORDS_BIG_ENDIAN for the reference.
1048
1049    The overall strategy is to preserve the invariant that every scalar in
1050    memory is associated with a single storage order, i.e. all accesses to
1051    this scalar are done with the same storage order.  This invariant makes
1052    it possible to factor out the storage order in most transformations, as
1053    only the address and/or the value (in target order) matter for them.
1054    But, of course, the storage order must be preserved when the accesses
1055    themselves are rewritten or transformed.  */
1056 #define REF_REVERSE_STORAGE_ORDER(NODE) \
1057   (TREE_CHECK2 (NODE, BIT_FIELD_REF, MEM_REF)->base.default_def_flag)
1058
1059   /* In an ADDR_EXPR, indicates that this is a pointer to nested function
1060    represented by a descriptor instead of a trampoline.  */
1061 #define FUNC_ADDR_BY_DESCRIPTOR(NODE) \
1062   (TREE_CHECK (NODE, ADDR_EXPR)->base.default_def_flag)
1063
1064 /* In a CALL_EXPR, indicates that this is an indirect call for which
1065    pointers to nested function are descriptors instead of trampolines.  */
1066 #define CALL_EXPR_BY_DESCRIPTOR(NODE) \
1067   (TREE_CHECK (NODE, CALL_EXPR)->base.default_def_flag)
1068
1069 /* These flags are available for each language front end to use internally.  */
1070 #define TREE_LANG_FLAG_0(NODE) \
1071   (TREE_NOT_CHECK2 (NODE, TREE_VEC, SSA_NAME)->base.u.bits.lang_flag_0)
1072 #define TREE_LANG_FLAG_1(NODE) \
1073   (TREE_NOT_CHECK2 (NODE, TREE_VEC, SSA_NAME)->base.u.bits.lang_flag_1)
1074 #define TREE_LANG_FLAG_2(NODE) \
1075   (TREE_NOT_CHECK2 (NODE, TREE_VEC, SSA_NAME)->base.u.bits.lang_flag_2)
1076 #define TREE_LANG_FLAG_3(NODE) \
1077   (TREE_NOT_CHECK2 (NODE, TREE_VEC, SSA_NAME)->base.u.bits.lang_flag_3)
1078 #define TREE_LANG_FLAG_4(NODE) \
1079   (TREE_NOT_CHECK2 (NODE, TREE_VEC, SSA_NAME)->base.u.bits.lang_flag_4)
1080 #define TREE_LANG_FLAG_5(NODE) \
1081   (TREE_NOT_CHECK2 (NODE, TREE_VEC, SSA_NAME)->base.u.bits.lang_flag_5)
1082 #define TREE_LANG_FLAG_6(NODE) \
1083   (TREE_NOT_CHECK2 (NODE, TREE_VEC, SSA_NAME)->base.u.bits.lang_flag_6)
1084
1085 /* Define additional fields and accessors for nodes representing constants.  */
1086
1087 #define TREE_INT_CST_NUNITS(NODE) \
1088   (INTEGER_CST_CHECK (NODE)->base.u.int_length.unextended)
1089 #define TREE_INT_CST_EXT_NUNITS(NODE) \
1090   (INTEGER_CST_CHECK (NODE)->base.u.int_length.extended)
1091 #define TREE_INT_CST_OFFSET_NUNITS(NODE) \
1092   (INTEGER_CST_CHECK (NODE)->base.u.int_length.offset)
1093 #define TREE_INT_CST_ELT(NODE, I) TREE_INT_CST_ELT_CHECK (NODE, I)
1094 #define TREE_INT_CST_LOW(NODE) \
1095   ((unsigned HOST_WIDE_INT) TREE_INT_CST_ELT (NODE, 0))
1096
1097 /* Return true if NODE is a POLY_INT_CST.  This is only ever true on
1098    targets with variable-sized modes.  */
1099 #define POLY_INT_CST_P(NODE) \
1100   (NUM_POLY_INT_COEFFS > 1 && TREE_CODE (NODE) == POLY_INT_CST)
1101
1102 /* In a POLY_INT_CST node.  */
1103 #define POLY_INT_CST_COEFF(NODE, I) \
1104   (POLY_INT_CST_CHECK (NODE)->poly_int_cst.coeffs[I])
1105
1106 #define TREE_REAL_CST_PTR(NODE) (&REAL_CST_CHECK (NODE)->real_cst.value)
1107 #define TREE_REAL_CST(NODE) (*TREE_REAL_CST_PTR (NODE))
1108
1109 #define TREE_FIXED_CST_PTR(NODE) \
1110   (FIXED_CST_CHECK (NODE)->fixed_cst.fixed_cst_ptr)
1111 #define TREE_FIXED_CST(NODE) (*TREE_FIXED_CST_PTR (NODE))
1112
1113 /* In a STRING_CST */
1114 /* In C terms, this is sizeof, not strlen.  */
1115 #define TREE_STRING_LENGTH(NODE) (STRING_CST_CHECK (NODE)->string.length)
1116 #define TREE_STRING_POINTER(NODE) \
1117   ((const char *)(STRING_CST_CHECK (NODE)->string.str))
1118
1119 /* In a COMPLEX_CST node.  */
1120 #define TREE_REALPART(NODE) (COMPLEX_CST_CHECK (NODE)->complex.real)
1121 #define TREE_IMAGPART(NODE) (COMPLEX_CST_CHECK (NODE)->complex.imag)
1122
1123 /* In a VECTOR_CST node.  See generic.texi for details.  */
1124 #define VECTOR_CST_NELTS(NODE) (TYPE_VECTOR_SUBPARTS (TREE_TYPE (NODE)))
1125 #define VECTOR_CST_ELT(NODE,IDX) vector_cst_elt (NODE, IDX)
1126
1127 #define VECTOR_CST_LOG2_NPATTERNS(NODE) \
1128   (VECTOR_CST_CHECK (NODE)->base.u.vector_cst.log2_npatterns)
1129 #define VECTOR_CST_NPATTERNS(NODE) \
1130   (1U << VECTOR_CST_LOG2_NPATTERNS (NODE))
1131 #define VECTOR_CST_NELTS_PER_PATTERN(NODE) \
1132   (VECTOR_CST_CHECK (NODE)->base.u.vector_cst.nelts_per_pattern)
1133 #define VECTOR_CST_DUPLICATE_P(NODE) \
1134   (VECTOR_CST_NELTS_PER_PATTERN (NODE) == 1)
1135 #define VECTOR_CST_STEPPED_P(NODE) \
1136   (VECTOR_CST_NELTS_PER_PATTERN (NODE) == 3)
1137 #define VECTOR_CST_ENCODED_ELTS(NODE) \
1138   (VECTOR_CST_CHECK (NODE)->vector.elts)
1139 #define VECTOR_CST_ENCODED_ELT(NODE, ELT) \
1140   (VECTOR_CST_CHECK (NODE)->vector.elts[ELT])
1141
1142 /* Define fields and accessors for some special-purpose tree nodes.  */
1143
1144 /* Unlike STRING_CST, in C terms this is strlen, not sizeof.  */
1145 #define IDENTIFIER_LENGTH(NODE) \
1146   (IDENTIFIER_NODE_CHECK (NODE)->identifier.id.len)
1147 #define IDENTIFIER_POINTER(NODE) \
1148   ((const char *) IDENTIFIER_NODE_CHECK (NODE)->identifier.id.str)
1149 #define IDENTIFIER_HASH_VALUE(NODE) \
1150   (IDENTIFIER_NODE_CHECK (NODE)->identifier.id.hash_value)
1151
1152 /* Translate a hash table identifier pointer to a tree_identifier
1153    pointer, and vice versa.  */
1154
1155 #define HT_IDENT_TO_GCC_IDENT(NODE) \
1156   ((tree) ((char *) (NODE) - sizeof (struct tree_common)))
1157 #define GCC_IDENT_TO_HT_IDENT(NODE) (&((struct tree_identifier *) (NODE))->id)
1158
1159 /* In a TREE_LIST node.  */
1160 #define TREE_PURPOSE(NODE) (TREE_LIST_CHECK (NODE)->list.purpose)
1161 #define TREE_VALUE(NODE) (TREE_LIST_CHECK (NODE)->list.value)
1162
1163 /* In a TREE_VEC node.  */
1164 #define TREE_VEC_LENGTH(NODE) (TREE_VEC_CHECK (NODE)->base.u.length)
1165 #define TREE_VEC_BEGIN(NODE) (&TREE_VEC_CHECK (NODE)->vec.a[0])
1166 #define TREE_VEC_END(NODE) \
1167   ((void) TREE_VEC_CHECK (NODE), &((NODE)->vec.a[(NODE)->base.u.length]))
1168
1169 #define TREE_VEC_ELT(NODE,I) TREE_VEC_ELT_CHECK (NODE, I)
1170
1171 /* In a CONSTRUCTOR node.  */
1172 #define CONSTRUCTOR_ELTS(NODE) (CONSTRUCTOR_CHECK (NODE)->constructor.elts)
1173 #define CONSTRUCTOR_ELT(NODE,IDX) \
1174   (&(*CONSTRUCTOR_ELTS (NODE))[IDX])
1175 #define CONSTRUCTOR_NELTS(NODE) \
1176   (vec_safe_length (CONSTRUCTOR_ELTS (NODE)))
1177 #define CONSTRUCTOR_NO_CLEARING(NODE) \
1178   (CONSTRUCTOR_CHECK (NODE)->base.public_flag)
1179
1180 /* Iterate through the vector V of CONSTRUCTOR_ELT elements, yielding the
1181    value of each element (stored within VAL). IX must be a scratch variable
1182    of unsigned integer type.  */
1183 #define FOR_EACH_CONSTRUCTOR_VALUE(V, IX, VAL) \
1184   for (IX = 0; (IX >= vec_safe_length (V)) \
1185                ? false \
1186                : ((VAL = (*(V))[IX].value), \
1187                true); \
1188        (IX)++)
1189
1190 /* Iterate through the vector V of CONSTRUCTOR_ELT elements, yielding both
1191    the value of each element (stored within VAL) and its index (stored
1192    within INDEX). IX must be a scratch variable of unsigned integer type.  */
1193 #define FOR_EACH_CONSTRUCTOR_ELT(V, IX, INDEX, VAL) \
1194   for (IX = 0; (IX >= vec_safe_length (V)) \
1195                ? false \
1196                : (((void) (VAL = (*V)[IX].value)), \
1197                   (INDEX = (*V)[IX].index), \
1198                   true); \
1199        (IX)++)
1200
1201 /* Append a new constructor element to V, with the specified INDEX and VAL.  */
1202 #define CONSTRUCTOR_APPEND_ELT(V, INDEX, VALUE) \
1203   do { \
1204     constructor_elt _ce___ = {INDEX, VALUE}; \
1205     vec_safe_push ((V), _ce___); \
1206   } while (0)
1207
1208 /* True if NODE, a FIELD_DECL, is to be processed as a bitfield for
1209    constructor output purposes.  */
1210 #define CONSTRUCTOR_BITFIELD_P(NODE) \
1211   (DECL_BIT_FIELD (FIELD_DECL_CHECK (NODE)) && DECL_MODE (NODE) != BLKmode)
1212
1213 /* True if NODE is a clobber right hand side, an expression of indeterminate
1214    value that clobbers the LHS in a copy instruction.  We use a volatile
1215    empty CONSTRUCTOR for this, as it matches most of the necessary semantic.
1216    In particular the volatile flag causes us to not prematurely remove
1217    such clobber instructions.  */
1218 #define TREE_CLOBBER_P(NODE) \
1219   (TREE_CODE (NODE) == CONSTRUCTOR && TREE_THIS_VOLATILE (NODE))
1220
1221 /* Return the clobber_kind of a CLOBBER CONSTRUCTOR.  */
1222 #define CLOBBER_KIND(NODE) \
1223   (CONSTRUCTOR_CHECK (NODE)->base.u.bits.address_space)
1224
1225 /* Define fields and accessors for some nodes that represent expressions.  */
1226
1227 /* Nonzero if NODE is an empty statement (NOP_EXPR <0>).  */
1228 #define IS_EMPTY_STMT(NODE)     (TREE_CODE (NODE) == NOP_EXPR \
1229                                  && VOID_TYPE_P (TREE_TYPE (NODE)) \
1230                                  && integer_zerop (TREE_OPERAND (NODE, 0)))
1231
1232 /* In ordinary expression nodes.  */
1233 #define TREE_OPERAND_LENGTH(NODE) tree_operand_length (NODE)
1234 #define TREE_OPERAND(NODE, I) TREE_OPERAND_CHECK (NODE, I)
1235
1236 /* In a tcc_vl_exp node, operand 0 is an INT_CST node holding the operand
1237    length.  Its value includes the length operand itself; that is,
1238    the minimum valid length is 1.
1239    Note that we have to bypass the use of TREE_OPERAND to access
1240    that field to avoid infinite recursion in expanding the macros.  */
1241 #define VL_EXP_OPERAND_LENGTH(NODE) \
1242   ((int)TREE_INT_CST_LOW (VL_EXP_CHECK (NODE)->exp.operands[0]))
1243
1244 /* Nonzero if gimple_debug_nonbind_marker_p() may possibly hold.  */
1245 #define MAY_HAVE_DEBUG_MARKER_STMTS debug_nonbind_markers_p
1246 /* Nonzero if gimple_debug_bind_p() (and thus
1247    gimple_debug_source_bind_p()) may possibly hold.  */
1248 #define MAY_HAVE_DEBUG_BIND_STMTS flag_var_tracking_assignments
1249 /* Nonzero if is_gimple_debug() may possibly hold.  */
1250 #define MAY_HAVE_DEBUG_STMTS                                    \
1251   (MAY_HAVE_DEBUG_MARKER_STMTS || MAY_HAVE_DEBUG_BIND_STMTS)
1252
1253 /* In a LOOP_EXPR node.  */
1254 #define LOOP_EXPR_BODY(NODE) TREE_OPERAND_CHECK_CODE (NODE, LOOP_EXPR, 0)
1255
1256 /* The source location of this expression.  Non-tree_exp nodes such as
1257    decls and constants can be shared among multiple locations, so
1258    return nothing.  */
1259 #define EXPR_LOCATION(NODE) \
1260   (CAN_HAVE_LOCATION_P ((NODE)) ? (NODE)->exp.locus : UNKNOWN_LOCATION)
1261 #define SET_EXPR_LOCATION(NODE, LOCUS) EXPR_CHECK ((NODE))->exp.locus = (LOCUS)
1262 #define EXPR_HAS_LOCATION(NODE) (LOCATION_LOCUS (EXPR_LOCATION (NODE))  \
1263   != UNKNOWN_LOCATION)
1264 /* The location to be used in a diagnostic about this expression.  Do not
1265    use this macro if the location will be assigned to other expressions.  */
1266 #define EXPR_LOC_OR_LOC(NODE, LOCUS) (EXPR_HAS_LOCATION (NODE) \
1267                                       ? (NODE)->exp.locus : (LOCUS))
1268 #define EXPR_FILENAME(NODE) LOCATION_FILE (EXPR_CHECK ((NODE))->exp.locus)
1269 #define EXPR_LINENO(NODE) LOCATION_LINE (EXPR_CHECK (NODE)->exp.locus)
1270
1271 #define CAN_HAVE_RANGE_P(NODE) (CAN_HAVE_LOCATION_P (NODE))
1272 #define EXPR_LOCATION_RANGE(NODE) (get_expr_source_range (EXPR_CHECK ((NODE))))
1273
1274 #define EXPR_HAS_RANGE(NODE) \
1275     (CAN_HAVE_RANGE_P (NODE) \
1276      ? EXPR_LOCATION_RANGE (NODE).m_start != UNKNOWN_LOCATION \
1277      : false)
1278
1279 /* True if a tree is an expression or statement that can have a
1280    location.  */
1281 #define CAN_HAVE_LOCATION_P(NODE) ((NODE) && EXPR_P (NODE))
1282
1283 static inline source_range
1284 get_expr_source_range (tree expr)
1285 {
1286   location_t loc = EXPR_LOCATION (expr);
1287   return get_range_from_loc (line_table, loc);
1288 }
1289
1290 extern void protected_set_expr_location (tree, location_t);
1291 extern void protected_set_expr_location_if_unset (tree, location_t);
1292
1293 WARN_UNUSED_RESULT extern tree maybe_wrap_with_location (tree, location_t);
1294
1295 extern int suppress_location_wrappers;
1296
1297 /* A class for suppressing the creation of location wrappers.
1298    Location wrappers will not be created during the lifetime
1299    of an instance of this class.  */
1300
1301 class auto_suppress_location_wrappers
1302 {
1303  public:
1304   auto_suppress_location_wrappers () { ++suppress_location_wrappers; }
1305   ~auto_suppress_location_wrappers () { --suppress_location_wrappers; }
1306 };
1307
1308 /* In a TARGET_EXPR node.  */
1309 #define TARGET_EXPR_SLOT(NODE) TREE_OPERAND_CHECK_CODE (NODE, TARGET_EXPR, 0)
1310 #define TARGET_EXPR_INITIAL(NODE) TREE_OPERAND_CHECK_CODE (NODE, TARGET_EXPR, 1)
1311 #define TARGET_EXPR_CLEANUP(NODE) TREE_OPERAND_CHECK_CODE (NODE, TARGET_EXPR, 2)
1312 /* Don't elide the initialization of TARGET_EXPR_SLOT for this TARGET_EXPR
1313    on rhs of MODIFY_EXPR.  */
1314 #define TARGET_EXPR_NO_ELIDE(NODE) (TARGET_EXPR_CHECK (NODE)->base.private_flag)
1315
1316 /* DECL_EXPR accessor. This gives access to the DECL associated with
1317    the given declaration statement.  */
1318 #define DECL_EXPR_DECL(NODE)    TREE_OPERAND (DECL_EXPR_CHECK (NODE), 0)
1319
1320 #define EXIT_EXPR_COND(NODE)         TREE_OPERAND (EXIT_EXPR_CHECK (NODE), 0)
1321
1322 /* COMPOUND_LITERAL_EXPR accessors.  */
1323 #define COMPOUND_LITERAL_EXPR_DECL_EXPR(NODE)           \
1324   TREE_OPERAND (COMPOUND_LITERAL_EXPR_CHECK (NODE), 0)
1325 #define COMPOUND_LITERAL_EXPR_DECL(NODE)                        \
1326   DECL_EXPR_DECL (COMPOUND_LITERAL_EXPR_DECL_EXPR (NODE))
1327
1328 /* SWITCH_EXPR accessors. These give access to the condition and body.  */
1329 #define SWITCH_COND(NODE)       TREE_OPERAND (SWITCH_EXPR_CHECK (NODE), 0)
1330 #define SWITCH_BODY(NODE)       TREE_OPERAND (SWITCH_EXPR_CHECK (NODE), 1)
1331 /* True if there are case labels for all possible values of SWITCH_COND, either
1332    because there is a default: case label or because the case label ranges cover
1333    all values.  */
1334 #define SWITCH_ALL_CASES_P(NODE) (SWITCH_EXPR_CHECK (NODE)->base.private_flag)
1335
1336 /* CASE_LABEL_EXPR accessors. These give access to the high and low values
1337    of a case label, respectively.  */
1338 #define CASE_LOW(NODE)                  TREE_OPERAND (CASE_LABEL_EXPR_CHECK (NODE), 0)
1339 #define CASE_HIGH(NODE)                 TREE_OPERAND (CASE_LABEL_EXPR_CHECK (NODE), 1)
1340 #define CASE_LABEL(NODE)                TREE_OPERAND (CASE_LABEL_EXPR_CHECK (NODE), 2)
1341 #define CASE_CHAIN(NODE)                TREE_OPERAND (CASE_LABEL_EXPR_CHECK (NODE), 3)
1342
1343 /* The operands of a TARGET_MEM_REF.  Operands 0 and 1 have to match
1344    corresponding MEM_REF operands.  */
1345 #define TMR_BASE(NODE) (TREE_OPERAND (TARGET_MEM_REF_CHECK (NODE), 0))
1346 #define TMR_OFFSET(NODE) (TREE_OPERAND (TARGET_MEM_REF_CHECK (NODE), 1))
1347 #define TMR_INDEX(NODE) (TREE_OPERAND (TARGET_MEM_REF_CHECK (NODE), 2))
1348 #define TMR_STEP(NODE) (TREE_OPERAND (TARGET_MEM_REF_CHECK (NODE), 3))
1349 #define TMR_INDEX2(NODE) (TREE_OPERAND (TARGET_MEM_REF_CHECK (NODE), 4))
1350
1351 #define MR_DEPENDENCE_CLIQUE(NODE) \
1352   (TREE_CHECK2 (NODE, MEM_REF, TARGET_MEM_REF)->base.u.dependence_info.clique)
1353 #define MR_DEPENDENCE_BASE(NODE) \
1354   (TREE_CHECK2 (NODE, MEM_REF, TARGET_MEM_REF)->base.u.dependence_info.base)
1355
1356 /* The operands of a BIND_EXPR.  */
1357 #define BIND_EXPR_VARS(NODE) (TREE_OPERAND (BIND_EXPR_CHECK (NODE), 0))
1358 #define BIND_EXPR_BODY(NODE) (TREE_OPERAND (BIND_EXPR_CHECK (NODE), 1))
1359 #define BIND_EXPR_BLOCK(NODE) (TREE_OPERAND (BIND_EXPR_CHECK (NODE), 2))
1360
1361 /* GOTO_EXPR accessor. This gives access to the label associated with
1362    a goto statement.  */
1363 #define GOTO_DESTINATION(NODE)  TREE_OPERAND (GOTO_EXPR_CHECK (NODE), 0)
1364
1365 /* ASM_EXPR accessors. ASM_STRING returns a STRING_CST for the
1366    instruction (e.g., "mov x, y"). ASM_OUTPUTS, ASM_INPUTS, and
1367    ASM_CLOBBERS represent the outputs, inputs, and clobbers for the
1368    statement.  */
1369 #define ASM_STRING(NODE)        TREE_OPERAND (ASM_EXPR_CHECK (NODE), 0)
1370 #define ASM_OUTPUTS(NODE)       TREE_OPERAND (ASM_EXPR_CHECK (NODE), 1)
1371 #define ASM_INPUTS(NODE)        TREE_OPERAND (ASM_EXPR_CHECK (NODE), 2)
1372 #define ASM_CLOBBERS(NODE)      TREE_OPERAND (ASM_EXPR_CHECK (NODE), 3)
1373 #define ASM_LABELS(NODE)        TREE_OPERAND (ASM_EXPR_CHECK (NODE), 4)
1374 /* Nonzero if we want to create an ASM_INPUT instead of an
1375    ASM_OPERAND with no operands.  */
1376 #define ASM_INPUT_P(NODE) (ASM_EXPR_CHECK (NODE)->base.static_flag)
1377 #define ASM_VOLATILE_P(NODE) (ASM_EXPR_CHECK (NODE)->base.public_flag)
1378 /* Nonzero if we want to consider this asm as minimum length and cost
1379    for inlining decisions.  */
1380 #define ASM_INLINE_P(NODE) (ASM_EXPR_CHECK (NODE)->base.protected_flag)
1381
1382 /* COND_EXPR accessors.  */
1383 #define COND_EXPR_COND(NODE)    (TREE_OPERAND (COND_EXPR_CHECK (NODE), 0))
1384 #define COND_EXPR_THEN(NODE)    (TREE_OPERAND (COND_EXPR_CHECK (NODE), 1))
1385 #define COND_EXPR_ELSE(NODE)    (TREE_OPERAND (COND_EXPR_CHECK (NODE), 2))
1386
1387 /* Accessors for the chains of recurrences.  */
1388 #define CHREC_LEFT(NODE)          TREE_OPERAND (POLYNOMIAL_CHREC_CHECK (NODE), 0)
1389 #define CHREC_RIGHT(NODE)         TREE_OPERAND (POLYNOMIAL_CHREC_CHECK (NODE), 1)
1390 #define CHREC_VARIABLE(NODE)      POLYNOMIAL_CHREC_CHECK (NODE)->base.u.chrec_var
1391
1392 /* LABEL_EXPR accessor. This gives access to the label associated with
1393    the given label expression.  */
1394 #define LABEL_EXPR_LABEL(NODE)  TREE_OPERAND (LABEL_EXPR_CHECK (NODE), 0)
1395
1396 /* CATCH_EXPR accessors.  */
1397 #define CATCH_TYPES(NODE)       TREE_OPERAND (CATCH_EXPR_CHECK (NODE), 0)
1398 #define CATCH_BODY(NODE)        TREE_OPERAND (CATCH_EXPR_CHECK (NODE), 1)
1399
1400 /* EH_FILTER_EXPR accessors.  */
1401 #define EH_FILTER_TYPES(NODE)   TREE_OPERAND (EH_FILTER_EXPR_CHECK (NODE), 0)
1402 #define EH_FILTER_FAILURE(NODE) TREE_OPERAND (EH_FILTER_EXPR_CHECK (NODE), 1)
1403
1404 /* OBJ_TYPE_REF accessors.  */
1405 #define OBJ_TYPE_REF_EXPR(NODE)   TREE_OPERAND (OBJ_TYPE_REF_CHECK (NODE), 0)
1406 #define OBJ_TYPE_REF_OBJECT(NODE) TREE_OPERAND (OBJ_TYPE_REF_CHECK (NODE), 1)
1407 #define OBJ_TYPE_REF_TOKEN(NODE)  TREE_OPERAND (OBJ_TYPE_REF_CHECK (NODE), 2)
1408
1409 /* ASSERT_EXPR accessors.  */
1410 #define ASSERT_EXPR_VAR(NODE)   TREE_OPERAND (ASSERT_EXPR_CHECK (NODE), 0)
1411 #define ASSERT_EXPR_COND(NODE)  TREE_OPERAND (ASSERT_EXPR_CHECK (NODE), 1)
1412
1413 /* CALL_EXPR accessors.  */
1414 #define CALL_EXPR_FN(NODE) TREE_OPERAND (CALL_EXPR_CHECK (NODE), 1)
1415 #define CALL_EXPR_STATIC_CHAIN(NODE) TREE_OPERAND (CALL_EXPR_CHECK (NODE), 2)
1416 #define CALL_EXPR_ARG(NODE, I) TREE_OPERAND (CALL_EXPR_CHECK (NODE), (I) + 3)
1417 #define call_expr_nargs(NODE) (VL_EXP_OPERAND_LENGTH (NODE) - 3)
1418 #define CALL_EXPR_IFN(NODE) (CALL_EXPR_CHECK (NODE)->base.u.ifn)
1419
1420 /* CALL_EXPR_ARGP returns a pointer to the argument vector for NODE.
1421    We can't use &CALL_EXPR_ARG (NODE, 0) because that will complain if
1422    the argument count is zero when checking is enabled.  Instead, do
1423    the pointer arithmetic to advance past the 3 fixed operands in a
1424    CALL_EXPR.  That produces a valid pointer to just past the end of the
1425    operand array, even if it's not valid to dereference it.  */
1426 #define CALL_EXPR_ARGP(NODE) \
1427   (&(TREE_OPERAND (CALL_EXPR_CHECK (NODE), 0)) + 3)
1428
1429 /* TM directives and accessors.  */
1430 #define TRANSACTION_EXPR_BODY(NODE) \
1431   TREE_OPERAND (TRANSACTION_EXPR_CHECK (NODE), 0)
1432 #define TRANSACTION_EXPR_OUTER(NODE) \
1433   (TRANSACTION_EXPR_CHECK (NODE)->base.static_flag)
1434 #define TRANSACTION_EXPR_RELAXED(NODE) \
1435   (TRANSACTION_EXPR_CHECK (NODE)->base.public_flag)
1436
1437 /* OpenMP and OpenACC directive and clause accessors.  */
1438
1439 /* Generic accessors for OMP nodes that keep the body as operand 0, and clauses
1440    as operand 1.  */
1441 #define OMP_BODY(NODE) \
1442   TREE_OPERAND (TREE_RANGE_CHECK (NODE, OACC_PARALLEL, OMP_MASTER), 0)
1443 #define OMP_CLAUSES(NODE) \
1444   TREE_OPERAND (TREE_RANGE_CHECK (NODE, OACC_PARALLEL, OMP_SCAN), 1)
1445
1446 /* Generic accessors for OMP nodes that keep clauses as operand 0.  */
1447 #define OMP_STANDALONE_CLAUSES(NODE) \
1448   TREE_OPERAND (TREE_RANGE_CHECK (NODE, OACC_CACHE, OMP_TARGET_EXIT_DATA), 0)
1449
1450 #define OACC_DATA_BODY(NODE) \
1451   TREE_OPERAND (OACC_DATA_CHECK (NODE), 0)
1452 #define OACC_DATA_CLAUSES(NODE) \
1453   TREE_OPERAND (OACC_DATA_CHECK (NODE), 1)
1454
1455 #define OACC_HOST_DATA_BODY(NODE) \
1456   TREE_OPERAND (OACC_HOST_DATA_CHECK (NODE), 0)
1457 #define OACC_HOST_DATA_CLAUSES(NODE) \
1458   TREE_OPERAND (OACC_HOST_DATA_CHECK (NODE), 1)
1459
1460 #define OACC_CACHE_CLAUSES(NODE) \
1461   TREE_OPERAND (OACC_CACHE_CHECK (NODE), 0)
1462
1463 #define OACC_DECLARE_CLAUSES(NODE) \
1464   TREE_OPERAND (OACC_DECLARE_CHECK (NODE), 0)
1465
1466 #define OACC_ENTER_DATA_CLAUSES(NODE) \
1467   TREE_OPERAND (OACC_ENTER_DATA_CHECK (NODE), 0)
1468
1469 #define OACC_EXIT_DATA_CLAUSES(NODE) \
1470   TREE_OPERAND (OACC_EXIT_DATA_CHECK (NODE), 0)
1471
1472 #define OACC_UPDATE_CLAUSES(NODE) \
1473   TREE_OPERAND (OACC_UPDATE_CHECK (NODE), 0)
1474
1475 #define OMP_PARALLEL_BODY(NODE)    TREE_OPERAND (OMP_PARALLEL_CHECK (NODE), 0)
1476 #define OMP_PARALLEL_CLAUSES(NODE) TREE_OPERAND (OMP_PARALLEL_CHECK (NODE), 1)
1477
1478 #define OMP_TASK_BODY(NODE)        TREE_OPERAND (OMP_TASK_CHECK (NODE), 0)
1479 #define OMP_TASK_CLAUSES(NODE)     TREE_OPERAND (OMP_TASK_CHECK (NODE), 1)
1480
1481 #define OMP_TASKREG_CHECK(NODE)   TREE_RANGE_CHECK (NODE, OMP_PARALLEL, OMP_TASK)
1482 #define OMP_TASKREG_BODY(NODE)    TREE_OPERAND (OMP_TASKREG_CHECK (NODE), 0)
1483 #define OMP_TASKREG_CLAUSES(NODE) TREE_OPERAND (OMP_TASKREG_CHECK (NODE), 1)
1484
1485 #define OMP_LOOPING_CHECK(NODE) TREE_RANGE_CHECK (NODE, OMP_FOR, OACC_LOOP)
1486 #define OMP_FOR_BODY(NODE)         TREE_OPERAND (OMP_LOOPING_CHECK (NODE), 0)
1487 #define OMP_FOR_CLAUSES(NODE)      TREE_OPERAND (OMP_LOOPING_CHECK (NODE), 1)
1488 #define OMP_FOR_INIT(NODE)         TREE_OPERAND (OMP_LOOPING_CHECK (NODE), 2)
1489 #define OMP_FOR_COND(NODE)         TREE_OPERAND (OMP_LOOPING_CHECK (NODE), 3)
1490 #define OMP_FOR_INCR(NODE)         TREE_OPERAND (OMP_LOOPING_CHECK (NODE), 4)
1491 #define OMP_FOR_PRE_BODY(NODE)     TREE_OPERAND (OMP_LOOPING_CHECK (NODE), 5)
1492 #define OMP_FOR_ORIG_DECLS(NODE)   TREE_OPERAND (OMP_LOOPING_CHECK (NODE), 6)
1493
1494 #define OMP_SECTIONS_BODY(NODE)    TREE_OPERAND (OMP_SECTIONS_CHECK (NODE), 0)
1495 #define OMP_SECTIONS_CLAUSES(NODE) TREE_OPERAND (OMP_SECTIONS_CHECK (NODE), 1)
1496
1497 #define OMP_SECTION_BODY(NODE)     TREE_OPERAND (OMP_SECTION_CHECK (NODE), 0)
1498
1499 #define OMP_SINGLE_BODY(NODE)      TREE_OPERAND (OMP_SINGLE_CHECK (NODE), 0)
1500 #define OMP_SINGLE_CLAUSES(NODE)   TREE_OPERAND (OMP_SINGLE_CHECK (NODE), 1)
1501
1502 #define OMP_SCOPE_BODY(NODE)       TREE_OPERAND (OMP_SCOPE_CHECK (NODE), 0)
1503 #define OMP_SCOPE_CLAUSES(NODE)    TREE_OPERAND (OMP_SCOPE_CHECK (NODE), 1)
1504
1505 #define OMP_MASTER_BODY(NODE)      TREE_OPERAND (OMP_MASTER_CHECK (NODE), 0)
1506
1507 #define OMP_MASKED_BODY(NODE)      TREE_OPERAND (OMP_MASKED_CHECK (NODE), 0)
1508 #define OMP_MASKED_CLAUSES(NODE)   TREE_OPERAND (OMP_MASKED_CHECK (NODE), 1)
1509
1510 #define OMP_TASKGROUP_BODY(NODE)   TREE_OPERAND (OMP_TASKGROUP_CHECK (NODE), 0)
1511 #define OMP_TASKGROUP_CLAUSES(NODE) \
1512   TREE_OPERAND (OMP_TASKGROUP_CHECK (NODE), 1)
1513
1514 #define OMP_ORDERED_BODY(NODE)     TREE_OPERAND (OMP_ORDERED_CHECK (NODE), 0)
1515 #define OMP_ORDERED_CLAUSES(NODE)  TREE_OPERAND (OMP_ORDERED_CHECK (NODE), 1)
1516
1517 #define OMP_CRITICAL_BODY(NODE)    TREE_OPERAND (OMP_CRITICAL_CHECK (NODE), 0)
1518 #define OMP_CRITICAL_CLAUSES(NODE) TREE_OPERAND (OMP_CRITICAL_CHECK (NODE), 1)
1519 #define OMP_CRITICAL_NAME(NODE)    TREE_OPERAND (OMP_CRITICAL_CHECK (NODE), 2)
1520
1521 #define OMP_TEAMS_BODY(NODE)       TREE_OPERAND (OMP_TEAMS_CHECK (NODE), 0)
1522 #define OMP_TEAMS_CLAUSES(NODE)    TREE_OPERAND (OMP_TEAMS_CHECK (NODE), 1)
1523
1524 #define OMP_TARGET_DATA_BODY(NODE) \
1525   TREE_OPERAND (OMP_TARGET_DATA_CHECK (NODE), 0)
1526 #define OMP_TARGET_DATA_CLAUSES(NODE)\
1527   TREE_OPERAND (OMP_TARGET_DATA_CHECK (NODE), 1)
1528
1529 #define OMP_TARGET_BODY(NODE)      TREE_OPERAND (OMP_TARGET_CHECK (NODE), 0)
1530 #define OMP_TARGET_CLAUSES(NODE)   TREE_OPERAND (OMP_TARGET_CHECK (NODE), 1)
1531
1532 #define OMP_TARGET_UPDATE_CLAUSES(NODE)\
1533   TREE_OPERAND (OMP_TARGET_UPDATE_CHECK (NODE), 0)
1534
1535 #define OMP_TARGET_ENTER_DATA_CLAUSES(NODE)\
1536   TREE_OPERAND (OMP_TARGET_ENTER_DATA_CHECK (NODE), 0)
1537
1538 #define OMP_TARGET_EXIT_DATA_CLAUSES(NODE)\
1539   TREE_OPERAND (OMP_TARGET_EXIT_DATA_CHECK (NODE), 0)
1540
1541 #define OMP_SCAN_BODY(NODE)     TREE_OPERAND (OMP_SCAN_CHECK (NODE), 0)
1542 #define OMP_SCAN_CLAUSES(NODE)  TREE_OPERAND (OMP_SCAN_CHECK (NODE), 1)
1543
1544 #define OMP_CLAUSE_SIZE(NODE)                                           \
1545   OMP_CLAUSE_OPERAND (OMP_CLAUSE_RANGE_CHECK (OMP_CLAUSE_CHECK (NODE),  \
1546                                               OMP_CLAUSE_FROM,          \
1547                                               OMP_CLAUSE__CACHE_), 1)
1548
1549 #define OMP_CLAUSE_CHAIN(NODE)     TREE_CHAIN (OMP_CLAUSE_CHECK (NODE))
1550 #define OMP_CLAUSE_DECL(NODE)                                           \
1551   OMP_CLAUSE_OPERAND (OMP_CLAUSE_RANGE_CHECK (OMP_CLAUSE_CHECK (NODE),  \
1552                                               OMP_CLAUSE_PRIVATE,       \
1553                                               OMP_CLAUSE__SCANTEMP_), 0)
1554 #define OMP_CLAUSE_HAS_LOCATION(NODE) \
1555   (LOCATION_LOCUS ((OMP_CLAUSE_CHECK (NODE))->omp_clause.locus)         \
1556   != UNKNOWN_LOCATION)
1557 #define OMP_CLAUSE_LOCATION(NODE)  (OMP_CLAUSE_CHECK (NODE))->omp_clause.locus
1558
1559 /* True on OMP_FOR and other OpenMP/OpenACC looping constructs if the loop nest
1560    is non-rectangular.  */
1561 #define OMP_FOR_NON_RECTANGULAR(NODE) \
1562   (OMP_LOOPING_CHECK (NODE)->base.private_flag)
1563
1564 /* True on an OMP_SECTION statement that was the last lexical member.
1565    This status is meaningful in the implementation of lastprivate.  */
1566 #define OMP_SECTION_LAST(NODE) \
1567   (OMP_SECTION_CHECK (NODE)->base.private_flag)
1568
1569 /* True on an OMP_PARALLEL statement if it represents an explicit
1570    combined parallel work-sharing constructs.  */
1571 #define OMP_PARALLEL_COMBINED(NODE) \
1572   (OMP_PARALLEL_CHECK (NODE)->base.private_flag)
1573
1574 /* True on an OMP_TEAMS statement if it represents an explicit
1575    combined teams distribute constructs.  */
1576 #define OMP_TEAMS_COMBINED(NODE) \
1577   (OMP_TEAMS_CHECK (NODE)->base.private_flag)
1578
1579 /* True on an OMP_TARGET statement if it represents explicit
1580    combined target teams, target parallel or target simd constructs.  */
1581 #define OMP_TARGET_COMBINED(NODE) \
1582   (OMP_TARGET_CHECK (NODE)->base.private_flag)
1583
1584 /* True on an OMP_MASTER statement if it represents an explicit
1585    combined master constructs.  */
1586 #define OMP_MASTER_COMBINED(NODE) \
1587   (OMP_MASTER_CHECK (NODE)->base.private_flag)
1588
1589 /* True on an OMP_MASKED statement if it represents an explicit
1590    combined masked constructs.  */
1591 #define OMP_MASKED_COMBINED(NODE) \
1592   (OMP_MASKED_CHECK (NODE)->base.private_flag)
1593
1594 /* Memory order for OMP_ATOMIC*.  */
1595 #define OMP_ATOMIC_MEMORY_ORDER(NODE) \
1596   (TREE_RANGE_CHECK (NODE, OMP_ATOMIC, \
1597                      OMP_ATOMIC_CAPTURE_NEW)->base.u.omp_atomic_memory_order)
1598
1599 /* Weak clause on OMP_ATOMIC*.  */
1600 #define OMP_ATOMIC_WEAK(NODE) \
1601   (TREE_RANGE_CHECK (NODE, OMP_ATOMIC, \
1602                      OMP_ATOMIC_CAPTURE_NEW)->base.public_flag)
1603
1604 /* True on a PRIVATE clause if its decl is kept around for debugging
1605    information only and its DECL_VALUE_EXPR is supposed to point
1606    to what it has been remapped to.  */
1607 #define OMP_CLAUSE_PRIVATE_DEBUG(NODE) \
1608   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_PRIVATE)->base.public_flag)
1609
1610 /* True on a PRIVATE clause if ctor needs access to outer region's
1611    variable.  */
1612 #define OMP_CLAUSE_PRIVATE_OUTER_REF(NODE) \
1613   TREE_PRIVATE (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_PRIVATE))
1614
1615 /* True if a PRIVATE clause is for a C++ class IV on taskloop construct
1616    (thus should be private on the outer taskloop and firstprivate on
1617    task).  */
1618 #define OMP_CLAUSE_PRIVATE_TASKLOOP_IV(NODE) \
1619   TREE_PROTECTED (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_PRIVATE))
1620
1621 /* True on a FIRSTPRIVATE clause if it has been added implicitly.  */
1622 #define OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT(NODE) \
1623   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_FIRSTPRIVATE)->base.public_flag)
1624
1625 /* True on a FIRSTPRIVATE clause if only the reference and not what it refers
1626    to should be firstprivatized.  */
1627 #define OMP_CLAUSE_FIRSTPRIVATE_NO_REFERENCE(NODE) \
1628   TREE_PRIVATE (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_FIRSTPRIVATE))
1629
1630 /* True on a FIRSTPRIVATE clause with OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT also
1631    set if target construct is the only one that accepts the clause.  */
1632 #define OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT_TARGET(NODE) \
1633   TREE_PROTECTED (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_FIRSTPRIVATE))
1634
1635 /* True on a LASTPRIVATE clause if a FIRSTPRIVATE clause for the same
1636    decl is present in the chain.  */
1637 #define OMP_CLAUSE_LASTPRIVATE_FIRSTPRIVATE(NODE) \
1638   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_LASTPRIVATE)->base.public_flag)
1639 #define OMP_CLAUSE_LASTPRIVATE_STMT(NODE) \
1640   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE,                   \
1641                                                 OMP_CLAUSE_LASTPRIVATE),\
1642                       1)
1643 #define OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ(NODE) \
1644   (OMP_CLAUSE_CHECK (NODE))->omp_clause.gimple_reduction_init
1645
1646 /* True if a LASTPRIVATE clause is for a C++ class IV on taskloop or
1647    loop construct (thus should be lastprivate on the outer taskloop and
1648    firstprivate on task for the taskloop construct and carefully handled
1649    for loop construct).  */
1650 #define OMP_CLAUSE_LASTPRIVATE_LOOP_IV(NODE) \
1651   TREE_PROTECTED (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_LASTPRIVATE))
1652
1653 /* True if a LASTPRIVATE clause has CONDITIONAL: modifier.  */
1654 #define OMP_CLAUSE_LASTPRIVATE_CONDITIONAL(NODE) \
1655   TREE_PRIVATE (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_LASTPRIVATE))
1656
1657 /* True on a SHARED clause if a FIRSTPRIVATE clause for the same
1658    decl is present in the chain (this can happen only for taskloop
1659    with FIRSTPRIVATE/LASTPRIVATE on it originally.  */
1660 #define OMP_CLAUSE_SHARED_FIRSTPRIVATE(NODE) \
1661   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_SHARED)->base.public_flag)
1662
1663 /* True on a SHARED clause if a scalar is not modified in the body and
1664    thus could be optimized as firstprivate.  */
1665 #define OMP_CLAUSE_SHARED_READONLY(NODE) \
1666   TREE_PRIVATE (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_SHARED))
1667
1668 #define OMP_CLAUSE_IF_MODIFIER(NODE)    \
1669   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_IF)->omp_clause.subcode.if_modifier)
1670
1671 #define OMP_CLAUSE_FINAL_EXPR(NODE) \
1672   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_FINAL), 0)
1673 #define OMP_CLAUSE_IF_EXPR(NODE) \
1674   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_IF), 0)
1675 #define OMP_CLAUSE_NUM_THREADS_EXPR(NODE) \
1676   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_NUM_THREADS),0)
1677 #define OMP_CLAUSE_SCHEDULE_CHUNK_EXPR(NODE) \
1678   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_SCHEDULE), 0)
1679 #define OMP_CLAUSE_NUM_TASKS_EXPR(NODE) \
1680   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_NUM_TASKS), 0)
1681 #define OMP_CLAUSE_HINT_EXPR(NODE) \
1682   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_HINT), 0)
1683 #define OMP_CLAUSE_FILTER_EXPR(NODE) \
1684   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_FILTER), 0)
1685
1686 #define OMP_CLAUSE_GRAINSIZE_EXPR(NODE) \
1687   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_GRAINSIZE),0)
1688
1689 #define OMP_CLAUSE_PRIORITY_EXPR(NODE) \
1690   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_PRIORITY),0)
1691
1692 #define OMP_CLAUSE_GRAINSIZE_STRICT(NODE) \
1693   TREE_PRIVATE (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_GRAINSIZE))
1694 #define OMP_CLAUSE_NUM_TASKS_STRICT(NODE) \
1695   TREE_PRIVATE (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_NUM_TASKS))
1696
1697 /* OpenACC clause expressions  */
1698 #define OMP_CLAUSE_EXPR(NODE, CLAUSE) \
1699   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, CLAUSE), 0)
1700 #define OMP_CLAUSE_GANG_EXPR(NODE) \
1701   OMP_CLAUSE_OPERAND ( \
1702     OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_GANG), 0)
1703 #define OMP_CLAUSE_GANG_STATIC_EXPR(NODE) \
1704   OMP_CLAUSE_OPERAND ( \
1705     OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_GANG), 1)
1706 #define OMP_CLAUSE_ASYNC_EXPR(NODE) \
1707   OMP_CLAUSE_OPERAND ( \
1708     OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_ASYNC), 0)
1709 #define OMP_CLAUSE_WAIT_EXPR(NODE) \
1710   OMP_CLAUSE_OPERAND ( \
1711     OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_WAIT), 0)
1712 #define OMP_CLAUSE_VECTOR_EXPR(NODE) \
1713   OMP_CLAUSE_OPERAND ( \
1714     OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_VECTOR), 0)
1715 #define OMP_CLAUSE_WORKER_EXPR(NODE) \
1716   OMP_CLAUSE_OPERAND ( \
1717     OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_WORKER), 0)
1718 #define OMP_CLAUSE_NUM_GANGS_EXPR(NODE) \
1719   OMP_CLAUSE_OPERAND ( \
1720     OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_NUM_GANGS), 0)
1721 #define OMP_CLAUSE_NUM_WORKERS_EXPR(NODE) \
1722   OMP_CLAUSE_OPERAND ( \
1723     OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_NUM_WORKERS), 0)
1724 #define OMP_CLAUSE_VECTOR_LENGTH_EXPR(NODE) \
1725   OMP_CLAUSE_OPERAND ( \
1726     OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_VECTOR_LENGTH), 0)
1727
1728 #define OMP_CLAUSE_DEPEND_KIND(NODE) \
1729   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_DEPEND)->omp_clause.subcode.depend_kind)
1730
1731 #define OMP_CLAUSE_DOACROSS_KIND(NODE) \
1732   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_DOACROSS)->omp_clause.subcode.doacross_kind)
1733
1734 #define OMP_CLAUSE_DOACROSS_SINK_NEGATIVE(NODE) \
1735   TREE_PUBLIC (TREE_LIST_CHECK (NODE))
1736
1737 /* True if DOACROSS clause is spelled as DEPEND.  */
1738 #define OMP_CLAUSE_DOACROSS_DEPEND(NODE) \
1739   TREE_PROTECTED (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_DOACROSS))
1740
1741 #define OMP_CLAUSE_MAP_KIND(NODE) \
1742   ((enum gomp_map_kind) OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_MAP)->omp_clause.subcode.map_kind)
1743 #define OMP_CLAUSE_SET_MAP_KIND(NODE, MAP_KIND) \
1744   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_MAP)->omp_clause.subcode.map_kind \
1745    = (unsigned int) (MAP_KIND))
1746
1747 /* Nonzero if this map clause is for array (rather than pointer) based array
1748    section with zero bias.  Both the non-decl OMP_CLAUSE_MAP and corresponding
1749    OMP_CLAUSE_MAP with GOMP_MAP_POINTER are marked with this flag.  */
1750 #define OMP_CLAUSE_MAP_ZERO_BIAS_ARRAY_SECTION(NODE) \
1751   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_MAP)->base.public_flag)
1752 /* Nonzero if this is a mapped array section, that might need special
1753    treatment if OMP_CLAUSE_SIZE is zero.  */
1754 #define OMP_CLAUSE_MAP_MAYBE_ZERO_LENGTH_ARRAY_SECTION(NODE) \
1755   TREE_PROTECTED (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_MAP))
1756 /* Nonzero if this map clause is for an OpenACC compute construct's reduction
1757    variable or OpenMP map clause mentioned also in in_reduction clause on the
1758    same construct.  */
1759 #define OMP_CLAUSE_MAP_IN_REDUCTION(NODE) \
1760   TREE_PRIVATE (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_MAP))
1761 /* Nonzero on map clauses added implicitly for reduction clauses on combined
1762    or composite constructs.  They shall be removed if there is an explicit
1763    map clause.  */
1764 #define OMP_CLAUSE_MAP_IMPLICIT(NODE) \
1765   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_MAP)->base.default_def_flag)
1766 /* Nonzero if this map clause is to be indicated to the runtime as 'implicit',
1767    due to being created through implicit data-mapping rules in the middle-end.
1768    NOTE: this is different than OMP_CLAUSE_MAP_IMPLICIT.  */
1769 #define OMP_CLAUSE_MAP_RUNTIME_IMPLICIT_P(NODE) \
1770   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_MAP)->base.deprecated_flag)
1771
1772 /* Flag that 'OMP_CLAUSE_DECL (NODE)' is to be made addressable during OMP
1773    lowering.  */
1774 #define OMP_CLAUSE_MAP_DECL_MAKE_ADDRESSABLE(NODE) \
1775   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_MAP)->base.addressable_flag)
1776
1777 /* True on an OMP_CLAUSE_USE_DEVICE_PTR with an OpenACC 'if_present'
1778    clause.  */
1779 #define OMP_CLAUSE_USE_DEVICE_PTR_IF_PRESENT(NODE) \
1780   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_USE_DEVICE_PTR)->base.public_flag)
1781
1782 #define OMP_CLAUSE_PROC_BIND_KIND(NODE) \
1783   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_PROC_BIND)->omp_clause.subcode.proc_bind_kind)
1784
1785 #define OMP_CLAUSE_DEVICE_TYPE_KIND(NODE) \
1786   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_DEVICE_TYPE)->omp_clause.subcode.device_type_kind)
1787
1788 /* True if there is a device clause with a device-modifier 'ancestor'.  */
1789 #define OMP_CLAUSE_DEVICE_ANCESTOR(NODE) \
1790   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_DEVICE)->base.public_flag)
1791
1792 #define OMP_CLAUSE_COLLAPSE_EXPR(NODE) \
1793   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_COLLAPSE), 0)
1794 #define OMP_CLAUSE_COLLAPSE_ITERVAR(NODE) \
1795   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_COLLAPSE), 1)
1796 #define OMP_CLAUSE_COLLAPSE_COUNT(NODE) \
1797   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_COLLAPSE), 2)
1798
1799 #define OMP_CLAUSE_ORDERED_EXPR(NODE) \
1800   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_ORDERED), 0)
1801
1802 /* True on an OMP_CLAUSE_ORDERED if stand-alone ordered construct is nested
1803    inside of work-sharing loop the clause is on.  */
1804 #define OMP_CLAUSE_ORDERED_DOACROSS(NODE) \
1805   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_ORDERED)->base.public_flag)
1806
1807 /* True for unconstrained modifier on order(concurrent) clause.  */
1808 #define OMP_CLAUSE_ORDER_UNCONSTRAINED(NODE) \
1809   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_ORDER)->base.public_flag)
1810 /* True for reproducible modifier on order(concurrent) clause.  */
1811 #define OMP_CLAUSE_ORDER_REPRODUCIBLE(NODE) \
1812   TREE_PROTECTED (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_ORDER))
1813
1814 #define OMP_CLAUSE_REDUCTION_CODE(NODE) \
1815   (OMP_CLAUSE_RANGE_CHECK (NODE, OMP_CLAUSE_REDUCTION, \
1816      OMP_CLAUSE_IN_REDUCTION)->omp_clause.subcode.reduction_code)
1817 #define OMP_CLAUSE_REDUCTION_INIT(NODE) \
1818   OMP_CLAUSE_OPERAND (OMP_CLAUSE_RANGE_CHECK (NODE, OMP_CLAUSE_REDUCTION, \
1819                                               OMP_CLAUSE_IN_REDUCTION), 1)
1820 #define OMP_CLAUSE_REDUCTION_MERGE(NODE) \
1821   OMP_CLAUSE_OPERAND (OMP_CLAUSE_RANGE_CHECK (NODE, OMP_CLAUSE_REDUCTION, \
1822                                               OMP_CLAUSE_IN_REDUCTION), 2)
1823 #define OMP_CLAUSE_REDUCTION_GIMPLE_INIT(NODE) \
1824   (OMP_CLAUSE_CHECK (NODE))->omp_clause.gimple_reduction_init
1825 #define OMP_CLAUSE_REDUCTION_GIMPLE_MERGE(NODE) \
1826   (OMP_CLAUSE_CHECK (NODE))->omp_clause.gimple_reduction_merge
1827 #define OMP_CLAUSE_REDUCTION_PLACEHOLDER(NODE) \
1828   OMP_CLAUSE_OPERAND (OMP_CLAUSE_RANGE_CHECK (NODE, OMP_CLAUSE_REDUCTION, \
1829                                               OMP_CLAUSE_IN_REDUCTION), 3)
1830 #define OMP_CLAUSE_REDUCTION_DECL_PLACEHOLDER(NODE) \
1831   OMP_CLAUSE_OPERAND (OMP_CLAUSE_RANGE_CHECK (NODE, OMP_CLAUSE_REDUCTION, \
1832                                               OMP_CLAUSE_IN_REDUCTION), 4)
1833
1834 /* True if a REDUCTION clause may reference the original list item (omp_orig)
1835    in its OMP_CLAUSE_REDUCTION_{,GIMPLE_}INIT.  */
1836 #define OMP_CLAUSE_REDUCTION_OMP_ORIG_REF(NODE) \
1837   (OMP_CLAUSE_RANGE_CHECK (NODE, OMP_CLAUSE_REDUCTION, \
1838                            OMP_CLAUSE_IN_REDUCTION)->base.public_flag)
1839
1840 /* True if a REDUCTION clause has task reduction-modifier.  */
1841 #define OMP_CLAUSE_REDUCTION_TASK(NODE) \
1842   TREE_PROTECTED (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_REDUCTION))
1843
1844 /* True if a REDUCTION clause has inscan reduction-modifier.  */
1845 #define OMP_CLAUSE_REDUCTION_INSCAN(NODE) \
1846   TREE_PRIVATE (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_REDUCTION))
1847
1848 /* True if a LINEAR clause doesn't need copy in.  True for iterator vars which
1849    are always initialized inside of the loop construct, false otherwise.  */
1850 #define OMP_CLAUSE_LINEAR_NO_COPYIN(NODE) \
1851   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_LINEAR)->base.public_flag)
1852
1853 /* True if a LINEAR clause doesn't need copy out.  True for iterator vars which
1854    are declared inside of the simd construct.  */
1855 #define OMP_CLAUSE_LINEAR_NO_COPYOUT(NODE) \
1856   TREE_PRIVATE (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_LINEAR))
1857
1858 /* True if a LINEAR clause has a stride that is variable.  */
1859 #define OMP_CLAUSE_LINEAR_VARIABLE_STRIDE(NODE) \
1860   TREE_PROTECTED (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_LINEAR))
1861
1862 /* True for a LINEAR clause with old style modifier syntax
1863    linear(modifier(list)) or linear(modifier(list):step).  */
1864 #define OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER(NODE) \
1865   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_LINEAR)->base.addressable_flag)
1866
1867 /* True if a LINEAR clause is for an array or allocatable variable that
1868    needs special handling by the frontend.  */
1869 #define OMP_CLAUSE_LINEAR_ARRAY(NODE) \
1870   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_LINEAR)->base.deprecated_flag)
1871
1872 #define OMP_CLAUSE_LINEAR_STEP(NODE) \
1873   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_LINEAR), 1)
1874
1875 #define OMP_CLAUSE_LINEAR_STMT(NODE) \
1876   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_LINEAR), 2)
1877
1878 #define OMP_CLAUSE_LINEAR_GIMPLE_SEQ(NODE) \
1879   (OMP_CLAUSE_CHECK (NODE))->omp_clause.gimple_reduction_init
1880
1881 #define OMP_CLAUSE_LINEAR_KIND(NODE) \
1882   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_LINEAR)->omp_clause.subcode.linear_kind)
1883
1884 #define OMP_CLAUSE_ALIGNED_ALIGNMENT(NODE) \
1885   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_ALIGNED), 1)
1886
1887 #define OMP_CLAUSE_ALLOCATE_ALLOCATOR(NODE) \
1888   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_ALLOCATE), 1)
1889
1890 #define OMP_CLAUSE_ALLOCATE_ALIGN(NODE) \
1891   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_ALLOCATE), 2)
1892
1893 /* True if an ALLOCATE clause was present on a combined or composite
1894    construct and the code for splitting the clauses has already performed
1895    checking if the listed variable has explicit privatization on the
1896    construct.  */
1897 #define OMP_CLAUSE_ALLOCATE_COMBINED(NODE) \
1898   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_ALLOCATE)->base.public_flag)
1899
1900 #define OMP_CLAUSE_NUM_TEAMS_UPPER_EXPR(NODE) \
1901   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_NUM_TEAMS), 0)
1902
1903 #define OMP_CLAUSE_NUM_TEAMS_LOWER_EXPR(NODE) \
1904   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_NUM_TEAMS), 1)
1905
1906 #define OMP_CLAUSE_THREAD_LIMIT_EXPR(NODE) \
1907   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, \
1908                                                 OMP_CLAUSE_THREAD_LIMIT), 0)
1909
1910 #define OMP_CLAUSE_DEVICE_ID(NODE) \
1911   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_DEVICE), 0)
1912
1913 #define OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR(NODE) \
1914   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, \
1915                                                 OMP_CLAUSE_DIST_SCHEDULE), 0)
1916
1917 #define OMP_CLAUSE_SAFELEN_EXPR(NODE) \
1918   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_SAFELEN), 0)
1919
1920 #define OMP_CLAUSE_SIMDLEN_EXPR(NODE) \
1921   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_SIMDLEN), 0)
1922
1923 #define OMP_CLAUSE__SIMDUID__DECL(NODE) \
1924   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE__SIMDUID_), 0)
1925
1926 #define OMP_CLAUSE_SCHEDULE_KIND(NODE) \
1927   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_SCHEDULE)->omp_clause.subcode.schedule_kind)
1928
1929 /* True if a SCHEDULE clause has the simd modifier on it.  */
1930 #define OMP_CLAUSE_SCHEDULE_SIMD(NODE) \
1931   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_SCHEDULE)->base.public_flag)
1932
1933 #define OMP_CLAUSE_DEFAULT_KIND(NODE) \
1934   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_DEFAULT)->omp_clause.subcode.default_kind)
1935
1936 #define OMP_CLAUSE_DEFAULTMAP_KIND(NODE) \
1937   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_DEFAULTMAP)->omp_clause.subcode.defaultmap_kind)
1938 #define OMP_CLAUSE_DEFAULTMAP_CATEGORY(NODE) \
1939   ((enum omp_clause_defaultmap_kind) \
1940    (OMP_CLAUSE_DEFAULTMAP_KIND (NODE) & OMP_CLAUSE_DEFAULTMAP_CATEGORY_MASK))
1941 #define OMP_CLAUSE_DEFAULTMAP_BEHAVIOR(NODE) \
1942   ((enum omp_clause_defaultmap_kind) \
1943    (OMP_CLAUSE_DEFAULTMAP_KIND (NODE) & OMP_CLAUSE_DEFAULTMAP_MASK))
1944 #define OMP_CLAUSE_DEFAULTMAP_SET_KIND(NODE, BEHAVIOR, CATEGORY) \
1945   (OMP_CLAUSE_DEFAULTMAP_KIND (NODE) \
1946    = (enum omp_clause_defaultmap_kind) (CATEGORY | BEHAVIOR))
1947
1948 #define OMP_CLAUSE_BIND_KIND(NODE) \
1949   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_BIND)->omp_clause.subcode.bind_kind)
1950
1951 /* True if ENTER clause is spelled as TO.  */
1952 #define OMP_CLAUSE_ENTER_TO(NODE) \
1953   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_ENTER)->base.public_flag)
1954
1955 #define OMP_CLAUSE_TILE_LIST(NODE) \
1956   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_TILE), 0)
1957 #define OMP_CLAUSE_TILE_ITERVAR(NODE) \
1958   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_TILE), 1)
1959 #define OMP_CLAUSE_TILE_COUNT(NODE) \
1960   OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_TILE), 2)
1961
1962 /* _CONDTEMP_ holding temporary with iteration count.  */
1963 #define OMP_CLAUSE__CONDTEMP__ITER(NODE) \
1964   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE__CONDTEMP_)->base.public_flag)
1965
1966 /* _SCANTEMP_ holding temporary with pointer to thread's local array;
1967    allocation.  */
1968 #define OMP_CLAUSE__SCANTEMP__ALLOC(NODE) \
1969   (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE__SCANTEMP_)->base.public_flag)
1970
1971 /* _SCANTEMP_ holding temporary with a control variable for deallocation;
1972    one boolean_type_node for test whether alloca was used, another one
1973    to pass to __builtin_stack_restore or free.  */
1974 #define OMP_CLAUSE__SCANTEMP__CONTROL(NODE) \
1975   TREE_PRIVATE (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE__SCANTEMP_))
1976
1977 /* SSA_NAME accessors.  */
1978
1979 /* Whether SSA_NAME NODE is a virtual operand.  This simply caches the
1980    information in the underlying SSA_NAME_VAR for efficiency.  */
1981 #define SSA_NAME_IS_VIRTUAL_OPERAND(NODE) \
1982   SSA_NAME_CHECK (NODE)->base.public_flag
1983
1984 /* Returns the IDENTIFIER_NODE giving the SSA name a name or NULL_TREE
1985    if there is no name associated with it.  */
1986 #define SSA_NAME_IDENTIFIER(NODE)                               \
1987   (SSA_NAME_CHECK (NODE)->ssa_name.var != NULL_TREE             \
1988    ? (TREE_CODE ((NODE)->ssa_name.var) == IDENTIFIER_NODE       \
1989       ? (NODE)->ssa_name.var                                    \
1990       : DECL_NAME ((NODE)->ssa_name.var))                       \
1991    : NULL_TREE)
1992
1993 /* Returns the variable being referenced.  This can be NULL_TREE for
1994    temporaries not associated with any user variable.
1995    Once released, this is the only field that can be relied upon.  */
1996 #define SSA_NAME_VAR(NODE)                                      \
1997   (SSA_NAME_CHECK (NODE)->ssa_name.var == NULL_TREE             \
1998    || TREE_CODE ((NODE)->ssa_name.var) == IDENTIFIER_NODE       \
1999    ? NULL_TREE : (NODE)->ssa_name.var)
2000
2001 #define SET_SSA_NAME_VAR_OR_IDENTIFIER(NODE,VAR) \
2002   do \
2003     { \
2004       tree var_ = (VAR); \
2005       SSA_NAME_CHECK (NODE)->ssa_name.var = var_; \
2006       SSA_NAME_IS_VIRTUAL_OPERAND (NODE) \
2007         = (var_ \
2008            && TREE_CODE (var_) == VAR_DECL \
2009            && VAR_DECL_IS_VIRTUAL_OPERAND (var_)); \
2010     } \
2011   while (0)
2012
2013 /* Returns the statement which defines this SSA name.  */
2014 #define SSA_NAME_DEF_STMT(NODE) SSA_NAME_CHECK (NODE)->ssa_name.def_stmt
2015
2016 /* Returns the SSA version number of this SSA name.  Note that in
2017    tree SSA, version numbers are not per variable and may be recycled.  */
2018 #define SSA_NAME_VERSION(NODE)  SSA_NAME_CHECK (NODE)->base.u.version
2019
2020 /* Nonzero if this SSA name occurs in an abnormal PHI.  SSA_NAMES are
2021    never output, so we can safely use the ASM_WRITTEN_FLAG for this
2022    status bit.  */
2023 #define SSA_NAME_OCCURS_IN_ABNORMAL_PHI(NODE) \
2024     SSA_NAME_CHECK (NODE)->base.asm_written_flag
2025
2026 /* Nonzero if this SSA_NAME expression is currently on the free list of
2027    SSA_NAMES.  Using NOTHROW_FLAG seems reasonably safe since throwing
2028    has no meaning for an SSA_NAME.  */
2029 #define SSA_NAME_IN_FREE_LIST(NODE) \
2030     SSA_NAME_CHECK (NODE)->base.nothrow_flag
2031
2032 /* Nonzero if this SSA_NAME is the default definition for the
2033    underlying symbol.  A default SSA name is created for symbol S if
2034    the very first reference to S in the function is a read operation.
2035    Default definitions are always created by an empty statement and
2036    belong to no basic block.  */
2037 #define SSA_NAME_IS_DEFAULT_DEF(NODE) \
2038     SSA_NAME_CHECK (NODE)->base.default_def_flag
2039
2040 /* Nonzero if this SSA_NAME is known to point to memory that may not
2041    be written to.  This is set for default defs of function parameters
2042    that have a corresponding r or R specification in the functions
2043    fn spec attribute.  This is used by alias analysis.  */
2044 #define SSA_NAME_POINTS_TO_READONLY_MEMORY(NODE) \
2045     SSA_NAME_CHECK (NODE)->base.deprecated_flag
2046
2047 /* Attributes for SSA_NAMEs for pointer-type variables.  */
2048 #define SSA_NAME_PTR_INFO(N) \
2049    SSA_NAME_CHECK (N)->ssa_name.info.ptr_info
2050
2051 /* Value range info attributes for SSA_NAMEs of non pointer-type variables.  */
2052 #define SSA_NAME_RANGE_INFO(N) \
2053     SSA_NAME_CHECK (N)->ssa_name.info.range_info
2054
2055 /* Return the immediate_use information for an SSA_NAME. */
2056 #define SSA_NAME_IMM_USE_NODE(NODE) SSA_NAME_CHECK (NODE)->ssa_name.imm_uses
2057
2058 #define OMP_CLAUSE_CODE(NODE)                                   \
2059         (OMP_CLAUSE_CHECK (NODE))->omp_clause.code
2060
2061 #define OMP_CLAUSE_SET_CODE(NODE, CODE)                         \
2062         ((OMP_CLAUSE_CHECK (NODE))->omp_clause.code = (CODE))
2063
2064 #define OMP_CLAUSE_OPERAND(NODE, I)                             \
2065         OMP_CLAUSE_ELT_CHECK (NODE, I)
2066
2067 /* In a BLOCK (scope) node:
2068    Variables declared in the scope NODE.  */
2069 #define BLOCK_VARS(NODE) (BLOCK_CHECK (NODE)->block.vars)
2070 #define BLOCK_NONLOCALIZED_VARS(NODE) \
2071   (BLOCK_CHECK (NODE)->block.nonlocalized_vars)
2072 #define BLOCK_NUM_NONLOCALIZED_VARS(NODE) \
2073   vec_safe_length (BLOCK_NONLOCALIZED_VARS (NODE))
2074 #define BLOCK_NONLOCALIZED_VAR(NODE,N) (*BLOCK_NONLOCALIZED_VARS (NODE))[N]
2075 /* A chain of BLOCKs (scopes) nested within the scope NODE.  */
2076 #define BLOCK_SUBBLOCKS(NODE) (BLOCK_CHECK (NODE)->block.subblocks)
2077 /* The scope enclosing the scope NODE, or FUNCTION_DECL for the "outermost"
2078    function scope.  Inlined functions are chained by this so that given
2079    expression E and its TREE_BLOCK(E) B, BLOCK_SUPERCONTEXT(B) is the scope
2080    in which E has been made or into which E has been inlined.   */
2081 #define BLOCK_SUPERCONTEXT(NODE) (BLOCK_CHECK (NODE)->block.supercontext)
2082 /* Points to the next scope at the same level of nesting as scope NODE.  */
2083 #define BLOCK_CHAIN(NODE) (BLOCK_CHECK (NODE)->block.chain)
2084 /* A BLOCK, or FUNCTION_DECL of the function from which a block has been
2085    inlined.  In a scope immediately enclosing an inlined leaf expression,
2086    points to the outermost scope into which it has been inlined (thus
2087    bypassing all intermediate BLOCK_SUPERCONTEXTs). */
2088 #define BLOCK_ABSTRACT_ORIGIN(NODE) (BLOCK_CHECK (NODE)->block.abstract_origin)
2089 #define BLOCK_ORIGIN(NODE) \
2090   (BLOCK_ABSTRACT_ORIGIN(NODE) ? BLOCK_ABSTRACT_ORIGIN(NODE) : (NODE))
2091 #define BLOCK_DIE(NODE) (BLOCK_CHECK (NODE)->block.die)
2092
2093 /* True if BLOCK has the same ranges as its BLOCK_SUPERCONTEXT.  */
2094 #define BLOCK_SAME_RANGE(NODE) (BLOCK_CHECK (NODE)->base.u.bits.nameless_flag)
2095
2096 /* True if BLOCK appears in cold section.  */
2097 #define BLOCK_IN_COLD_SECTION_P(NODE) \
2098   (BLOCK_CHECK (NODE)->base.u.bits.atomic_flag)
2099
2100 /* An index number for this block.  These values are not guaranteed to
2101    be unique across functions -- whether or not they are depends on
2102    the debugging output format in use.  */
2103 #define BLOCK_NUMBER(NODE) (BLOCK_CHECK (NODE)->block.block_num)
2104
2105 /* If block reordering splits a lexical block into discontiguous
2106    address ranges, we'll make a copy of the original block.
2107
2108    Note that this is logically distinct from BLOCK_ABSTRACT_ORIGIN.
2109    In that case, we have one source block that has been replicated
2110    (through inlining or unrolling) into many logical blocks, and that
2111    these logical blocks have different physical variables in them.
2112
2113    In this case, we have one logical block split into several
2114    non-contiguous address ranges.  Most debug formats can't actually
2115    represent this idea directly, so we fake it by creating multiple
2116    logical blocks with the same variables in them.  However, for those
2117    that do support non-contiguous regions, these allow the original
2118    logical block to be reconstructed, along with the set of address
2119    ranges.
2120
2121    One of the logical block fragments is arbitrarily chosen to be
2122    the ORIGIN.  The other fragments will point to the origin via
2123    BLOCK_FRAGMENT_ORIGIN; the origin itself will have this pointer
2124    be null.  The list of fragments will be chained through
2125    BLOCK_FRAGMENT_CHAIN from the origin.  */
2126
2127 #define BLOCK_FRAGMENT_ORIGIN(NODE) (BLOCK_CHECK (NODE)->block.fragment_origin)
2128 #define BLOCK_FRAGMENT_CHAIN(NODE) (BLOCK_CHECK (NODE)->block.fragment_chain)
2129
2130 /* For an inlined function, this gives the location where it was called
2131    from.  This is only set in the top level block, which corresponds to the
2132    inlined function scope.  This is used in the debug output routines.  */
2133
2134 #define BLOCK_SOURCE_LOCATION(NODE) (BLOCK_CHECK (NODE)->block.locus)
2135
2136 /* This gives the location of the end of the block, useful to attach
2137    code implicitly generated for outgoing paths.  */
2138
2139 #define BLOCK_SOURCE_END_LOCATION(NODE) (BLOCK_CHECK (NODE)->block.end_locus)
2140
2141 /* Define fields and accessors for nodes representing data types.  */
2142
2143 /* See tree.def for documentation of the use of these fields.
2144    Look at the documentation of the various ..._TYPE tree codes.
2145
2146    Note that the type.values, type.minval, and type.maxval fields are
2147    overloaded and used for different macros in different kinds of types.
2148    Each macro must check to ensure the tree node is of the proper kind of
2149    type.  Note also that some of the front-ends also overload these fields,
2150    so they must be checked as well.  */
2151
2152 #define TYPE_UID(NODE) (TYPE_CHECK (NODE)->type_common.uid)
2153 /* Type size in bits as a tree expression.  Need not be constant and may
2154    be greater than TYPE_SIZE for a C++ FIELD_DECL representing a base
2155    class subobject with its own virtual base classes (which are laid out
2156    separately).  */
2157 #define TYPE_SIZE(NODE) (TYPE_CHECK (NODE)->type_common.size)
2158 /* Likewise, type size in bytes.  */
2159 #define TYPE_SIZE_UNIT(NODE) (TYPE_CHECK (NODE)->type_common.size_unit)
2160 #define TYPE_POINTER_TO(NODE) (TYPE_CHECK (NODE)->type_common.pointer_to)
2161 #define TYPE_REFERENCE_TO(NODE) (TYPE_CHECK (NODE)->type_common.reference_to)
2162 #define TYPE_PRECISION(NODE) (TYPE_CHECK (NODE)->type_common.precision)
2163 #define TYPE_NAME(NODE) (TYPE_CHECK (NODE)->type_common.name)
2164 #define TYPE_NEXT_VARIANT(NODE) (TYPE_CHECK (NODE)->type_common.next_variant)
2165 #define TYPE_MAIN_VARIANT(NODE) (TYPE_CHECK (NODE)->type_common.main_variant)
2166 #define TYPE_CONTEXT(NODE) (TYPE_CHECK (NODE)->type_common.context)
2167
2168 #define TYPE_MODE_RAW(NODE) (TYPE_CHECK (NODE)->type_common.mode)
2169 #define TYPE_MODE(NODE) \
2170   (VECTOR_TYPE_P (TYPE_CHECK (NODE)) \
2171    ? vector_type_mode (NODE) : (NODE)->type_common.mode)
2172 #define SCALAR_TYPE_MODE(NODE) \
2173   (as_a <scalar_mode> (TYPE_CHECK (NODE)->type_common.mode))
2174 #define SCALAR_INT_TYPE_MODE(NODE) \
2175   (as_a <scalar_int_mode> (TYPE_CHECK (NODE)->type_common.mode))
2176 #define SCALAR_FLOAT_TYPE_MODE(NODE) \
2177   (as_a <scalar_float_mode> (TYPE_CHECK (NODE)->type_common.mode))
2178 #define SET_TYPE_MODE(NODE, MODE) \
2179   (TYPE_CHECK (NODE)->type_common.mode = (MODE))
2180
2181 extern machine_mode element_mode (const_tree);
2182 extern machine_mode vector_type_mode (const_tree);
2183 extern unsigned int vector_element_bits (const_tree);
2184 extern tree vector_element_bits_tree (const_tree);
2185
2186 /* The "canonical" type for this type node, which is used by frontends to
2187    compare the type for equality with another type.  If two types are
2188    equal (based on the semantics of the language), then they will have
2189    equivalent TYPE_CANONICAL entries.
2190
2191    As a special case, if TYPE_CANONICAL is NULL_TREE, and thus
2192    TYPE_STRUCTURAL_EQUALITY_P is true, then it cannot
2193    be used for comparison against other types.  Instead, the type is
2194    said to require structural equality checks, described in
2195    TYPE_STRUCTURAL_EQUALITY_P.
2196
2197    For unqualified aggregate and function types the middle-end relies on
2198    TYPE_CANONICAL to tell whether two variables can be assigned
2199    to each other without a conversion.  The middle-end also makes sure
2200    to assign the same alias-sets to the type partition with equal
2201    TYPE_CANONICAL of their unqualified variants.  */
2202 #define TYPE_CANONICAL(NODE) (TYPE_CHECK (NODE)->type_common.canonical)
2203 /* Indicates that the type node requires structural equality
2204    checks.  The compiler will need to look at the composition of the
2205    type to determine whether it is equal to another type, rather than
2206    just comparing canonical type pointers.  For instance, we would need
2207    to look at the return and parameter types of a FUNCTION_TYPE
2208    node.  */
2209 #define TYPE_STRUCTURAL_EQUALITY_P(NODE) (TYPE_CANONICAL (NODE) == NULL_TREE)
2210 /* Sets the TYPE_CANONICAL field to NULL_TREE, indicating that the
2211    type node requires structural equality.  */
2212 #define SET_TYPE_STRUCTURAL_EQUALITY(NODE) (TYPE_CANONICAL (NODE) = NULL_TREE)
2213
2214 #define TYPE_IBIT(NODE) (GET_MODE_IBIT (TYPE_MODE (NODE)))
2215 #define TYPE_FBIT(NODE) (GET_MODE_FBIT (TYPE_MODE (NODE)))
2216
2217 /* The (language-specific) typed-based alias set for this type.
2218    Objects whose TYPE_ALIAS_SETs are different cannot alias each
2219    other.  If the TYPE_ALIAS_SET is -1, no alias set has yet been
2220    assigned to this type.  If the TYPE_ALIAS_SET is 0, objects of this
2221    type can alias objects of any type.  */
2222 #define TYPE_ALIAS_SET(NODE) (TYPE_CHECK (NODE)->type_common.alias_set)
2223
2224 /* Nonzero iff the typed-based alias set for this type has been
2225    calculated.  */
2226 #define TYPE_ALIAS_SET_KNOWN_P(NODE) \
2227   (TYPE_CHECK (NODE)->type_common.alias_set != -1)
2228
2229 /* A TREE_LIST of IDENTIFIER nodes of the attributes that apply
2230    to this type.  */
2231 #define TYPE_ATTRIBUTES(NODE) (TYPE_CHECK (NODE)->type_common.attributes)
2232
2233 /* Raw access to the alignment field.  */
2234 #define TYPE_ALIGN_RAW(NODE)                    \
2235   (TYPE_CHECK (NODE)->type_common.align)
2236
2237 /* The alignment necessary for objects of this type.
2238    The value is an int, measured in bits and must be a power of two.
2239    We support also an "alignment" of zero.  */
2240 #define TYPE_ALIGN(NODE)                                        \
2241   (TYPE_ALIGN_RAW (NODE)                                        \
2242    ? ((unsigned)1) << (TYPE_ALIGN_RAW(NODE) - 1) : 0)
2243
2244 /* Specify that TYPE_ALIGN(NODE) is X.  */
2245 #define SET_TYPE_ALIGN(NODE, X) \
2246     (TYPE_CHECK (NODE)->type_common.align = ffs_hwi (X))
2247
2248 /* 1 if the alignment for this type was requested by "aligned" attribute,
2249    0 if it is the default for this type.  */
2250 #define TYPE_USER_ALIGN(NODE) (TYPE_CHECK (NODE)->base.u.bits.user_align)
2251
2252 /* The alignment for NODE, in bytes.  */
2253 #define TYPE_ALIGN_UNIT(NODE) (TYPE_ALIGN (NODE) / BITS_PER_UNIT)
2254
2255 /* The minimum alignment necessary for objects of this type without
2256    warning.  The value is an int, measured in bits.  */
2257 #define TYPE_WARN_IF_NOT_ALIGN(NODE) \
2258     (TYPE_CHECK (NODE)->type_common.warn_if_not_align \
2259      ? ((unsigned)1) << ((NODE)->type_common.warn_if_not_align - 1) : 0)
2260
2261 /* Specify that TYPE_WARN_IF_NOT_ALIGN(NODE) is X.  */
2262 #define SET_TYPE_WARN_IF_NOT_ALIGN(NODE, X) \
2263     (TYPE_CHECK (NODE)->type_common.warn_if_not_align = ffs_hwi (X))
2264
2265 /* If your language allows you to declare types, and you want debug info
2266    for them, then you need to generate corresponding TYPE_DECL nodes.
2267    These "stub" TYPE_DECL nodes have no name, and simply point at the
2268    type node.  You then set the TYPE_STUB_DECL field of the type node
2269    to point back at the TYPE_DECL node.  This allows the debug routines
2270    to know that the two nodes represent the same type, so that we only
2271    get one debug info record for them.  */
2272 #define TYPE_STUB_DECL(NODE) (TREE_CHAIN (TYPE_CHECK (NODE)))
2273
2274 /* In a RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE or ARRAY_TYPE, it means
2275    the type has BLKmode only because it lacks the alignment required for
2276    its size.  */
2277 #define TYPE_NO_FORCE_BLK(NODE) \
2278   (TYPE_CHECK (NODE)->type_common.no_force_blk_flag)
2279
2280 /* Nonzero in a type considered volatile as a whole.  */
2281 #define TYPE_VOLATILE(NODE) (TYPE_CHECK (NODE)->base.volatile_flag)
2282
2283 /* Nonzero in a type considered atomic as a whole.  */
2284 #define TYPE_ATOMIC(NODE) (TYPE_CHECK (NODE)->base.u.bits.atomic_flag)
2285
2286 /* Means this type is const-qualified.  */
2287 #define TYPE_READONLY(NODE) (TYPE_CHECK (NODE)->base.readonly_flag)
2288
2289 /* If nonzero, this type is `restrict'-qualified, in the C sense of
2290    the term.  */
2291 #define TYPE_RESTRICT(NODE) (TYPE_CHECK (NODE)->type_common.restrict_flag)
2292
2293 /* If nonzero, type's name shouldn't be emitted into debug info.  */
2294 #define TYPE_NAMELESS(NODE) (TYPE_CHECK (NODE)->base.u.bits.nameless_flag)
2295
2296 /* The address space the type is in.  */
2297 #define TYPE_ADDR_SPACE(NODE) (TYPE_CHECK (NODE)->base.u.bits.address_space)
2298
2299 /* Encode/decode the named memory support as part of the qualifier.  If more
2300    than 8 qualifiers are added, these macros need to be adjusted.  */
2301 #define ENCODE_QUAL_ADDR_SPACE(NUM) ((NUM & 0xFF) << 8)
2302 #define DECODE_QUAL_ADDR_SPACE(X) (((X) >> 8) & 0xFF)
2303
2304 /* Return all qualifiers except for the address space qualifiers.  */
2305 #define CLEAR_QUAL_ADDR_SPACE(X) ((X) & ~0xFF00)
2306
2307 /* Only keep the address space out of the qualifiers and discard the other
2308    qualifiers.  */
2309 #define KEEP_QUAL_ADDR_SPACE(X) ((X) & 0xFF00)
2310
2311 /* The set of type qualifiers for this type.  */
2312 #define TYPE_QUALS(NODE)                                        \
2313   ((int) ((TYPE_READONLY (NODE) * TYPE_QUAL_CONST)              \
2314           | (TYPE_VOLATILE (NODE) * TYPE_QUAL_VOLATILE)         \
2315           | (TYPE_ATOMIC (NODE) * TYPE_QUAL_ATOMIC)             \
2316           | (TYPE_RESTRICT (NODE) * TYPE_QUAL_RESTRICT)         \
2317           | (ENCODE_QUAL_ADDR_SPACE (TYPE_ADDR_SPACE (NODE)))))
2318
2319 /* The same as TYPE_QUALS without the address space qualifications.  */
2320 #define TYPE_QUALS_NO_ADDR_SPACE(NODE)                          \
2321   ((int) ((TYPE_READONLY (NODE) * TYPE_QUAL_CONST)              \
2322           | (TYPE_VOLATILE (NODE) * TYPE_QUAL_VOLATILE)         \
2323           | (TYPE_ATOMIC (NODE) * TYPE_QUAL_ATOMIC)             \
2324           | (TYPE_RESTRICT (NODE) * TYPE_QUAL_RESTRICT)))
2325
2326 /* The same as TYPE_QUALS without the address space and atomic 
2327    qualifications.  */
2328 #define TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC(NODE)                \
2329   ((int) ((TYPE_READONLY (NODE) * TYPE_QUAL_CONST)              \
2330           | (TYPE_VOLATILE (NODE) * TYPE_QUAL_VOLATILE)         \
2331           | (TYPE_RESTRICT (NODE) * TYPE_QUAL_RESTRICT)))
2332
2333 /* These flags are available for each language front end to use internally.  */
2334 #define TYPE_LANG_FLAG_0(NODE) (TYPE_CHECK (NODE)->type_common.lang_flag_0)
2335 #define TYPE_LANG_FLAG_1(NODE) (TYPE_CHECK (NODE)->type_common.lang_flag_1)
2336 #define TYPE_LANG_FLAG_2(NODE) (TYPE_CHECK (NODE)->type_common.lang_flag_2)
2337 #define TYPE_LANG_FLAG_3(NODE) (TYPE_CHECK (NODE)->type_common.lang_flag_3)
2338 #define TYPE_LANG_FLAG_4(NODE) (TYPE_CHECK (NODE)->type_common.lang_flag_4)
2339 #define TYPE_LANG_FLAG_5(NODE) (TYPE_CHECK (NODE)->type_common.lang_flag_5)
2340 #define TYPE_LANG_FLAG_6(NODE) (TYPE_CHECK (NODE)->type_common.lang_flag_6)
2341 #define TYPE_LANG_FLAG_7(NODE) (TYPE_CHECK (NODE)->type_common.lang_flag_7)
2342
2343 /* Used to keep track of visited nodes in tree traversals.  This is set to
2344    0 by copy_node and make_node.  */
2345 #define TREE_VISITED(NODE) ((NODE)->base.visited)
2346
2347 /* If set in an ARRAY_TYPE, indicates a string type (for languages
2348    that distinguish string from array of char).
2349    If set in a INTEGER_TYPE, indicates a character type.  */
2350 #define TYPE_STRING_FLAG(NODE) \
2351         (ARRAY_OR_INTEGER_TYPE_CHECK (NODE)->type_common.string_flag)
2352
2353 /* If set for RECORD_TYPE or UNION_TYPE it indicates that the type conforms
2354    to the C++ one definition rule.  This is used for LTO canonical type
2355    computation.  */
2356 #define TYPE_CXX_ODR_P(NODE) \
2357         (RECORD_OR_UNION_CHECK (NODE)->type_common.string_flag)
2358
2359 /* Nonzero in a VECTOR_TYPE if the frontends should not emit warnings
2360    about missing conversions to other vector types of the same size.  */
2361 #define TYPE_VECTOR_OPAQUE(NODE) \
2362   (VECTOR_TYPE_CHECK (NODE)->base.default_def_flag)
2363
2364 /* Indicates that objects of this type must be initialized by calling a
2365    function when they are created.  */
2366 #define TYPE_NEEDS_CONSTRUCTING(NODE) \
2367   (TYPE_CHECK (NODE)->type_common.needs_constructing_flag)
2368
2369 /* Indicates that a UNION_TYPE object should be passed the same way that
2370    the first union alternative would be passed, or that a RECORD_TYPE
2371    object should be passed the same way that the first (and only) member
2372    would be passed.  */
2373 #define TYPE_TRANSPARENT_AGGR(NODE) \
2374   (RECORD_OR_UNION_CHECK (NODE)->type_common.transparent_aggr_flag)
2375
2376 /* For an ARRAY_TYPE, indicates that it is not permitted to take the
2377    address of a component of the type.  This is the counterpart of
2378    DECL_NONADDRESSABLE_P for arrays, see the definition of this flag.  */
2379 #define TYPE_NONALIASED_COMPONENT(NODE) \
2380   (ARRAY_TYPE_CHECK (NODE)->type_common.transparent_aggr_flag)
2381
2382 /* For an ARRAY_TYPE, a RECORD_TYPE, a UNION_TYPE or a QUAL_UNION_TYPE
2383    whether the array is typeless storage or the type contains a member
2384    with this flag set.  Such types are exempt from type-based alias
2385    analysis.  For ARRAY_TYPEs with AGGREGATE_TYPE_P element types
2386    the flag should be inherited from the element type, can change
2387    when type is finalized and because of that should not be used in
2388    type hashing.  For ARRAY_TYPEs with non-AGGREGATE_TYPE_P element types
2389    the flag should not be changed after the array is created and should
2390    be used in type hashing.  */
2391 #define TYPE_TYPELESS_STORAGE(NODE) \
2392   (TREE_CHECK4 (NODE, RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE, \
2393                 ARRAY_TYPE)->type_common.typeless_storage)
2394
2395 /* Indicated that objects of this type should be laid out in as
2396    compact a way as possible.  */
2397 #define TYPE_PACKED(NODE) (TYPE_CHECK (NODE)->base.u.bits.packed_flag)
2398
2399 /* Used by type_contains_placeholder_p to avoid recomputation.
2400    Values are: 0 (unknown), 1 (false), 2 (true).  Never access
2401    this field directly.  */
2402 #define TYPE_CONTAINS_PLACEHOLDER_INTERNAL(NODE) \
2403   (TYPE_CHECK (NODE)->type_common.contains_placeholder_bits)
2404
2405 /* Nonzero if RECORD_TYPE represents a final derivation of class.  */
2406 #define TYPE_FINAL_P(NODE) \
2407   (RECORD_OR_UNION_CHECK (NODE)->base.default_def_flag)
2408
2409 /* The debug output functions use the symtab union field to store
2410    information specific to the debugging format.  The different debug
2411    output hooks store different types in the union field.  These three
2412    macros are used to access different fields in the union.  The debug
2413    hooks are responsible for consistently using only a specific
2414    macro.  */
2415
2416 /* Symtab field as an integer.  Used by stabs generator in dbxout.cc to
2417    hold the type's number in the generated stabs.  */
2418 #define TYPE_SYMTAB_ADDRESS(NODE) \
2419   (TYPE_CHECK (NODE)->type_common.symtab.address)
2420
2421 /* Symtab field as a pointer to a DWARF DIE.  Used by DWARF generator
2422    in dwarf2out.cc to point to the DIE generated for the type.  */
2423 #define TYPE_SYMTAB_DIE(NODE) \
2424   (TYPE_CHECK (NODE)->type_common.symtab.die)
2425
2426 /* The garbage collector needs to know the interpretation of the
2427    symtab field.  These constants represent the different types in the
2428    union.  */
2429
2430 #define TYPE_SYMTAB_IS_ADDRESS (0)
2431 #define TYPE_SYMTAB_IS_DIE (1)
2432
2433 #define TYPE_LANG_SPECIFIC(NODE) \
2434   (TYPE_CHECK (NODE)->type_with_lang_specific.lang_specific)
2435
2436 #define TYPE_VALUES(NODE) (ENUMERAL_TYPE_CHECK (NODE)->type_non_common.values)
2437 #define TYPE_DOMAIN(NODE) (ARRAY_TYPE_CHECK (NODE)->type_non_common.values)
2438 #define TYPE_FIELDS(NODE)                               \
2439   (RECORD_OR_UNION_CHECK (NODE)->type_non_common.values)
2440 #define TYPE_CACHED_VALUES(NODE) (TYPE_CHECK (NODE)->type_non_common.values)
2441 #define TYPE_ARG_TYPES(NODE)                            \
2442   (FUNC_OR_METHOD_CHECK (NODE)->type_non_common.values)
2443 #define TYPE_VALUES_RAW(NODE) (TYPE_CHECK (NODE)->type_non_common.values)
2444
2445 #define TYPE_MIN_VALUE(NODE)                            \
2446   (NUMERICAL_TYPE_CHECK (NODE)->type_non_common.minval)
2447 #define TYPE_NEXT_PTR_TO(NODE)                          \
2448   (POINTER_TYPE_CHECK (NODE)->type_non_common.minval)
2449 #define TYPE_NEXT_REF_TO(NODE)                          \
2450   (REFERENCE_TYPE_CHECK (NODE)->type_non_common.minval)
2451 #define TYPE_VFIELD(NODE)                               \
2452   (RECORD_OR_UNION_CHECK (NODE)->type_non_common.minval)
2453 #define TYPE_MIN_VALUE_RAW(NODE) (TYPE_CHECK (NODE)->type_non_common.minval)
2454
2455 #define TYPE_MAX_VALUE(NODE) \
2456   (NUMERICAL_TYPE_CHECK (NODE)->type_non_common.maxval)
2457 #define TYPE_METHOD_BASETYPE(NODE)                      \
2458   (FUNC_OR_METHOD_CHECK (NODE)->type_non_common.maxval)
2459 #define TYPE_OFFSET_BASETYPE(NODE)                      \
2460   (OFFSET_TYPE_CHECK (NODE)->type_non_common.maxval)
2461 /* If non-NULL, this is an upper bound of the size (in bytes) of an
2462    object of the given ARRAY_TYPE_NON_COMMON.  This allows temporaries to be
2463    allocated.  */
2464 #define TYPE_ARRAY_MAX_SIZE(ARRAY_TYPE) \
2465   (ARRAY_TYPE_CHECK (ARRAY_TYPE)->type_non_common.maxval)
2466 #define TYPE_MAX_VALUE_RAW(NODE) (TYPE_CHECK (NODE)->type_non_common.maxval)
2467 /* For record and union types, information about this type, as a base type
2468    for itself.  */
2469 #define TYPE_BINFO(NODE) (RECORD_OR_UNION_CHECK (NODE)->type_non_common.maxval)
2470
2471 /* For types, used in a language-dependent way.  */
2472 #define TYPE_LANG_SLOT_1(NODE) \
2473   (TYPE_CHECK (NODE)->type_non_common.lang_1)
2474
2475 /* Define accessor macros for information about type inheritance
2476    and basetypes.
2477
2478    A "basetype" means a particular usage of a data type for inheritance
2479    in another type.  Each such basetype usage has its own "binfo"
2480    object to describe it.  The binfo object is a TREE_VEC node.
2481
2482    Inheritance is represented by the binfo nodes allocated for a
2483    given type.  For example, given types C and D, such that D is
2484    inherited by C, 3 binfo nodes will be allocated: one for describing
2485    the binfo properties of C, similarly one for D, and one for
2486    describing the binfo properties of D as a base type for C.
2487    Thus, given a pointer to class C, one can get a pointer to the binfo
2488    of D acting as a basetype for C by looking at C's binfo's basetypes.  */
2489
2490 /* BINFO specific flags.  */
2491
2492 /* Nonzero means that the derivation chain is via a `virtual' declaration.  */
2493 #define BINFO_VIRTUAL_P(NODE) (TREE_BINFO_CHECK (NODE)->base.static_flag)
2494
2495 /* Flags for language dependent use.  */
2496 #define BINFO_FLAG_0(NODE) TREE_LANG_FLAG_0 (TREE_BINFO_CHECK (NODE))
2497 #define BINFO_FLAG_1(NODE) TREE_LANG_FLAG_1 (TREE_BINFO_CHECK (NODE))
2498 #define BINFO_FLAG_2(NODE) TREE_LANG_FLAG_2 (TREE_BINFO_CHECK (NODE))
2499 #define BINFO_FLAG_3(NODE) TREE_LANG_FLAG_3 (TREE_BINFO_CHECK (NODE))
2500 #define BINFO_FLAG_4(NODE) TREE_LANG_FLAG_4 (TREE_BINFO_CHECK (NODE))
2501 #define BINFO_FLAG_5(NODE) TREE_LANG_FLAG_5 (TREE_BINFO_CHECK (NODE))
2502 #define BINFO_FLAG_6(NODE) TREE_LANG_FLAG_6 (TREE_BINFO_CHECK (NODE))
2503
2504 /* The actual data type node being inherited in this basetype.  */
2505 #define BINFO_TYPE(NODE) TREE_TYPE (TREE_BINFO_CHECK (NODE))
2506
2507 /* The offset where this basetype appears in its containing type.
2508    BINFO_OFFSET slot holds the offset (in bytes)
2509    from the base of the complete object to the base of the part of the
2510    object that is allocated on behalf of this `type'.
2511    This is always 0 except when there is multiple inheritance.  */
2512
2513 #define BINFO_OFFSET(NODE) (TREE_BINFO_CHECK (NODE)->binfo.offset)
2514 #define BINFO_OFFSET_ZEROP(NODE) (integer_zerop (BINFO_OFFSET (NODE)))
2515
2516 /* The virtual function table belonging to this basetype.  Virtual
2517    function tables provide a mechanism for run-time method dispatching.
2518    The entries of a virtual function table are language-dependent.  */
2519
2520 #define BINFO_VTABLE(NODE) (TREE_BINFO_CHECK (NODE)->binfo.vtable)
2521
2522 /* The virtual functions in the virtual function table.  This is
2523    a TREE_LIST that is used as an initial approximation for building
2524    a virtual function table for this basetype.  */
2525 #define BINFO_VIRTUALS(NODE) (TREE_BINFO_CHECK (NODE)->binfo.virtuals)
2526
2527 /* A vector of binfos for the direct basetypes inherited by this
2528    basetype.
2529
2530    If this basetype describes type D as inherited in C, and if the
2531    basetypes of D are E and F, then this vector contains binfos for
2532    inheritance of E and F by C.  */
2533 #define BINFO_BASE_BINFOS(NODE) (&TREE_BINFO_CHECK (NODE)->binfo.base_binfos)
2534
2535 /* The number of basetypes for NODE.  */
2536 #define BINFO_N_BASE_BINFOS(NODE) (BINFO_BASE_BINFOS (NODE)->length ())
2537
2538 /* Accessor macro to get to the Nth base binfo of this binfo.  */
2539 #define BINFO_BASE_BINFO(NODE,N) \
2540  ((*BINFO_BASE_BINFOS (NODE))[(N)])
2541 #define BINFO_BASE_ITERATE(NODE,N,B) \
2542  (BINFO_BASE_BINFOS (NODE)->iterate ((N), &(B)))
2543 #define BINFO_BASE_APPEND(NODE,T) \
2544  (BINFO_BASE_BINFOS (NODE)->quick_push ((T)))
2545
2546 /* For a BINFO record describing a virtual base class, i.e., one where
2547    TREE_VIA_VIRTUAL is set, this field assists in locating the virtual
2548    base.  The actual contents are language-dependent.  In the C++
2549    front-end this field is an INTEGER_CST giving an offset into the
2550    vtable where the offset to the virtual base can be found.  */
2551 #define BINFO_VPTR_FIELD(NODE) (TREE_BINFO_CHECK (NODE)->binfo.vptr_field)
2552
2553 /* Indicates the accesses this binfo has to its bases. The values are
2554    access_public_node, access_protected_node or access_private_node.
2555    If this array is not present, public access is implied.  */
2556 #define BINFO_BASE_ACCESSES(NODE) \
2557   (TREE_BINFO_CHECK (NODE)->binfo.base_accesses)
2558
2559 #define BINFO_BASE_ACCESS(NODE,N) \
2560   (*BINFO_BASE_ACCESSES (NODE))[(N)]
2561 #define BINFO_BASE_ACCESS_APPEND(NODE,T) \
2562   BINFO_BASE_ACCESSES (NODE)->quick_push ((T))
2563
2564 /* The index in the VTT where this subobject's sub-VTT can be found.
2565    NULL_TREE if there is no sub-VTT.  */
2566 #define BINFO_SUBVTT_INDEX(NODE) (TREE_BINFO_CHECK (NODE)->binfo.vtt_subvtt)
2567
2568 /* The index in the VTT where the vptr for this subobject can be
2569    found.  NULL_TREE if there is no secondary vptr in the VTT.  */
2570 #define BINFO_VPTR_INDEX(NODE) (TREE_BINFO_CHECK (NODE)->binfo.vtt_vptr)
2571
2572 /* The BINFO_INHERITANCE_CHAIN points at the binfo for the base
2573    inheriting this base for non-virtual bases. For virtual bases it
2574    points either to the binfo for which this is a primary binfo, or to
2575    the binfo of the most derived type.  */
2576 #define BINFO_INHERITANCE_CHAIN(NODE) \
2577         (TREE_BINFO_CHECK (NODE)->binfo.inheritance)
2578
2579
2580 /* Define fields and accessors for nodes representing declared names.  */
2581
2582 /* Nonzero if DECL represents an SSA name or a variable that can possibly
2583    have an associated SSA name.  */
2584 #define SSA_VAR_P(DECL)                                                 \
2585         (TREE_CODE (DECL) == VAR_DECL                                   \
2586          || TREE_CODE (DECL) == PARM_DECL                               \
2587          || TREE_CODE (DECL) == RESULT_DECL                             \
2588          || TREE_CODE (DECL) == SSA_NAME)
2589
2590
2591 #define DECL_CHAIN(NODE) (TREE_CHAIN (DECL_MINIMAL_CHECK (NODE)))
2592
2593 /* This is the name of the object as written by the user.
2594    It is an IDENTIFIER_NODE.  */
2595 #define DECL_NAME(NODE) (DECL_MINIMAL_CHECK (NODE)->decl_minimal.name)
2596
2597 /* The IDENTIFIER_NODE associated with the TYPE_NAME field.  */
2598 #define TYPE_IDENTIFIER(NODE) \
2599   (TYPE_NAME (NODE) && DECL_P (TYPE_NAME (NODE)) \
2600    ? DECL_NAME (TYPE_NAME (NODE)) : TYPE_NAME (NODE))
2601
2602 /* Every ..._DECL node gets a unique number.  */
2603 #define DECL_UID(NODE) (DECL_MINIMAL_CHECK (NODE)->decl_minimal.uid)
2604
2605 /* DEBUG_EXPR_DECLs get negative UID numbers, to catch erroneous
2606    uses.  */
2607 #define DEBUG_TEMP_UID(NODE) (-DECL_UID (TREE_CHECK ((NODE), DEBUG_EXPR_DECL)))
2608
2609 /* Every ..._DECL node gets a unique number that stays the same even
2610    when the decl is copied by the inliner once it is set.  */
2611 #define DECL_PT_UID(NODE) \
2612   (DECL_COMMON_CHECK (NODE)->decl_common.pt_uid == -1u \
2613    ? (NODE)->decl_minimal.uid : (NODE)->decl_common.pt_uid)
2614 /* Initialize the ..._DECL node pt-uid to the decls uid.  */
2615 #define SET_DECL_PT_UID(NODE, UID) \
2616   (DECL_COMMON_CHECK (NODE)->decl_common.pt_uid = (UID))
2617 /* Whether the ..._DECL node pt-uid has been initialized and thus needs to
2618    be preserved when copyin the decl.  */
2619 #define DECL_PT_UID_SET_P(NODE) \
2620   (DECL_COMMON_CHECK (NODE)->decl_common.pt_uid != -1u)
2621
2622 /* These two fields describe where in the source code the declaration
2623    was.  If the declaration appears in several places (as for a C
2624    function that is declared first and then defined later), this
2625    information should refer to the definition.  */
2626 #define DECL_SOURCE_LOCATION(NODE) \
2627   (DECL_MINIMAL_CHECK (NODE)->decl_minimal.locus)
2628 #define DECL_SOURCE_FILE(NODE) LOCATION_FILE (DECL_SOURCE_LOCATION (NODE))
2629 #define DECL_SOURCE_LINE(NODE) LOCATION_LINE (DECL_SOURCE_LOCATION (NODE))
2630 #define DECL_SOURCE_COLUMN(NODE) LOCATION_COLUMN (DECL_SOURCE_LOCATION (NODE))
2631 /* This decl was created by a front-end or back-end rather than by
2632    user code, and has not been explicitly declared by the user -- when
2633    that happens the source location is updated to the user's
2634    source.  This includes decls with no location (!).  */
2635 #define DECL_IS_UNDECLARED_BUILTIN(DECL) \
2636   (DECL_SOURCE_LOCATION (DECL) <= BUILTINS_LOCATION)
2637
2638 /*  For FIELD_DECLs, this is the RECORD_TYPE, UNION_TYPE, or
2639     QUAL_UNION_TYPE node that the field is a member of.  For VAR_DECL,
2640     PARM_DECL, FUNCTION_DECL, LABEL_DECL, RESULT_DECL, and CONST_DECL
2641     nodes, this points to either the FUNCTION_DECL for the containing
2642     function, the RECORD_TYPE or UNION_TYPE for the containing type, or
2643     NULL_TREE or a TRANSLATION_UNIT_DECL if the given decl has "file
2644     scope".  In particular, for VAR_DECLs which are virtual table pointers
2645     (they have DECL_VIRTUAL set), we use DECL_CONTEXT to determine the type
2646     they belong to.  */
2647 #define DECL_CONTEXT(NODE) (DECL_MINIMAL_CHECK (NODE)->decl_minimal.context)
2648 #define DECL_FIELD_CONTEXT(NODE) \
2649   (FIELD_DECL_CHECK (NODE)->decl_minimal.context)
2650
2651 /* If nonzero, decl's name shouldn't be emitted into debug info.  */
2652 #define DECL_NAMELESS(NODE) (DECL_MINIMAL_CHECK (NODE)->base.u.bits.nameless_flag)
2653
2654 /* For any sort of a ..._DECL node, this points to the original (abstract)
2655    decl node which this decl is an inlined/cloned instance of, or else it
2656    is NULL indicating that this decl is not an instance of some other decl.
2657
2658    The C front-end also uses this in a nested declaration of an inline
2659    function, to point back to the definition.  */
2660 #define DECL_ABSTRACT_ORIGIN(NODE) \
2661   (DECL_COMMON_CHECK (NODE)->decl_common.abstract_origin)
2662
2663 /* Like DECL_ABSTRACT_ORIGIN, but returns NODE if there's no abstract
2664    origin.  This is useful when setting the DECL_ABSTRACT_ORIGIN.  */
2665 #define DECL_ORIGIN(NODE) \
2666   (DECL_ABSTRACT_ORIGIN (NODE) ? DECL_ABSTRACT_ORIGIN (NODE) : (NODE))
2667
2668 /* Nonzero for any sort of ..._DECL node means this decl node represents an
2669    inline instance of some original (abstract) decl from an inline function;
2670    suppress any warnings about shadowing some other variable.  FUNCTION_DECL
2671    nodes can also have their abstract origin set to themselves.  */
2672 #define DECL_FROM_INLINE(NODE) \
2673   (DECL_ABSTRACT_ORIGIN (NODE) != NULL_TREE \
2674    && DECL_ABSTRACT_ORIGIN (NODE) != (NODE))
2675
2676 /* In a DECL this is the field where attributes are stored.  */
2677 #define DECL_ATTRIBUTES(NODE) \
2678   (DECL_COMMON_CHECK (NODE)->decl_common.attributes)
2679
2680 /* For a FUNCTION_DECL, holds the tree of BINDINGs.
2681    For a TRANSLATION_UNIT_DECL, holds the namespace's BLOCK.
2682    For a VAR_DECL, holds the initial value.
2683    For a PARM_DECL, used for DECL_ARG_TYPE--default
2684    values for parameters are encoded in the type of the function,
2685    not in the PARM_DECL slot.
2686    For a FIELD_DECL, this is used for enumeration values and the C
2687    frontend uses it for temporarily storing bitwidth of bitfields.
2688
2689    ??? Need to figure out some way to check this isn't a PARM_DECL.  */
2690 #define DECL_INITIAL(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.initial)
2691
2692 /* Holds the size of the datum, in bits, as a tree expression.
2693    Need not be constant and may be null.  May be less than TYPE_SIZE
2694    for a C++ FIELD_DECL representing a base class subobject with its
2695    own virtual base classes (which are laid out separately).  */
2696 #define DECL_SIZE(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.size)
2697 /* Likewise for the size in bytes.  */
2698 #define DECL_SIZE_UNIT(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.size_unit)
2699 #define DECL_ALIGN_RAW(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.align)
2700 /* Returns the alignment required for the datum, in bits.  It must
2701    be a power of two, but an "alignment" of zero is supported
2702    (e.g. as "uninitialized" sentinel).  */
2703 #define DECL_ALIGN(NODE)                                        \
2704   (DECL_ALIGN_RAW (NODE)                                        \
2705    ? ((unsigned)1) << (DECL_ALIGN_RAW (NODE) - 1) : 0)
2706 /* Specify that DECL_ALIGN(NODE) is X.  */
2707 #define SET_DECL_ALIGN(NODE, X) \
2708   (DECL_ALIGN_RAW (NODE) = ffs_hwi (X))
2709
2710 /* The minimum alignment necessary for the datum, in bits, without
2711    warning.  */
2712 #define DECL_WARN_IF_NOT_ALIGN_RAW(NODE)                        \
2713   (DECL_COMMON_CHECK (NODE)->decl_common.warn_if_not_align)
2714 #define DECL_WARN_IF_NOT_ALIGN(NODE)                                    \
2715   (DECL_WARN_IF_NOT_ALIGN_RAW (NODE)                                    \
2716    ? ((unsigned)1) << (DECL_WARN_IF_NOT_ALIGN_RAW (NODE) - 1) : 0)
2717
2718 /* Specify that DECL_WARN_IF_NOT_ALIGN(NODE) is X.  */
2719 #define SET_DECL_WARN_IF_NOT_ALIGN(NODE, X)             \
2720   (DECL_WARN_IF_NOT_ALIGN_RAW (NODE) = ffs_hwi (X))
2721
2722 /* The alignment of NODE, in bytes.  */
2723 #define DECL_ALIGN_UNIT(NODE) (DECL_ALIGN (NODE) / BITS_PER_UNIT)
2724 /* Set if the alignment of this DECL has been set by the user, for
2725    example with an 'aligned' attribute.  */
2726 #define DECL_USER_ALIGN(NODE) \
2727   (DECL_COMMON_CHECK (NODE)->base.u.bits.user_align)
2728 /* Holds the machine mode corresponding to the declaration of a variable or
2729    field.  Always equal to TYPE_MODE (TREE_TYPE (decl)) except for a
2730    FIELD_DECL.  */
2731 #define DECL_MODE(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.mode)
2732 #define SET_DECL_MODE(NODE, MODE) \
2733   (DECL_COMMON_CHECK (NODE)->decl_common.mode = (MODE))
2734
2735 /* For FUNCTION_DECL, if it is built-in, this identifies which built-in
2736    operation it is.  This is only intended for low-level accesses;
2737    normally DECL_FUNCTION_CODE, DECL_FE_FUNCTION_CODE or DECL_MD_FUNCTION
2738    should be used instead.  */
2739 #define DECL_UNCHECKED_FUNCTION_CODE(NODE) \
2740   (FUNCTION_DECL_CHECK (NODE)->function_decl.function_code)
2741
2742 /* Test if FCODE is a function code for an alloca operation.  */
2743 #define ALLOCA_FUNCTION_CODE_P(FCODE)                           \
2744   ((FCODE) == BUILT_IN_ALLOCA                                   \
2745    || (FCODE) == BUILT_IN_ALLOCA_WITH_ALIGN                     \
2746    || (FCODE) == BUILT_IN_ALLOCA_WITH_ALIGN_AND_MAX)
2747
2748 /* Generate case for an alloca operation.  */
2749 #define CASE_BUILT_IN_ALLOCA                    \
2750   case BUILT_IN_ALLOCA:                         \
2751   case BUILT_IN_ALLOCA_WITH_ALIGN:              \
2752   case BUILT_IN_ALLOCA_WITH_ALIGN_AND_MAX
2753
2754 #define DECL_FUNCTION_PERSONALITY(NODE) \
2755   (FUNCTION_DECL_CHECK (NODE)->function_decl.personality)
2756
2757 /* Nonzero for a given ..._DECL node means that the name of this node should
2758    be ignored for symbolic debug purposes.  For a TYPE_DECL, this means that
2759    the associated type should be ignored.  For a FUNCTION_DECL, the body of
2760    the function should also be ignored.  */
2761 #define DECL_IGNORED_P(NODE) \
2762   (DECL_COMMON_CHECK (NODE)->decl_common.ignored_flag)
2763
2764 /* Nonzero for a given ..._DECL node means that this node represents an
2765    "abstract instance" of the given declaration (e.g. in the original
2766    declaration of an inline function).  When generating symbolic debugging
2767    information, we mustn't try to generate any address information for nodes
2768    marked as "abstract instances" because we don't actually generate
2769    any code or allocate any data space for such instances.  */
2770 #define DECL_ABSTRACT_P(NODE) \
2771   (DECL_COMMON_CHECK (NODE)->decl_common.abstract_flag)
2772
2773 /* Language-specific decl information.  */
2774 #define DECL_LANG_SPECIFIC(NODE) \
2775   (DECL_COMMON_CHECK (NODE)->decl_common.lang_specific)
2776
2777 /* In a VAR_DECL or FUNCTION_DECL, nonzero means external reference:
2778    do not allocate storage, and refer to a definition elsewhere.  Note that
2779    this does not necessarily imply the entity represented by NODE
2780    has no program source-level definition in this translation unit.  For
2781    example, for a FUNCTION_DECL, DECL_SAVED_TREE may be non-NULL and
2782    DECL_EXTERNAL may be true simultaneously; that can be the case for
2783    a C99 "extern inline" function.  */
2784 #define DECL_EXTERNAL(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.decl_flag_1)
2785
2786 /* Nonzero in a ..._DECL means this variable is ref'd from a nested function.
2787    For VAR_DECL nodes, PARM_DECL nodes, and FUNCTION_DECL nodes.
2788
2789    For LABEL_DECL nodes, nonzero if nonlocal gotos to the label are permitted.
2790
2791    Also set in some languages for variables, etc., outside the normal
2792    lexical scope, such as class instance variables.  */
2793 #define DECL_NONLOCAL(NODE) \
2794   (DECL_COMMON_CHECK (NODE)->decl_common.nonlocal_flag)
2795
2796 /* Used in VAR_DECLs to indicate that the variable is a vtable.
2797    Used in FIELD_DECLs for vtable pointers.
2798    Used in FUNCTION_DECLs to indicate that the function is virtual.  */
2799 #define DECL_VIRTUAL_P(NODE) \
2800   (DECL_COMMON_CHECK (NODE)->decl_common.virtual_flag)
2801
2802 /* Used to indicate that this DECL represents a compiler-generated entity.  */
2803 #define DECL_ARTIFICIAL(NODE) \
2804   (DECL_COMMON_CHECK (NODE)->decl_common.artificial_flag)
2805
2806 /* Additional flags for language-specific uses.  */
2807 #define DECL_LANG_FLAG_0(NODE) \
2808   (DECL_COMMON_CHECK (NODE)->decl_common.lang_flag_0)
2809 #define DECL_LANG_FLAG_1(NODE) \
2810   (DECL_COMMON_CHECK (NODE)->decl_common.lang_flag_1)
2811 #define DECL_LANG_FLAG_2(NODE) \
2812   (DECL_COMMON_CHECK (NODE)->decl_common.lang_flag_2)
2813 #define DECL_LANG_FLAG_3(NODE) \
2814   (DECL_COMMON_CHECK (NODE)->decl_common.lang_flag_3)
2815 #define DECL_LANG_FLAG_4(NODE) \
2816   (DECL_COMMON_CHECK (NODE)->decl_common.lang_flag_4)
2817 #define DECL_LANG_FLAG_5(NODE) \
2818   (DECL_COMMON_CHECK (NODE)->decl_common.lang_flag_5)
2819 #define DECL_LANG_FLAG_6(NODE) \
2820   (DECL_COMMON_CHECK (NODE)->decl_common.lang_flag_6)
2821 #define DECL_LANG_FLAG_7(NODE) \
2822   (DECL_COMMON_CHECK (NODE)->decl_common.lang_flag_7)
2823 #define DECL_LANG_FLAG_8(NODE) \
2824   (DECL_COMMON_CHECK (NODE)->decl_common.lang_flag_8)
2825
2826 /* Nonzero for a scope which is equal to file scope.  */
2827 #define SCOPE_FILE_SCOPE_P(EXP) \
2828   (! (EXP) || TREE_CODE (EXP) == TRANSLATION_UNIT_DECL)
2829 /* Nonzero for a decl which is at file scope.  */
2830 #define DECL_FILE_SCOPE_P(EXP) SCOPE_FILE_SCOPE_P (DECL_CONTEXT (EXP))
2831 /* Nonzero for a type which is at file scope.  */
2832 #define TYPE_FILE_SCOPE_P(EXP) SCOPE_FILE_SCOPE_P (TYPE_CONTEXT (EXP))
2833
2834 /* Nonzero for a decl that is decorated using attribute used.
2835    This indicates to compiler tools that this decl needs to be preserved.  */
2836 #define DECL_PRESERVE_P(DECL) \
2837   DECL_COMMON_CHECK (DECL)->decl_common.preserve_flag
2838
2839 /* Nonzero for a decl that is decorated with the "noinit" attribute.
2840    decls with this attribute are placed into the ".noinit" section, so they are
2841    not initialized by the target's startup code.  */
2842 #define DECL_NOINIT_P(DECL)     \
2843   (DECL_P (DECL)                \
2844    && (lookup_attribute ("noinit", DECL_ATTRIBUTES (DECL)) != NULL_TREE))
2845
2846 /* Nonzero for a decl that is decorated with the "persistent" attribute.
2847    decls with this attribute are placed into the ".persistent" section, so they
2848    are not initialized by the target's startup code.  */
2849 #define DECL_PERSISTENT_P(DECL) \
2850   (DECL_P (DECL)                \
2851    && (lookup_attribute ("persistent", DECL_ATTRIBUTES (DECL)) != NULL_TREE))
2852
2853 /* For function local variables of COMPLEX and VECTOR types,
2854    indicates that the variable is not aliased, and that all
2855    modifications to the variable have been adjusted so that
2856    they are killing assignments.  Thus the variable may now
2857    be treated as a GIMPLE register, and use real instead of
2858    virtual ops in SSA form.  */
2859 #define DECL_NOT_GIMPLE_REG_P(DECL) \
2860   DECL_COMMON_CHECK (DECL)->decl_common.not_gimple_reg_flag
2861
2862 extern tree decl_value_expr_lookup (tree);
2863 extern void decl_value_expr_insert (tree, tree);
2864
2865 /* In a VAR_DECL or PARM_DECL, the location at which the value may be found,
2866    if transformations have made this more complicated than evaluating the
2867    decl itself.  */
2868 #define DECL_HAS_VALUE_EXPR_P(NODE) \
2869   (TREE_CHECK3 (NODE, VAR_DECL, PARM_DECL, RESULT_DECL) \
2870    ->decl_common.decl_flag_2)
2871 #define DECL_VALUE_EXPR(NODE) \
2872   (decl_value_expr_lookup (DECL_WRTL_CHECK (NODE)))
2873 #define SET_DECL_VALUE_EXPR(NODE, VAL) \
2874   (decl_value_expr_insert (DECL_WRTL_CHECK (NODE), VAL))
2875
2876 /* Holds the RTL expression for the value of a variable or function.
2877    This value can be evaluated lazily for functions, variables with
2878    static storage duration, and labels.  */
2879 #define DECL_RTL(NODE)                                  \
2880   (DECL_WRTL_CHECK (NODE)->decl_with_rtl.rtl            \
2881    ? (NODE)->decl_with_rtl.rtl                                  \
2882    : (make_decl_rtl (NODE), (NODE)->decl_with_rtl.rtl))
2883
2884 /* Set the DECL_RTL for NODE to RTL.  */
2885 #define SET_DECL_RTL(NODE, RTL) set_decl_rtl (NODE, RTL)
2886
2887 /* Returns nonzero if NODE is a tree node that can contain RTL.  */
2888 #define HAS_RTL_P(NODE) (CODE_CONTAINS_STRUCT (TREE_CODE (NODE), TS_DECL_WRTL))
2889
2890 /* Returns nonzero if the DECL_RTL for NODE has already been set.  */
2891 #define DECL_RTL_SET_P(NODE) \
2892   (HAS_RTL_P (NODE) && DECL_WRTL_CHECK (NODE)->decl_with_rtl.rtl != NULL)
2893
2894 /* Copy the RTL from SRC_DECL to DST_DECL.  If the RTL was not set for
2895    SRC_DECL, it will not be set for DST_DECL; this is a lazy copy.  */
2896 #define COPY_DECL_RTL(SRC_DECL, DST_DECL) \
2897   (DECL_WRTL_CHECK (DST_DECL)->decl_with_rtl.rtl \
2898    = DECL_WRTL_CHECK (SRC_DECL)->decl_with_rtl.rtl)
2899
2900 /* The DECL_RTL for NODE, if it is set, or NULL, if it is not set.  */
2901 #define DECL_RTL_IF_SET(NODE) (DECL_RTL_SET_P (NODE) ? DECL_RTL (NODE) : NULL)
2902
2903 #if (GCC_VERSION >= 2007)
2904 #define DECL_RTL_KNOWN_SET(decl) __extension__                          \
2905 ({  tree const __d = (decl);                                            \
2906     gcc_checking_assert (DECL_RTL_SET_P (__d));                         \
2907     /* Dereference it so the compiler knows it can't be NULL even       \
2908        without assertion checking.  */                                  \
2909     &*DECL_RTL_IF_SET (__d); })
2910 #else
2911 #define DECL_RTL_KNOWN_SET(decl) (&*DECL_RTL_IF_SET (decl))
2912 #endif
2913
2914 /* In VAR_DECL and PARM_DECL nodes, nonzero means declared `register'.  */
2915 #define DECL_REGISTER(NODE) (DECL_WRTL_CHECK (NODE)->decl_common.decl_flag_0)
2916
2917 /* In a FIELD_DECL, this is the field position, counting in bytes, of the
2918    DECL_OFFSET_ALIGN-bit-sized word containing the bit closest to the beginning
2919    of the structure.  */
2920 #define DECL_FIELD_OFFSET(NODE) (FIELD_DECL_CHECK (NODE)->field_decl.offset)
2921
2922 /* In a FIELD_DECL, this is the offset, in bits, of the first bit of the
2923    field from DECL_FIELD_OFFSET.  This field may be nonzero even for fields
2924    that are not bit fields (since DECL_OFFSET_ALIGN may be larger than the
2925    natural alignment of the field's type).  */
2926 #define DECL_FIELD_BIT_OFFSET(NODE) \
2927   (FIELD_DECL_CHECK (NODE)->field_decl.bit_offset)
2928
2929 /* In a FIELD_DECL, this indicates whether the field was a bit-field and
2930    if so, the type that was originally specified for it.
2931    TREE_TYPE may have been modified (in finish_struct).  */
2932 #define DECL_BIT_FIELD_TYPE(NODE) \
2933   (FIELD_DECL_CHECK (NODE)->field_decl.bit_field_type)
2934
2935 /* In a FIELD_DECL of a RECORD_TYPE, this is a pointer to the storage
2936    representative FIELD_DECL.  */
2937 #define DECL_BIT_FIELD_REPRESENTATIVE(NODE) \
2938   (FIELD_DECL_CHECK (NODE)->field_decl.qualifier)
2939
2940 /* For a FIELD_DECL in a QUAL_UNION_TYPE, records the expression, which
2941    if nonzero, indicates that the field occupies the type.  */
2942 #define DECL_QUALIFIER(NODE) (FIELD_DECL_CHECK (NODE)->field_decl.qualifier)
2943
2944 /* For FIELD_DECLs, off_align holds the number of low-order bits of
2945    DECL_FIELD_OFFSET which are known to be always zero.
2946    DECL_OFFSET_ALIGN thus returns the alignment that DECL_FIELD_OFFSET
2947    has.  */
2948 #define DECL_OFFSET_ALIGN(NODE) \
2949   (((unsigned HOST_WIDE_INT)1) << FIELD_DECL_CHECK (NODE)->decl_common.off_align)
2950
2951 /* Specify that DECL_OFFSET_ALIGN(NODE) is X.  */
2952 #define SET_DECL_OFFSET_ALIGN(NODE, X) \
2953   (FIELD_DECL_CHECK (NODE)->decl_common.off_align = ffs_hwi (X) - 1)
2954
2955 /* For FIELD_DECLS, DECL_FCONTEXT is the *first* baseclass in
2956    which this FIELD_DECL is defined.  This information is needed when
2957    writing debugging information about vfield and vbase decls for C++.  */
2958 #define DECL_FCONTEXT(NODE) (FIELD_DECL_CHECK (NODE)->field_decl.fcontext)
2959
2960 /* In a FIELD_DECL, indicates this field should be bit-packed.  */
2961 #define DECL_PACKED(NODE) (FIELD_DECL_CHECK (NODE)->base.u.bits.packed_flag)
2962
2963 /* Nonzero in a FIELD_DECL means it is a bit field, and must be accessed
2964    specially.  */
2965 #define DECL_BIT_FIELD(NODE) (FIELD_DECL_CHECK (NODE)->decl_common.decl_flag_1)
2966
2967 /* In a FIELD_DECL, indicates this field should be ignored for ABI decisions
2968    like passing/returning containing struct by value.
2969    Set for C++17 empty base artificial FIELD_DECLs as well as
2970    empty [[no_unique_address]] non-static data members.  */
2971 #define DECL_FIELD_ABI_IGNORED(NODE) \
2972   (!DECL_BIT_FIELD (NODE) && (NODE)->decl_common.decl_flag_0)
2973 #define SET_DECL_FIELD_ABI_IGNORED(NODE, VAL) \
2974   do {                                                                  \
2975     gcc_checking_assert (!DECL_BIT_FIELD (NODE));                       \
2976     FIELD_DECL_CHECK (NODE)->decl_common.decl_flag_0 = (VAL);           \
2977   } while (0)
2978
2979 /* In a FIELD_DECL, indicates C++ zero-width bitfield that used to be
2980    removed from the IL since PR42217 until PR101539 and by that changed
2981    the ABI on several targets.  This flag is provided so that the backends
2982    can decide on the ABI with zero-width bitfields and emit -Wpsabi
2983    warnings.  */
2984 #define DECL_FIELD_CXX_ZERO_WIDTH_BIT_FIELD(NODE) \
2985   (DECL_BIT_FIELD (NODE) && (NODE)->decl_common.decl_flag_0)
2986 #define SET_DECL_FIELD_CXX_ZERO_WIDTH_BIT_FIELD(NODE, VAL) \
2987   do {                                                                  \
2988     gcc_checking_assert (DECL_BIT_FIELD (NODE));                        \
2989     FIELD_DECL_CHECK (NODE)->decl_common.decl_flag_0 = (VAL);           \
2990   } while (0)
2991
2992 /* Used in a FIELD_DECL to indicate that we cannot form the address of
2993    this component.  This makes it possible for Type-Based Alias Analysis
2994    to disambiguate accesses to this field with indirect accesses using
2995    the field's type:
2996
2997      struct S { int i; } s;
2998      int *p;
2999
3000    If the flag is set on 'i', TBAA computes that s.i and *p never conflict.
3001
3002    From the implementation's viewpoint, the alias set of the type of the
3003    field 'i' (int) will not be recorded as a subset of that of the type of
3004    's' (struct S) in record_component_aliases.  The counterpart is that
3005    accesses to s.i must not be given the alias set of the type of 'i'
3006    (int) but instead directly that of the type of 's' (struct S).  */
3007 #define DECL_NONADDRESSABLE_P(NODE) \
3008   (FIELD_DECL_CHECK (NODE)->decl_common.decl_flag_2)
3009
3010 /* Used in a FIELD_DECL to indicate that this field is padding.  */
3011 #define DECL_PADDING_P(NODE) \
3012   (FIELD_DECL_CHECK (NODE)->decl_common.decl_flag_3)
3013
3014 /* Used in a FIELD_DECL to indicate whether this field is not a flexible
3015    array member. This is only valid for the last array type field of a
3016    structure.  */
3017 #define DECL_NOT_FLEXARRAY(NODE) \
3018   (FIELD_DECL_CHECK (NODE)->decl_common.decl_not_flexarray)
3019
3020 /* A numeric unique identifier for a LABEL_DECL.  The UID allocation is
3021    dense, unique within any one function, and may be used to index arrays.
3022    If the value is -1, then no UID has been assigned.  */
3023 #define LABEL_DECL_UID(NODE) \
3024   (LABEL_DECL_CHECK (NODE)->label_decl.label_decl_uid)
3025
3026 /* In a LABEL_DECL, the EH region number for which the label is the
3027    post_landing_pad.  */
3028 #define EH_LANDING_PAD_NR(NODE) \
3029   (LABEL_DECL_CHECK (NODE)->label_decl.eh_landing_pad_nr)
3030
3031 /* For a PARM_DECL, records the data type used to pass the argument,
3032    which may be different from the type seen in the program.  */
3033 #define DECL_ARG_TYPE(NODE) (PARM_DECL_CHECK (NODE)->decl_common.initial)
3034
3035 /* For PARM_DECL, holds an RTL for the stack slot or register
3036    where the data was actually passed.  */
3037 #define DECL_INCOMING_RTL(NODE) \
3038   (PARM_DECL_CHECK (NODE)->parm_decl.incoming_rtl)
3039
3040 /* Nonzero for a given ..._DECL node means that no warnings should be
3041    generated just because this node is unused.  */
3042 #define DECL_IN_SYSTEM_HEADER(NODE) \
3043   (in_system_header_at (DECL_SOURCE_LOCATION (NODE)))
3044
3045 /* Used to indicate that the linkage status of this DECL is not yet known,
3046    so it should not be output now.  */
3047 #define DECL_DEFER_OUTPUT(NODE) \
3048   (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.defer_output)
3049
3050 /* In a VAR_DECL that's static,
3051    nonzero if the space is in the text section.  */
3052 #define DECL_IN_TEXT_SECTION(NODE) \
3053   (VAR_DECL_CHECK (NODE)->decl_with_vis.in_text_section)
3054
3055 /* In a VAR_DECL that's static,
3056    nonzero if it belongs to the global constant pool.  */
3057 #define DECL_IN_CONSTANT_POOL(NODE) \
3058   (VAR_DECL_CHECK (NODE)->decl_with_vis.in_constant_pool)
3059
3060 /* Nonzero for a given ..._DECL node means that this node should be
3061    put in .common, if possible.  If a DECL_INITIAL is given, and it
3062    is not error_mark_node, then the decl cannot be put in .common.  */
3063 #define DECL_COMMON(NODE) \
3064   (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.common_flag)
3065
3066 /* In a VAR_DECL, nonzero if the decl is a register variable with
3067    an explicit asm specification.  */
3068 #define DECL_HARD_REGISTER(NODE)  \
3069   (VAR_DECL_CHECK (NODE)->decl_with_vis.hard_register)
3070
3071   /* Used to indicate that this DECL has weak linkage.  */
3072 #define DECL_WEAK(NODE) (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.weak_flag)
3073
3074 /* Used to indicate that the DECL is a dllimport.  */
3075 #define DECL_DLLIMPORT_P(NODE) \
3076   (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.dllimport_flag)
3077
3078 /* Used in a DECL to indicate that, even if it TREE_PUBLIC, it need
3079    not be put out unless it is needed in this translation unit.
3080    Entities like this are shared across translation units (like weak
3081    entities), but are guaranteed to be generated by any translation
3082    unit that needs them, and therefore need not be put out anywhere
3083    where they are not needed.  DECL_COMDAT is just a hint to the
3084    back-end; it is up to front-ends which set this flag to ensure
3085    that there will never be any harm, other than bloat, in putting out
3086    something which is DECL_COMDAT.  */
3087 #define DECL_COMDAT(NODE) \
3088   (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.comdat_flag)
3089
3090 #define DECL_COMDAT_GROUP(NODE) \
3091   decl_comdat_group (NODE)
3092
3093 /* Used in TREE_PUBLIC decls to indicate that copies of this DECL in
3094    multiple translation units should be merged.  */
3095 #define DECL_ONE_ONLY(NODE) (DECL_COMDAT_GROUP (NODE) != NULL_TREE \
3096                              && (TREE_PUBLIC (NODE) || DECL_EXTERNAL (NODE)))
3097
3098 /* The name of the object as the assembler will see it (but before any
3099    translations made by ASM_OUTPUT_LABELREF).  Often this is the same
3100    as DECL_NAME.  It is an IDENTIFIER_NODE.
3101
3102    ASSEMBLER_NAME of TYPE_DECLS may store global name of type used for
3103    One Definition Rule based type merging at LTO.  It is computed only for
3104    LTO compilation and C++.  */
3105 #define DECL_ASSEMBLER_NAME(NODE) decl_assembler_name (NODE)
3106
3107 /* Raw accessor for DECL_ASSEMBLE_NAME.  */
3108 #define DECL_ASSEMBLER_NAME_RAW(NODE) \
3109   (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.assembler_name)
3110
3111 /* Return true if NODE is a NODE that can contain a DECL_ASSEMBLER_NAME.
3112    This is true of all DECL nodes except FIELD_DECL.  */
3113 #define HAS_DECL_ASSEMBLER_NAME_P(NODE) \
3114   (CODE_CONTAINS_STRUCT (TREE_CODE (NODE), TS_DECL_WITH_VIS))
3115
3116 /* Returns nonzero if the DECL_ASSEMBLER_NAME for NODE has been set.  If zero,
3117    the NODE might still have a DECL_ASSEMBLER_NAME -- it just hasn't been set
3118    yet.  */
3119 #define DECL_ASSEMBLER_NAME_SET_P(NODE) \
3120   (DECL_ASSEMBLER_NAME_RAW (NODE) != NULL_TREE)
3121
3122 /* Set the DECL_ASSEMBLER_NAME for NODE to NAME.  */
3123 #define SET_DECL_ASSEMBLER_NAME(NODE, NAME) \
3124   overwrite_decl_assembler_name (NODE, NAME)
3125
3126 /* Copy the DECL_ASSEMBLER_NAME from SRC_DECL to DST_DECL.  Note that
3127    if SRC_DECL's DECL_ASSEMBLER_NAME has not yet been set, using this
3128    macro will not cause the DECL_ASSEMBLER_NAME to be set, but will
3129    clear DECL_ASSEMBLER_NAME of DST_DECL, if it was already set.  In
3130    other words, the semantics of using this macro, are different than
3131    saying:
3132
3133      SET_DECL_ASSEMBLER_NAME(DST_DECL, DECL_ASSEMBLER_NAME (SRC_DECL))
3134
3135    which will try to set the DECL_ASSEMBLER_NAME for SRC_DECL.  */
3136
3137 #define COPY_DECL_ASSEMBLER_NAME(SRC_DECL, DST_DECL)                    \
3138   SET_DECL_ASSEMBLER_NAME (DST_DECL, DECL_ASSEMBLER_NAME_RAW (SRC_DECL))
3139
3140 /* Records the section name in a section attribute.  Used to pass
3141    the name from decl_attributes to make_function_rtl and make_decl_rtl.  */
3142 #define DECL_SECTION_NAME(NODE) decl_section_name (NODE)
3143
3144 /* Nonzero in a decl means that the gimplifier has seen (or placed)
3145    this variable in a BIND_EXPR.  */
3146 #define DECL_SEEN_IN_BIND_EXPR_P(NODE) \
3147   (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.seen_in_bind_expr)
3148
3149 /* Value of the decls's visibility attribute */
3150 #define DECL_VISIBILITY(NODE) \
3151   (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.visibility)
3152
3153 /* Nonzero means that the decl (or an enclosing scope) had its
3154    visibility specified rather than being inferred.  */
3155 #define DECL_VISIBILITY_SPECIFIED(NODE) \
3156   (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.visibility_specified)
3157
3158 /* In a VAR_DECL, the model to use if the data should be allocated from
3159    thread-local storage.  */
3160 #define DECL_TLS_MODEL(NODE) decl_tls_model (NODE)
3161
3162 /* In a VAR_DECL, nonzero if the data should be allocated from
3163    thread-local storage.  */
3164 #define DECL_THREAD_LOCAL_P(NODE) \
3165   ((TREE_STATIC (NODE) || DECL_EXTERNAL (NODE)) && decl_tls_model (NODE) >= TLS_MODEL_REAL)
3166
3167 /* In a non-local VAR_DECL with static storage duration, true if the
3168    variable has an initialization priority.  If false, the variable
3169    will be initialized at the DEFAULT_INIT_PRIORITY.  */
3170 #define DECL_HAS_INIT_PRIORITY_P(NODE) \
3171   (VAR_DECL_CHECK (NODE)->decl_with_vis.init_priority_p)
3172
3173 extern tree decl_debug_expr_lookup (tree);
3174 extern void decl_debug_expr_insert (tree, tree);
3175
3176 /* For VAR_DECL, this is set to an expression that it was split from.  */
3177 #define DECL_HAS_DEBUG_EXPR_P(NODE) \
3178   (VAR_DECL_CHECK (NODE)->decl_common.debug_expr_is_from)
3179 #define DECL_DEBUG_EXPR(NODE) \
3180   (decl_debug_expr_lookup (VAR_DECL_CHECK (NODE)))
3181
3182 #define SET_DECL_DEBUG_EXPR(NODE, VAL) \
3183   (decl_debug_expr_insert (VAR_DECL_CHECK (NODE), VAL))
3184
3185 extern priority_type decl_init_priority_lookup (tree);
3186 extern priority_type decl_fini_priority_lookup (tree);
3187 extern void decl_init_priority_insert (tree, priority_type);
3188 extern void decl_fini_priority_insert (tree, priority_type);
3189
3190 /* For a VAR_DECL or FUNCTION_DECL the initialization priority of
3191    NODE.  */
3192 #define DECL_INIT_PRIORITY(NODE) \
3193   (decl_init_priority_lookup (NODE))
3194 /* Set the initialization priority for NODE to VAL.  */
3195 #define SET_DECL_INIT_PRIORITY(NODE, VAL) \
3196   (decl_init_priority_insert (NODE, VAL))
3197
3198 /* For a FUNCTION_DECL the finalization priority of NODE.  */
3199 #define DECL_FINI_PRIORITY(NODE) \
3200   (decl_fini_priority_lookup (NODE))
3201 /* Set the finalization priority for NODE to VAL.  */
3202 #define SET_DECL_FINI_PRIORITY(NODE, VAL) \
3203   (decl_fini_priority_insert (NODE, VAL))
3204
3205 /* The initialization priority for entities for which no explicit
3206    initialization priority has been specified.  */
3207 #define DEFAULT_INIT_PRIORITY 65535
3208
3209 /* The maximum allowed initialization priority.  */
3210 #define MAX_INIT_PRIORITY 65535
3211
3212 /* The largest priority value reserved for use by system runtime
3213    libraries.  */
3214 #define MAX_RESERVED_INIT_PRIORITY 100
3215
3216 /* In a VAR_DECL, nonzero if this is a global variable for VOPs.  */
3217 #define VAR_DECL_IS_VIRTUAL_OPERAND(NODE) \
3218   (VAR_DECL_CHECK (NODE)->base.u.bits.saturating_flag)
3219
3220 /* In a VAR_DECL, nonzero if this is a non-local frame structure.  */
3221 #define DECL_NONLOCAL_FRAME(NODE)  \
3222   (VAR_DECL_CHECK (NODE)->base.default_def_flag)
3223
3224 /* In a VAR_DECL, nonzero if this variable is not aliased by any pointer.  */
3225 #define DECL_NONALIASED(NODE) \
3226   (VAR_DECL_CHECK (NODE)->base.nothrow_flag)
3227
3228 /* This field is used to reference anything in decl.result and is meant only
3229    for use by the garbage collector.  */
3230 #define DECL_RESULT_FLD(NODE) \
3231   (DECL_NON_COMMON_CHECK (NODE)->decl_non_common.result)
3232
3233 /* The DECL_VINDEX is used for FUNCTION_DECLS in two different ways.
3234    Before the struct containing the FUNCTION_DECL is laid out,
3235    DECL_VINDEX may point to a FUNCTION_DECL in a base class which
3236    is the FUNCTION_DECL which this FUNCTION_DECL will replace as a virtual
3237    function.  When the class is laid out, this pointer is changed
3238    to an INTEGER_CST node which is suitable for use as an index
3239    into the virtual function table. */
3240 #define DECL_VINDEX(NODE) \
3241   (FUNCTION_DECL_CHECK (NODE)->function_decl.vindex)
3242
3243 /* In FUNCTION_DECL, holds the decl for the return value.  */
3244 #define DECL_RESULT(NODE) (FUNCTION_DECL_CHECK (NODE)->decl_non_common.result)
3245
3246 /* In a FUNCTION_DECL, nonzero if the function cannot be inlined.  */
3247 #define DECL_UNINLINABLE(NODE) \
3248   (FUNCTION_DECL_CHECK (NODE)->function_decl.uninlinable)
3249
3250 /* In a FUNCTION_DECL, the saved representation of the body of the
3251    entire function.  */
3252 #define DECL_SAVED_TREE(NODE) \
3253   (FUNCTION_DECL_CHECK (NODE)->function_decl.saved_tree)
3254
3255 /* Nonzero in a FUNCTION_DECL means this function should be treated
3256    as if it were a malloc, meaning it returns a pointer that is
3257    not an alias.  */
3258 #define DECL_IS_MALLOC(NODE) \
3259   (FUNCTION_DECL_CHECK (NODE)->function_decl.malloc_flag)
3260
3261 /* Macro for direct set and get of function_decl.decl_type.  */
3262 #define FUNCTION_DECL_DECL_TYPE(NODE) \
3263   (NODE->function_decl.decl_type)
3264
3265 /* Set decl_type of a DECL.  Set it to T when SET is true, or reset
3266    it to NONE.  */
3267
3268 static inline void
3269 set_function_decl_type (tree decl, function_decl_type t, bool set)
3270 {
3271   if (set)
3272     {
3273       gcc_assert (FUNCTION_DECL_DECL_TYPE (decl) == NONE
3274                   || FUNCTION_DECL_DECL_TYPE (decl) == t);
3275       FUNCTION_DECL_DECL_TYPE (decl) = t;
3276     }
3277   else if (FUNCTION_DECL_DECL_TYPE (decl) == t)
3278     FUNCTION_DECL_DECL_TYPE (decl) = NONE;
3279 }
3280
3281 /* Nonzero in a FUNCTION_DECL means this function is a replaceable
3282    function (like replaceable operators new or delete).  */
3283 #define DECL_IS_REPLACEABLE_OPERATOR(NODE)\
3284    (FUNCTION_DECL_CHECK (NODE)->function_decl.replaceable_operator)
3285
3286 /* Nonzero in a FUNCTION_DECL means this function should be treated as
3287    C++ operator new, meaning that it returns a pointer for which we
3288    should not use type based aliasing.  */
3289 #define DECL_IS_OPERATOR_NEW_P(NODE) \
3290   (FUNCTION_DECL_DECL_TYPE (FUNCTION_DECL_CHECK (NODE)) == OPERATOR_NEW)
3291
3292 #define DECL_IS_REPLACEABLE_OPERATOR_NEW_P(NODE) \
3293   (DECL_IS_OPERATOR_NEW_P (NODE) && DECL_IS_REPLACEABLE_OPERATOR (NODE))
3294
3295 #define DECL_SET_IS_OPERATOR_NEW(NODE, VAL) \
3296   set_function_decl_type (FUNCTION_DECL_CHECK (NODE), OPERATOR_NEW, VAL)
3297
3298 /* Nonzero in a FUNCTION_DECL means this function should be treated as
3299    C++ operator delete.  */
3300 #define DECL_IS_OPERATOR_DELETE_P(NODE) \
3301   (FUNCTION_DECL_DECL_TYPE (FUNCTION_DECL_CHECK (NODE)) == OPERATOR_DELETE)
3302
3303 #define DECL_SET_IS_OPERATOR_DELETE(NODE, VAL) \
3304   set_function_decl_type (FUNCTION_DECL_CHECK (NODE), OPERATOR_DELETE, VAL)
3305
3306 /* Nonzero in a FUNCTION_DECL means this function may return more
3307    than once.  */
3308 #define DECL_IS_RETURNS_TWICE(NODE) \
3309   (FUNCTION_DECL_CHECK (NODE)->function_decl.returns_twice_flag)
3310
3311 /* Nonzero in a FUNCTION_DECL means this function should be treated
3312    as "pure" function (like const function, but may read global memory).
3313    Note that being pure or const for a function is orthogonal to being
3314    nothrow, i.e. it is valid to have DECL_PURE_P set and TREE_NOTHROW
3315    cleared.  */
3316 #define DECL_PURE_P(NODE) (FUNCTION_DECL_CHECK (NODE)->function_decl.pure_flag)
3317
3318 /* Nonzero only if one of TREE_READONLY or DECL_PURE_P is nonzero AND
3319    the const or pure function may not terminate.  When this is nonzero
3320    for a const or pure function, it can be dealt with by cse passes
3321    but cannot be removed by dce passes since you are not allowed to
3322    change an infinite looping program into one that terminates without
3323    error.  */
3324 #define DECL_LOOPING_CONST_OR_PURE_P(NODE) \
3325   (FUNCTION_DECL_CHECK (NODE)->function_decl.looping_const_or_pure_flag)
3326
3327 /* Nonzero in a FUNCTION_DECL means this function should be treated
3328    as "novops" function (function that does not read global memory,
3329    but may have arbitrary side effects).  */
3330 #define DECL_IS_NOVOPS(NODE) \
3331   (FUNCTION_DECL_CHECK (NODE)->function_decl.novops_flag)
3332
3333 /* Used in FUNCTION_DECLs to indicate that they should be run automatically
3334    at the beginning or end of execution.  */
3335 #define DECL_STATIC_CONSTRUCTOR(NODE) \
3336   (FUNCTION_DECL_CHECK (NODE)->function_decl.static_ctor_flag)
3337
3338 #define DECL_STATIC_DESTRUCTOR(NODE) \
3339 (FUNCTION_DECL_CHECK (NODE)->function_decl.static_dtor_flag)
3340
3341 /* Used in FUNCTION_DECLs to indicate that function entry and exit should
3342    be instrumented with calls to support routines.  */
3343 #define DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT(NODE) \
3344   (FUNCTION_DECL_CHECK (NODE)->function_decl.no_instrument_function_entry_exit)
3345
3346 /* Used in FUNCTION_DECLs to indicate that limit-stack-* should be
3347    disabled in this function.  */
3348 #define DECL_NO_LIMIT_STACK(NODE) \
3349   (FUNCTION_DECL_CHECK (NODE)->function_decl.no_limit_stack)
3350
3351 /* In a FUNCTION_DECL indicates that a static chain is needed.  */
3352 #define DECL_STATIC_CHAIN(NODE) \
3353   (FUNCTION_DECL_CHECK (NODE)->decl_with_vis.regdecl_flag)
3354
3355 /* Nonzero for a decl that cgraph has decided should be inlined into
3356    at least one call site.  It is not meaningful to look at this
3357    directly; always use cgraph_function_possibly_inlined_p.  */
3358 #define DECL_POSSIBLY_INLINED(DECL) \
3359   FUNCTION_DECL_CHECK (DECL)->function_decl.possibly_inlined
3360
3361 /* Nonzero in a FUNCTION_DECL means that this function was declared inline,
3362    such as via the `inline' keyword in C/C++.  This flag controls the linkage
3363    semantics of 'inline'  */
3364 #define DECL_DECLARED_INLINE_P(NODE) \
3365   (FUNCTION_DECL_CHECK (NODE)->function_decl.declared_inline_flag)
3366
3367 /* Nonzero in a FUNCTION_DECL means this function should not get
3368    -Winline warnings.  */
3369 #define DECL_NO_INLINE_WARNING_P(NODE) \
3370   (FUNCTION_DECL_CHECK (NODE)->function_decl.no_inline_warning_flag)
3371
3372 /* Nonzero if a FUNCTION_CODE is a TM load/store.  */
3373 #define BUILTIN_TM_LOAD_STORE_P(FN) \
3374   ((FN) >= BUILT_IN_TM_STORE_1 && (FN) <= BUILT_IN_TM_LOAD_RFW_LDOUBLE)
3375
3376 /* Nonzero if a FUNCTION_CODE is a TM load.  */
3377 #define BUILTIN_TM_LOAD_P(FN) \
3378   ((FN) >= BUILT_IN_TM_LOAD_1 && (FN) <= BUILT_IN_TM_LOAD_RFW_LDOUBLE)
3379
3380 /* Nonzero if a FUNCTION_CODE is a TM store.  */
3381 #define BUILTIN_TM_STORE_P(FN) \
3382   ((FN) >= BUILT_IN_TM_STORE_1 && (FN) <= BUILT_IN_TM_STORE_WAW_LDOUBLE)
3383
3384 #define CASE_BUILT_IN_TM_LOAD(FN)       \
3385   case BUILT_IN_TM_LOAD_##FN:           \
3386   case BUILT_IN_TM_LOAD_RAR_##FN:       \
3387   case BUILT_IN_TM_LOAD_RAW_##FN:       \
3388   case BUILT_IN_TM_LOAD_RFW_##FN
3389
3390 #define CASE_BUILT_IN_TM_STORE(FN)      \
3391   case BUILT_IN_TM_STORE_##FN:          \
3392   case BUILT_IN_TM_STORE_WAR_##FN:      \
3393   case BUILT_IN_TM_STORE_WAW_##FN
3394
3395 /* Nonzero in a FUNCTION_DECL that should be always inlined by the inliner
3396    disregarding size and cost heuristics.  This is equivalent to using
3397    the always_inline attribute without the required diagnostics if the
3398    function cannot be inlined.  */
3399 #define DECL_DISREGARD_INLINE_LIMITS(NODE) \
3400   (FUNCTION_DECL_CHECK (NODE)->function_decl.disregard_inline_limits)
3401
3402 extern vec<tree, va_gc> **decl_debug_args_lookup (tree);
3403 extern vec<tree, va_gc> **decl_debug_args_insert (tree);
3404
3405 /* Nonzero if a FUNCTION_DECL has DEBUG arguments attached to it.  */
3406 #define DECL_HAS_DEBUG_ARGS_P(NODE) \
3407   (FUNCTION_DECL_CHECK (NODE)->function_decl.has_debug_args_flag)
3408
3409 /* For FUNCTION_DECL, this holds a pointer to a structure ("struct function")
3410    that describes the status of this function.  */
3411 #define DECL_STRUCT_FUNCTION(NODE) \
3412   (FUNCTION_DECL_CHECK (NODE)->function_decl.f)
3413
3414 /* For a builtin function, identify which part of the compiler defined it.  */
3415 #define DECL_BUILT_IN_CLASS(NODE) \
3416    ((built_in_class) FUNCTION_DECL_CHECK (NODE)->function_decl.built_in_class)
3417
3418 /* In FUNCTION_DECL, a chain of ..._DECL nodes.  */
3419 #define DECL_ARGUMENTS(NODE) \
3420    (FUNCTION_DECL_CHECK (NODE)->function_decl.arguments)
3421
3422 /* In FUNCTION_DECL, the function specific target options to use when compiling
3423    this function.  */
3424 #define DECL_FUNCTION_SPECIFIC_TARGET(NODE) \
3425    (FUNCTION_DECL_CHECK (NODE)->function_decl.function_specific_target)
3426
3427 /* In FUNCTION_DECL, the function specific optimization options to use when
3428    compiling this function.  */
3429 #define DECL_FUNCTION_SPECIFIC_OPTIMIZATION(NODE) \
3430    (FUNCTION_DECL_CHECK (NODE)->function_decl.function_specific_optimization)
3431
3432 /* In FUNCTION_DECL, this is set if this function has other versions generated
3433    using "target" attributes.  The default version is the one which does not
3434    have any "target" attribute set. */
3435 #define DECL_FUNCTION_VERSIONED(NODE)\
3436    (FUNCTION_DECL_CHECK (NODE)->function_decl.versioned_function)
3437
3438 /* In FUNCTION_DECL, this is set if this function is a C++ constructor.
3439    Devirtualization machinery uses this knowledge for determing type of the
3440    object constructed.  Also we assume that constructor address is not
3441    important.  */
3442 #define DECL_CXX_CONSTRUCTOR_P(NODE)\
3443    (FUNCTION_DECL_CHECK (NODE)->decl_with_vis.cxx_constructor)
3444
3445 /* In FUNCTION_DECL, this is set if this function is a C++ destructor.
3446    Devirtualization machinery uses this to track types in destruction.  */
3447 #define DECL_CXX_DESTRUCTOR_P(NODE)\
3448    (FUNCTION_DECL_CHECK (NODE)->decl_with_vis.cxx_destructor)
3449
3450 /* In FUNCTION_DECL, this is set if this function is a lambda function.  */
3451 #define DECL_LAMBDA_FUNCTION_P(NODE) \
3452   (FUNCTION_DECL_DECL_TYPE (FUNCTION_DECL_CHECK (NODE)) == LAMBDA_FUNCTION)
3453
3454 #define DECL_SET_LAMBDA_FUNCTION(NODE, VAL) \
3455   set_function_decl_type (FUNCTION_DECL_CHECK (NODE), LAMBDA_FUNCTION, VAL)
3456
3457 /* In FUNCTION_DECL that represent an virtual method this is set when
3458    the method is final.  */
3459 #define DECL_FINAL_P(NODE)\
3460    (FUNCTION_DECL_CHECK (NODE)->decl_with_vis.final)
3461
3462 /* The source language of the translation-unit.  */
3463 #define TRANSLATION_UNIT_LANGUAGE(NODE) \
3464   (TRANSLATION_UNIT_DECL_CHECK (NODE)->translation_unit_decl.language)
3465
3466 /* TRANSLATION_UNIT_DECL inherits from DECL_MINIMAL.  */
3467
3468 /* For a TYPE_DECL, holds the "original" type.  (TREE_TYPE has the copy.) */
3469 #define DECL_ORIGINAL_TYPE(NODE) \
3470   (TYPE_DECL_CHECK (NODE)->decl_non_common.result)
3471
3472 /* In a TYPE_DECL nonzero means the detail info about this type is not dumped
3473    into stabs.  Instead it will generate cross reference ('x') of names.
3474    This uses the same flag as DECL_EXTERNAL.  */
3475 #define TYPE_DECL_SUPPRESS_DEBUG(NODE) \
3476   (TYPE_DECL_CHECK (NODE)->decl_common.decl_flag_1)
3477
3478 /* Getter of the imported declaration associated to the
3479    IMPORTED_DECL node.  */
3480 #define IMPORTED_DECL_ASSOCIATED_DECL(NODE) \
3481 (DECL_INITIAL (IMPORTED_DECL_CHECK (NODE)))
3482
3483 /* Getter of the symbol declaration associated with the
3484    NAMELIST_DECL node.  */
3485 #define NAMELIST_DECL_ASSOCIATED_DECL(NODE) \
3486   (DECL_INITIAL (NODE))
3487
3488 /* A STATEMENT_LIST chains statements together in GENERIC and GIMPLE.
3489    To reduce overhead, the nodes containing the statements are not trees.
3490    This avoids the overhead of tree_common on all linked list elements.
3491
3492    Use the interface in tree-iterator.h to access this node.  */
3493
3494 #define STATEMENT_LIST_HEAD(NODE) \
3495   (STATEMENT_LIST_CHECK (NODE)->stmt_list.head)
3496 #define STATEMENT_LIST_TAIL(NODE) \
3497   (STATEMENT_LIST_CHECK (NODE)->stmt_list.tail)
3498
3499 #define TREE_OPTIMIZATION(NODE) \
3500   (OPTIMIZATION_NODE_CHECK (NODE)->optimization.opts)
3501
3502 #define TREE_OPTIMIZATION_OPTABS(NODE) \
3503   (OPTIMIZATION_NODE_CHECK (NODE)->optimization.optabs)
3504
3505 #define TREE_OPTIMIZATION_BASE_OPTABS(NODE) \
3506   (OPTIMIZATION_NODE_CHECK (NODE)->optimization.base_optabs)
3507
3508 /* Return a tree node that encapsulates the optimization options in OPTS
3509    and OPTS_SET.  */
3510 extern tree build_optimization_node (struct gcc_options *opts,
3511                                      struct gcc_options *opts_set);
3512
3513 #define TREE_TARGET_OPTION(NODE) \
3514   (TARGET_OPTION_NODE_CHECK (NODE)->target_option.opts)
3515
3516 #define TREE_TARGET_GLOBALS(NODE) \
3517   (TARGET_OPTION_NODE_CHECK (NODE)->target_option.globals)
3518
3519 /* Return a tree node that encapsulates the target options in OPTS and
3520    OPTS_SET.  */
3521 extern tree build_target_option_node (struct gcc_options *opts,
3522                                       struct gcc_options *opts_set);
3523
3524 extern void prepare_target_option_nodes_for_pch (void);
3525
3526 #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
3527
3528 inline tree
3529 tree_check (tree __t, const char *__f, int __l, const char *__g, tree_code __c)
3530 {
3531   if (TREE_CODE (__t) != __c)
3532     tree_check_failed (__t, __f, __l, __g, __c, 0);
3533   return __t;
3534 }
3535
3536 inline tree
3537 tree_not_check (tree __t, const char *__f, int __l, const char *__g,
3538                 enum tree_code __c)
3539 {
3540   if (TREE_CODE (__t) == __c)
3541     tree_not_check_failed (__t, __f, __l, __g, __c, 0);
3542   return __t;
3543 }
3544
3545 inline tree
3546 tree_check2 (tree __t, const char *__f, int __l, const char *__g,
3547              enum tree_code __c1, enum tree_code __c2)
3548 {
3549   if (TREE_CODE (__t) != __c1
3550       && TREE_CODE (__t) != __c2)
3551     tree_check_failed (__t, __f, __l, __g, __c1, __c2, 0);
3552   return __t;
3553 }
3554
3555 inline tree
3556 tree_not_check2 (tree __t, const char *__f, int __l, const char *__g,
3557                  enum tree_code __c1, enum tree_code __c2)
3558 {
3559   if (TREE_CODE (__t) == __c1
3560       || TREE_CODE (__t) == __c2)
3561     tree_not_check_failed (__t, __f, __l, __g, __c1, __c2, 0);
3562   return __t;
3563 }
3564
3565 inline tree
3566 tree_check3 (tree __t, const char *__f, int __l, const char *__g,
3567              enum tree_code __c1, enum tree_code __c2, enum tree_code __c3)
3568 {
3569   if (TREE_CODE (__t) != __c1
3570       && TREE_CODE (__t) != __c2
3571       && TREE_CODE (__t) != __c3)
3572     tree_check_failed (__t, __f, __l, __g, __c1, __c2, __c3, 0);
3573   return __t;
3574 }
3575
3576 inline tree
3577 tree_not_check3 (tree __t, const char *__f, int __l, const char *__g,
3578                  enum tree_code __c1, enum tree_code __c2, enum tree_code __c3)
3579 {
3580   if (TREE_CODE (__t) == __c1
3581       || TREE_CODE (__t) == __c2
3582       || TREE_CODE (__t) == __c3)
3583     tree_not_check_failed (__t, __f, __l, __g, __c1, __c2, __c3, 0);
3584   return __t;
3585 }
3586
3587 inline tree
3588 tree_check4 (tree __t, const char *__f, int __l, const char *__g,
3589              enum tree_code __c1, enum tree_code __c2, enum tree_code __c3,
3590              enum tree_code __c4)
3591 {
3592   if (TREE_CODE (__t) != __c1
3593       && TREE_CODE (__t) != __c2
3594       && TREE_CODE (__t) != __c3
3595       && TREE_CODE (__t) != __c4)
3596     tree_check_failed (__t, __f, __l, __g, __c1, __c2, __c3, __c4, 0);
3597   return __t;
3598 }
3599
3600 inline tree
3601 tree_not_check4 (tree __t, const char *__f, int __l, const char *__g,
3602                  enum tree_code __c1, enum tree_code __c2, enum tree_code __c3,
3603                  enum tree_code __c4)
3604 {
3605   if (TREE_CODE (__t) == __c1
3606       || TREE_CODE (__t) == __c2
3607       || TREE_CODE (__t) == __c3
3608       || TREE_CODE (__t) == __c4)
3609     tree_not_check_failed (__t, __f, __l, __g, __c1, __c2, __c3, __c4, 0);
3610   return __t;
3611 }
3612
3613 inline tree
3614 tree_check5 (tree __t, const char *__f, int __l, const char *__g,
3615              enum tree_code __c1, enum tree_code __c2, enum tree_code __c3,
3616              enum tree_code __c4, enum tree_code __c5)
3617 {
3618   if (TREE_CODE (__t) != __c1
3619       && TREE_CODE (__t) != __c2
3620       && TREE_CODE (__t) != __c3
3621       && TREE_CODE (__t) != __c4
3622       && TREE_CODE (__t) != __c5)
3623     tree_check_failed (__t, __f, __l, __g, __c1, __c2, __c3, __c4, __c5, 0);
3624   return __t;
3625 }
3626
3627 inline tree
3628 tree_not_check5 (tree __t, const char *__f, int __l, const char *__g,
3629                  enum tree_code __c1, enum tree_code __c2, enum tree_code __c3,
3630                  enum tree_code __c4, enum tree_code __c5)
3631 {
3632   if (TREE_CODE (__t) == __c1
3633       || TREE_CODE (__t) == __c2
3634       || TREE_CODE (__t) == __c3
3635       || TREE_CODE (__t) == __c4
3636       || TREE_CODE (__t) == __c5)
3637     tree_not_check_failed (__t, __f, __l, __g, __c1, __c2, __c3, __c4, __c5, 0);
3638   return __t;
3639 }
3640
3641 inline tree
3642 contains_struct_check (tree __t, const enum tree_node_structure_enum __s,
3643                        const char *__f, int __l, const char *__g)
3644 {
3645   if (tree_contains_struct[TREE_CODE (__t)][__s] != 1)
3646       tree_contains_struct_check_failed (__t, __s, __f, __l, __g);
3647   return __t;
3648 }
3649
3650 inline tree
3651 tree_class_check (tree __t, const enum tree_code_class __class,
3652                   const char *__f, int __l, const char *__g)
3653 {
3654   if (TREE_CODE_CLASS (TREE_CODE (__t)) != __class)
3655     tree_class_check_failed (__t, __class, __f, __l, __g);
3656   return __t;
3657 }
3658
3659 inline tree
3660 tree_range_check (tree __t,
3661                   enum tree_code __code1, enum tree_code __code2,
3662                   const char *__f, int __l, const char *__g)
3663 {
3664   if (TREE_CODE (__t) < __code1 || TREE_CODE (__t) > __code2)
3665     tree_range_check_failed (__t, __f, __l, __g, __code1, __code2);
3666   return __t;
3667 }
3668
3669 inline tree
3670 omp_clause_subcode_check (tree __t, enum omp_clause_code __code,
3671                           const char *__f, int __l, const char *__g)
3672 {
3673   if (TREE_CODE (__t) != OMP_CLAUSE)
3674     tree_check_failed (__t, __f, __l, __g, OMP_CLAUSE, 0);
3675   if (__t->omp_clause.code != __code)
3676     omp_clause_check_failed (__t, __f, __l, __g, __code);
3677   return __t;
3678 }
3679
3680 inline tree
3681 omp_clause_range_check (tree __t,
3682                         enum omp_clause_code __code1,
3683                         enum omp_clause_code __code2,
3684                         const char *__f, int __l, const char *__g)
3685 {
3686   if (TREE_CODE (__t) != OMP_CLAUSE)
3687     tree_check_failed (__t, __f, __l, __g, OMP_CLAUSE, 0);
3688   if ((int) __t->omp_clause.code < (int) __code1
3689       || (int) __t->omp_clause.code > (int) __code2)
3690     omp_clause_range_check_failed (__t, __f, __l, __g, __code1, __code2);
3691   return __t;
3692 }
3693
3694 /* These checks have to be special cased.  */
3695
3696 inline tree
3697 expr_check (tree __t, const char *__f, int __l, const char *__g)
3698 {
3699   char const __c = TREE_CODE_CLASS (TREE_CODE (__t));
3700   if (!IS_EXPR_CODE_CLASS (__c))
3701     tree_class_check_failed (__t, tcc_expression, __f, __l, __g);
3702   return __t;
3703 }
3704
3705 /* These checks have to be special cased.  */
3706
3707 inline tree
3708 non_type_check (tree __t, const char *__f, int __l, const char *__g)
3709 {
3710   if (TYPE_P (__t))
3711     tree_not_class_check_failed (__t, tcc_type, __f, __l, __g);
3712   return __t;
3713 }
3714
3715 inline const HOST_WIDE_INT *
3716 tree_int_cst_elt_check (const_tree __t, int __i,
3717                         const char *__f, int __l, const char *__g)
3718 {
3719   if (TREE_CODE (__t) != INTEGER_CST)
3720     tree_check_failed (__t, __f, __l, __g, INTEGER_CST, 0);
3721   if (__i < 0 || __i >= __t->base.u.int_length.extended)
3722     tree_int_cst_elt_check_failed (__i, __t->base.u.int_length.extended,
3723                                    __f, __l, __g);
3724   return &CONST_CAST_TREE (__t)->int_cst.val[__i];
3725 }
3726
3727 inline HOST_WIDE_INT *
3728 tree_int_cst_elt_check (tree __t, int __i,
3729                         const char *__f, int __l, const char *__g)
3730 {
3731   if (TREE_CODE (__t) != INTEGER_CST)
3732     tree_check_failed (__t, __f, __l, __g, INTEGER_CST, 0);
3733   if (__i < 0 || __i >= __t->base.u.int_length.extended)
3734     tree_int_cst_elt_check_failed (__i, __t->base.u.int_length.extended,
3735                                    __f, __l, __g);
3736   return &CONST_CAST_TREE (__t)->int_cst.val[__i];
3737 }
3738
3739 /* Workaround -Wstrict-overflow false positive during profiledbootstrap.  */
3740
3741 # if GCC_VERSION >= 4006
3742 #pragma GCC diagnostic push
3743 #pragma GCC diagnostic ignored "-Wstrict-overflow"
3744 #endif
3745
3746 inline tree *
3747 tree_vec_elt_check (tree __t, int __i,
3748                     const char *__f, int __l, const char *__g)
3749 {
3750   if (TREE_CODE (__t) != TREE_VEC)
3751     tree_check_failed (__t, __f, __l, __g, TREE_VEC, 0);
3752   if (__i < 0 || __i >= __t->base.u.length)
3753     tree_vec_elt_check_failed (__i, __t->base.u.length, __f, __l, __g);
3754   return &CONST_CAST_TREE (__t)->vec.a[__i];
3755 }
3756
3757 # if GCC_VERSION >= 4006
3758 #pragma GCC diagnostic pop
3759 #endif
3760
3761 inline tree *
3762 omp_clause_elt_check (tree __t, int __i,
3763                       const char *__f, int __l, const char *__g)
3764 {
3765   if (TREE_CODE (__t) != OMP_CLAUSE)
3766     tree_check_failed (__t, __f, __l, __g, OMP_CLAUSE, 0);
3767   if (__i < 0 || __i >= omp_clause_num_ops [__t->omp_clause.code])
3768     omp_clause_operand_check_failed (__i, __t, __f, __l, __g);
3769   return &__t->omp_clause.ops[__i];
3770 }
3771
3772 /* These checks have to be special cased.  */
3773
3774 inline tree
3775 any_integral_type_check (tree __t, const char *__f, int __l, const char *__g)
3776 {
3777   if (!ANY_INTEGRAL_TYPE_P (__t))
3778     tree_check_failed (__t, __f, __l, __g, BOOLEAN_TYPE, ENUMERAL_TYPE,
3779                        INTEGER_TYPE, 0);
3780   return __t;
3781 }
3782
3783 inline const_tree
3784 tree_check (const_tree __t, const char *__f, int __l, const char *__g,
3785             tree_code __c)
3786 {
3787   if (TREE_CODE (__t) != __c)
3788     tree_check_failed (__t, __f, __l, __g, __c, 0);
3789   return __t;
3790 }
3791
3792 inline const_tree
3793 tree_not_check (const_tree __t, const char *__f, int __l, const char *__g,
3794                 enum tree_code __c)
3795 {
3796   if (TREE_CODE (__t) == __c)
3797     tree_not_check_failed (__t, __f, __l, __g, __c, 0);
3798   return __t;
3799 }
3800
3801 inline const_tree
3802 tree_check2 (const_tree __t, const char *__f, int __l, const char *__g,
3803              enum tree_code __c1, enum tree_code __c2)
3804 {
3805   if (TREE_CODE (__t) != __c1
3806       && TREE_CODE (__t) != __c2)
3807     tree_check_failed (__t, __f, __l, __g, __c1, __c2, 0);
3808   return __t;
3809 }
3810
3811 inline const_tree
3812 tree_not_check2 (const_tree __t, const char *__f, int __l, const char *__g,
3813                  enum tree_code __c1, enum tree_code __c2)
3814 {
3815   if (TREE_CODE (__t) == __c1
3816       || TREE_CODE (__t) == __c2)
3817     tree_not_check_failed (__t, __f, __l, __g, __c1, __c2, 0);
3818   return __t;
3819 }
3820
3821 inline const_tree
3822 tree_check3 (const_tree __t, const char *__f, int __l, const char *__g,
3823              enum tree_code __c1, enum tree_code __c2, enum tree_code __c3)
3824 {
3825   if (TREE_CODE (__t) != __c1
3826       && TREE_CODE (__t) != __c2
3827       && TREE_CODE (__t) != __c3)
3828     tree_check_failed (__t, __f, __l, __g, __c1, __c2, __c3, 0);
3829   return __t;
3830 }
3831
3832 inline const_tree
3833 tree_not_check3 (const_tree __t, const char *__f, int __l, const char *__g,
3834                  enum tree_code __c1, enum tree_code __c2, enum tree_code __c3)
3835 {
3836   if (TREE_CODE (__t) == __c1
3837       || TREE_CODE (__t) == __c2
3838       || TREE_CODE (__t) == __c3)
3839     tree_not_check_failed (__t, __f, __l, __g, __c1, __c2, __c3, 0);
3840   return __t;
3841 }
3842
3843 inline const_tree
3844 tree_check4 (const_tree __t, const char *__f, int __l, const char *__g,
3845              enum tree_code __c1, enum tree_code __c2, enum tree_code __c3,
3846              enum tree_code __c4)
3847 {
3848   if (TREE_CODE (__t) != __c1
3849       && TREE_CODE (__t) != __c2
3850       && TREE_CODE (__t) != __c3
3851       && TREE_CODE (__t) != __c4)
3852     tree_check_failed (__t, __f, __l, __g, __c1, __c2, __c3, __c4, 0);
3853   return __t;
3854 }
3855
3856 inline const_tree
3857 tree_not_check4 (const_tree __t, const char *__f, int __l, const char *__g,
3858                  enum tree_code __c1, enum tree_code __c2, enum tree_code __c3,
3859                  enum tree_code __c4)
3860 {
3861   if (TREE_CODE (__t) == __c1
3862       || TREE_CODE (__t) == __c2
3863       || TREE_CODE (__t) == __c3
3864       || TREE_CODE (__t) == __c4)
3865     tree_not_check_failed (__t, __f, __l, __g, __c1, __c2, __c3, __c4, 0);
3866   return __t;
3867 }
3868
3869 inline const_tree
3870 tree_check5 (const_tree __t, const char *__f, int __l, const char *__g,
3871              enum tree_code __c1, enum tree_code __c2, enum tree_code __c3,
3872              enum tree_code __c4, enum tree_code __c5)
3873 {
3874   if (TREE_CODE (__t) != __c1
3875       && TREE_CODE (__t) != __c2
3876       && TREE_CODE (__t) != __c3
3877       && TREE_CODE (__t) != __c4
3878       && TREE_CODE (__t) != __c5)
3879     tree_check_failed (__t, __f, __l, __g, __c1, __c2, __c3, __c4, __c5, 0);
3880   return __t;
3881 }
3882
3883 inline const_tree
3884 tree_not_check5 (const_tree __t, const char *__f, int __l, const char *__g,
3885                  enum tree_code __c1, enum tree_code __c2, enum tree_code __c3,
3886                  enum tree_code __c4, enum tree_code __c5)
3887 {
3888   if (TREE_CODE (__t) == __c1
3889       || TREE_CODE (__t) == __c2
3890       || TREE_CODE (__t) == __c3
3891       || TREE_CODE (__t) == __c4
3892       || TREE_CODE (__t) == __c5)
3893     tree_not_check_failed (__t, __f, __l, __g, __c1, __c2, __c3, __c4, __c5, 0);
3894   return __t;
3895 }
3896
3897 inline const_tree
3898 contains_struct_check (const_tree __t, const enum tree_node_structure_enum __s,
3899                        const char *__f, int __l, const char *__g)
3900 {
3901   if (tree_contains_struct[TREE_CODE (__t)][__s] != 1)
3902       tree_contains_struct_check_failed (__t, __s, __f, __l, __g);
3903   return __t;
3904 }
3905
3906 inline const_tree
3907 tree_class_check (const_tree __t, const enum tree_code_class __class,
3908                   const char *__f, int __l, const char *__g)
3909 {
3910   if (TREE_CODE_CLASS (TREE_CODE (__t)) != __class)
3911     tree_class_check_failed (__t, __class, __f, __l, __g);
3912   return __t;
3913 }
3914
3915 inline const_tree
3916 tree_range_check (const_tree __t,
3917                   enum tree_code __code1, enum tree_code __code2,
3918                   const char *__f, int __l, const char *__g)
3919 {
3920   if (TREE_CODE (__t) < __code1 || TREE_CODE (__t) > __code2)
3921     tree_range_check_failed (__t, __f, __l, __g, __code1, __code2);
3922   return __t;
3923 }
3924
3925 inline const_tree
3926 omp_clause_subcode_check (const_tree __t, enum omp_clause_code __code,
3927                           const char *__f, int __l, const char *__g)
3928 {
3929   if (TREE_CODE (__t) != OMP_CLAUSE)
3930     tree_check_failed (__t, __f, __l, __g, OMP_CLAUSE, 0);
3931   if (__t->omp_clause.code != __code)
3932     omp_clause_check_failed (__t, __f, __l, __g, __code);
3933   return __t;
3934 }
3935
3936 inline const_tree
3937 omp_clause_range_check (const_tree __t,
3938                         enum omp_clause_code __code1,
3939                         enum omp_clause_code __code2,
3940                         const char *__f, int __l, const char *__g)
3941 {
3942   if (TREE_CODE (__t) != OMP_CLAUSE)
3943     tree_check_failed (__t, __f, __l, __g, OMP_CLAUSE, 0);
3944   if ((int) __t->omp_clause.code < (int) __code1
3945       || (int) __t->omp_clause.code > (int) __code2)
3946     omp_clause_range_check_failed (__t, __f, __l, __g, __code1, __code2);
3947   return __t;
3948 }
3949
3950 inline const_tree
3951 expr_check (const_tree __t, const char *__f, int __l, const char *__g)
3952 {
3953   char const __c = TREE_CODE_CLASS (TREE_CODE (__t));
3954   if (!IS_EXPR_CODE_CLASS (__c))
3955     tree_class_check_failed (__t, tcc_expression, __f, __l, __g);
3956   return __t;
3957 }
3958
3959 inline const_tree
3960 non_type_check (const_tree __t, const char *__f, int __l, const char *__g)
3961 {
3962   if (TYPE_P (__t))
3963     tree_not_class_check_failed (__t, tcc_type, __f, __l, __g);
3964   return __t;
3965 }
3966
3967 # if GCC_VERSION >= 4006
3968 #pragma GCC diagnostic push
3969 #pragma GCC diagnostic ignored "-Wstrict-overflow"
3970 #endif
3971
3972 inline const_tree *
3973 tree_vec_elt_check (const_tree __t, int __i,
3974                     const char *__f, int __l, const char *__g)
3975 {
3976   if (TREE_CODE (__t) != TREE_VEC)
3977     tree_check_failed (__t, __f, __l, __g, TREE_VEC, 0);
3978   if (__i < 0 || __i >= __t->base.u.length)
3979     tree_vec_elt_check_failed (__i, __t->base.u.length, __f, __l, __g);
3980   return CONST_CAST (const_tree *, &__t->vec.a[__i]);
3981   //return &__t->vec.a[__i];
3982 }
3983
3984 # if GCC_VERSION >= 4006
3985 #pragma GCC diagnostic pop
3986 #endif
3987
3988 inline const_tree *
3989 omp_clause_elt_check (const_tree __t, int __i,
3990                       const char *__f, int __l, const char *__g)
3991 {
3992   if (TREE_CODE (__t) != OMP_CLAUSE)
3993     tree_check_failed (__t, __f, __l, __g, OMP_CLAUSE, 0);
3994   if (__i < 0 || __i >= omp_clause_num_ops [__t->omp_clause.code])
3995     omp_clause_operand_check_failed (__i, __t, __f, __l, __g);
3996   return CONST_CAST (const_tree *, &__t->omp_clause.ops[__i]);
3997 }
3998
3999 inline const_tree
4000 any_integral_type_check (const_tree __t, const char *__f, int __l,
4001                          const char *__g)
4002 {
4003   if (!ANY_INTEGRAL_TYPE_P (__t))
4004     tree_check_failed (__t, __f, __l, __g, BOOLEAN_TYPE, ENUMERAL_TYPE,
4005                        INTEGER_TYPE, 0);
4006   return __t;
4007 }
4008
4009 #endif
4010
4011 /* Compute the number of operands in an expression node NODE.  For
4012    tcc_vl_exp nodes like CALL_EXPRs, this is stored in the node itself,
4013    otherwise it is looked up from the node's code.  */
4014 static inline int
4015 tree_operand_length (const_tree node)
4016 {
4017   if (VL_EXP_CLASS_P (node))
4018     return VL_EXP_OPERAND_LENGTH (node);
4019   else
4020     return TREE_CODE_LENGTH (TREE_CODE (node));
4021 }
4022
4023 #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
4024
4025 /* Special checks for TREE_OPERANDs.  */
4026 inline tree *
4027 tree_operand_check (tree __t, int __i,
4028                     const char *__f, int __l, const char *__g)
4029 {
4030   const_tree __u = EXPR_CHECK (__t);
4031   if (__i < 0 || __i >= TREE_OPERAND_LENGTH (__u))
4032     tree_operand_check_failed (__i, __u, __f, __l, __g);
4033   return &CONST_CAST_TREE (__u)->exp.operands[__i];
4034 }
4035
4036 inline tree *
4037 tree_operand_check_code (tree __t, enum tree_code __code, int __i,
4038                          const char *__f, int __l, const char *__g)
4039 {
4040   if (TREE_CODE (__t) != __code)
4041     tree_check_failed (__t, __f, __l, __g, __code, 0);
4042   if (__i < 0 || __i >= TREE_OPERAND_LENGTH (__t))
4043     tree_operand_check_failed (__i, __t, __f, __l, __g);
4044   return &__t->exp.operands[__i];
4045 }
4046
4047 inline const_tree *
4048 tree_operand_check (const_tree __t, int __i,
4049                     const char *__f, int __l, const char *__g)
4050 {
4051   const_tree __u = EXPR_CHECK (__t);
4052   if (__i < 0 || __i >= TREE_OPERAND_LENGTH (__u))
4053     tree_operand_check_failed (__i, __u, __f, __l, __g);
4054   return CONST_CAST (const_tree *, &__u->exp.operands[__i]);
4055 }
4056
4057 inline const_tree *
4058 tree_operand_check_code (const_tree __t, enum tree_code __code, int __i,
4059                          const char *__f, int __l, const char *__g)
4060 {
4061   if (TREE_CODE (__t) != __code)
4062     tree_check_failed (__t, __f, __l, __g, __code, 0);
4063   if (__i < 0 || __i >= TREE_OPERAND_LENGTH (__t))
4064     tree_operand_check_failed (__i, __t, __f, __l, __g);
4065   return CONST_CAST (const_tree *, &__t->exp.operands[__i]);
4066 }
4067
4068 #endif
4069
4070 /* True iff an identifier matches a C string.  */
4071
4072 inline bool
4073 id_equal (const_tree id, const char *str)
4074 {
4075   return !strcmp (IDENTIFIER_POINTER (id), str);
4076 }
4077
4078 inline bool
4079 id_equal (const char *str, const_tree id)
4080 {
4081   return id_equal (id, str);
4082 }
4083
4084 /* Return the number of elements in the VECTOR_TYPE given by NODE.  */
4085
4086 inline poly_uint64
4087 TYPE_VECTOR_SUBPARTS (const_tree node)
4088 {
4089   STATIC_ASSERT (NUM_POLY_INT_COEFFS <= 2);
4090   unsigned int precision = VECTOR_TYPE_CHECK (node)->type_common.precision;
4091   if (NUM_POLY_INT_COEFFS == 2)
4092     {
4093       /* See the corresponding code in SET_TYPE_VECTOR_SUBPARTS for a
4094          description of the encoding.  */
4095       poly_uint64 res = 0;
4096       res.coeffs[0] = HOST_WIDE_INT_1U << (precision & 0xff);
4097       if (precision & 0x100)
4098         res.coeffs[1] = HOST_WIDE_INT_1U << (precision & 0xff);
4099       return res;
4100     }
4101   else
4102     return HOST_WIDE_INT_1U << precision;
4103 }
4104
4105 /* Set the number of elements in VECTOR_TYPE NODE to SUBPARTS, which must
4106    satisfy valid_vector_subparts_p.  */
4107
4108 inline void
4109 SET_TYPE_VECTOR_SUBPARTS (tree node, poly_uint64 subparts)
4110 {
4111   STATIC_ASSERT (NUM_POLY_INT_COEFFS <= 2);
4112   unsigned HOST_WIDE_INT coeff0 = subparts.coeffs[0];
4113   int index = exact_log2 (coeff0);
4114   gcc_assert (index >= 0);
4115   if (NUM_POLY_INT_COEFFS == 2)
4116     {
4117       /* We have two coefficients that are each in the range 1 << [0, 63],
4118          so supporting all combinations would require 6 bits per coefficient
4119          and 12 bits in total.  Since the precision field is only 10 bits
4120          in size, we need to be more restrictive than that.
4121
4122          At present, coeff[1] is always either 0 (meaning that the number
4123          of units is constant) or equal to coeff[0] (meaning that the number
4124          of units is N + X * N for some target-dependent zero-based runtime
4125          parameter X).  We can therefore encode coeff[1] in a single bit.
4126
4127          The most compact encoding would be to use mask 0x3f for coeff[0]
4128          and 0x40 for coeff[1], leaving 0x380 unused.  It's possible to
4129          get slightly more efficient code on some hosts if we instead
4130          treat the shift amount as an independent byte, so here we use
4131          0xff for coeff[0] and 0x100 for coeff[1].  */
4132       unsigned HOST_WIDE_INT coeff1 = subparts.coeffs[1];
4133       gcc_assert (coeff1 == 0 || coeff1 == coeff0);
4134       VECTOR_TYPE_CHECK (node)->type_common.precision
4135         = index + (coeff1 != 0 ? 0x100 : 0);
4136     }
4137   else
4138     VECTOR_TYPE_CHECK (node)->type_common.precision = index;
4139 }
4140
4141 /* Return true if we can construct vector types with the given number
4142    of subparts.  */
4143
4144 static inline bool
4145 valid_vector_subparts_p (poly_uint64 subparts)
4146 {
4147   unsigned HOST_WIDE_INT coeff0 = subparts.coeffs[0];
4148   if (!pow2p_hwi (coeff0))
4149     return false;
4150   if (NUM_POLY_INT_COEFFS == 2)
4151     {
4152       unsigned HOST_WIDE_INT coeff1 = subparts.coeffs[1];
4153       if (coeff1 != 0 && coeff1 != coeff0)
4154         return false;
4155     }
4156   return true;
4157 }
4158
4159 /* Return the built-in function that DECL represents, given that it is known
4160    to be a FUNCTION_DECL with built-in class BUILT_IN_NORMAL.  */
4161 inline built_in_function
4162 DECL_FUNCTION_CODE (const_tree decl)
4163 {
4164   const tree_function_decl &fndecl = FUNCTION_DECL_CHECK (decl)->function_decl;
4165   gcc_checking_assert (fndecl.built_in_class == BUILT_IN_NORMAL);
4166   return (built_in_function) fndecl.function_code;
4167 }
4168
4169 /* Return the target-specific built-in function that DECL represents,
4170    given that it is known to be a FUNCTION_DECL with built-in class
4171    BUILT_IN_MD.  */
4172 inline int
4173 DECL_MD_FUNCTION_CODE (const_tree decl)
4174 {
4175   const tree_function_decl &fndecl = FUNCTION_DECL_CHECK (decl)->function_decl;
4176   gcc_checking_assert (fndecl.built_in_class == BUILT_IN_MD);
4177   return fndecl.function_code;
4178 }
4179
4180 /* Return the frontend-specific built-in function that DECL represents,
4181    given that it is known to be a FUNCTION_DECL with built-in class
4182    BUILT_IN_FRONTEND.  */
4183 inline int
4184 DECL_FE_FUNCTION_CODE (const_tree decl)
4185 {
4186   const tree_function_decl &fndecl = FUNCTION_DECL_CHECK (decl)->function_decl;
4187   gcc_checking_assert (fndecl.built_in_class == BUILT_IN_FRONTEND);
4188   return fndecl.function_code;
4189 }
4190
4191 /* Record that FUNCTION_DECL DECL represents built-in function FCODE of
4192    class FCLASS.  */
4193 inline void
4194 set_decl_built_in_function (tree decl, built_in_class fclass,
4195                             unsigned int fcode)
4196 {
4197   tree_function_decl &fndecl = FUNCTION_DECL_CHECK (decl)->function_decl;
4198   fndecl.built_in_class = fclass;
4199   fndecl.function_code = fcode;
4200 }
4201
4202 /* Record that FUNCTION_DECL NEWDECL represents the same built-in function
4203    as OLDDECL (or none, if OLDDECL doesn't represent a built-in function).  */
4204 inline void
4205 copy_decl_built_in_function (tree newdecl, const_tree olddecl)
4206 {
4207   tree_function_decl &newfndecl = FUNCTION_DECL_CHECK (newdecl)->function_decl;
4208   const tree_function_decl &oldfndecl
4209     = FUNCTION_DECL_CHECK (olddecl)->function_decl;
4210   newfndecl.built_in_class = oldfndecl.built_in_class;
4211   newfndecl.function_code = oldfndecl.function_code;
4212 }
4213
4214 /* In NON_LVALUE_EXPR and VIEW_CONVERT_EXPR, set when this node is merely a
4215    wrapper added to express a location_t on behalf of the node's child
4216    (e.g. by maybe_wrap_with_location).  */
4217
4218 #define EXPR_LOCATION_WRAPPER_P(NODE) \
4219   (TREE_CHECK2(NODE, NON_LVALUE_EXPR, VIEW_CONVERT_EXPR)->base.public_flag)
4220
4221 /* Test if EXP is merely a wrapper node, added to express a location_t
4222    on behalf of the node's child (e.g. by maybe_wrap_with_location).  */
4223
4224 inline bool
4225 location_wrapper_p (const_tree exp)
4226 {
4227   /* A wrapper node has code NON_LVALUE_EXPR or VIEW_CONVERT_EXPR, and
4228      the flag EXPR_LOCATION_WRAPPER_P is set.
4229      It normally has the same type as its operand, but it can have a
4230      different one if the type of the operand has changed (e.g. when
4231      merging duplicate decls).
4232
4233      NON_LVALUE_EXPR is used for wrapping constants, apart from STRING_CST.
4234      VIEW_CONVERT_EXPR is used for wrapping non-constants and STRING_CST.  */
4235   if ((TREE_CODE (exp) == NON_LVALUE_EXPR
4236        || TREE_CODE (exp) == VIEW_CONVERT_EXPR)
4237       && EXPR_LOCATION_WRAPPER_P (exp))
4238     return true;
4239   return false;
4240 }
4241
4242 /* Implementation of STRIP_ANY_LOCATION_WRAPPER.  */
4243
4244 inline tree
4245 tree_strip_any_location_wrapper (tree exp)
4246 {
4247   if (location_wrapper_p (exp))
4248     return TREE_OPERAND (exp, 0);
4249   else
4250     return exp;
4251 }
4252
4253 #define error_mark_node                 global_trees[TI_ERROR_MARK]
4254
4255 #define intQI_type_node                 global_trees[TI_INTQI_TYPE]
4256 #define intHI_type_node                 global_trees[TI_INTHI_TYPE]
4257 #define intSI_type_node                 global_trees[TI_INTSI_TYPE]
4258 #define intDI_type_node                 global_trees[TI_INTDI_TYPE]
4259 #define intTI_type_node                 global_trees[TI_INTTI_TYPE]
4260
4261 #define unsigned_intQI_type_node        global_trees[TI_UINTQI_TYPE]
4262 #define unsigned_intHI_type_node        global_trees[TI_UINTHI_TYPE]
4263 #define unsigned_intSI_type_node        global_trees[TI_UINTSI_TYPE]
4264 #define unsigned_intDI_type_node        global_trees[TI_UINTDI_TYPE]
4265 #define unsigned_intTI_type_node        global_trees[TI_UINTTI_TYPE]
4266
4267 #define atomicQI_type_node      global_trees[TI_ATOMICQI_TYPE]
4268 #define atomicHI_type_node      global_trees[TI_ATOMICHI_TYPE]
4269 #define atomicSI_type_node      global_trees[TI_ATOMICSI_TYPE]
4270 #define atomicDI_type_node      global_trees[TI_ATOMICDI_TYPE]
4271 #define atomicTI_type_node      global_trees[TI_ATOMICTI_TYPE]
4272
4273 #define uint16_type_node                global_trees[TI_UINT16_TYPE]
4274 #define uint32_type_node                global_trees[TI_UINT32_TYPE]
4275 #define uint64_type_node                global_trees[TI_UINT64_TYPE]
4276 #define uint128_type_node               global_trees[TI_UINT128_TYPE]
4277
4278 #define void_node                       global_trees[TI_VOID]
4279
4280 #define integer_zero_node               global_trees[TI_INTEGER_ZERO]
4281 #define integer_one_node                global_trees[TI_INTEGER_ONE]
4282 #define integer_three_node              global_trees[TI_INTEGER_THREE]
4283 #define integer_minus_one_node          global_trees[TI_INTEGER_MINUS_ONE]
4284 #define size_zero_node                  global_trees[TI_SIZE_ZERO]
4285 #define size_one_node                   global_trees[TI_SIZE_ONE]
4286 #define bitsize_zero_node               global_trees[TI_BITSIZE_ZERO]
4287 #define bitsize_one_node                global_trees[TI_BITSIZE_ONE]
4288 #define bitsize_unit_node               global_trees[TI_BITSIZE_UNIT]
4289
4290 /* Base access nodes.  */
4291 #define access_public_node              global_trees[TI_PUBLIC]
4292 #define access_protected_node           global_trees[TI_PROTECTED]
4293 #define access_private_node             global_trees[TI_PRIVATE]
4294
4295 #define null_pointer_node               global_trees[TI_NULL_POINTER]
4296
4297 #define float_type_node                 global_trees[TI_FLOAT_TYPE]
4298 #define double_type_node                global_trees[TI_DOUBLE_TYPE]
4299 #define long_double_type_node           global_trees[TI_LONG_DOUBLE_TYPE]
4300 #define bfloat16_type_node              global_trees[TI_BFLOAT16_TYPE]
4301
4302 /* Nodes for particular _FloatN and _FloatNx types in sequence.  */
4303 #define FLOATN_TYPE_NODE(IDX)           global_trees[TI_FLOATN_TYPE_FIRST + (IDX)]
4304 #define FLOATN_NX_TYPE_NODE(IDX)        global_trees[TI_FLOATN_NX_TYPE_FIRST + (IDX)]
4305 #define FLOATNX_TYPE_NODE(IDX)          global_trees[TI_FLOATNX_TYPE_FIRST + (IDX)]
4306
4307 /* Names for individual types (code should normally iterate over all
4308    such types; these are only for back-end use, or in contexts such as
4309    *.def where iteration is not possible).  */
4310 #define float16_type_node               global_trees[TI_FLOAT16_TYPE]
4311 #define float32_type_node               global_trees[TI_FLOAT32_TYPE]
4312 #define float64_type_node               global_trees[TI_FLOAT64_TYPE]
4313 #define float128_type_node              global_trees[TI_FLOAT128_TYPE]
4314 #define float32x_type_node              global_trees[TI_FLOAT32X_TYPE]
4315 #define float64x_type_node              global_trees[TI_FLOAT64X_TYPE]
4316 #define float128x_type_node             global_trees[TI_FLOAT128X_TYPE]
4317
4318 /* Type used by certain backends for __float128, which in C++ should be
4319    distinct type from _Float128 for backwards compatibility reasons.  */
4320 #define float128t_type_node             global_trees[TI_FLOAT128T_TYPE]
4321
4322 #define float_ptr_type_node             global_trees[TI_FLOAT_PTR_TYPE]
4323 #define double_ptr_type_node            global_trees[TI_DOUBLE_PTR_TYPE]
4324 #define long_double_ptr_type_node       global_trees[TI_LONG_DOUBLE_PTR_TYPE]
4325 #define integer_ptr_type_node           global_trees[TI_INTEGER_PTR_TYPE]
4326
4327 #define complex_integer_type_node       global_trees[TI_COMPLEX_INTEGER_TYPE]
4328 #define complex_float_type_node         global_trees[TI_COMPLEX_FLOAT_TYPE]
4329 #define complex_double_type_node        global_trees[TI_COMPLEX_DOUBLE_TYPE]
4330 #define complex_long_double_type_node   global_trees[TI_COMPLEX_LONG_DOUBLE_TYPE]
4331
4332 #define COMPLEX_FLOATN_NX_TYPE_NODE(IDX)        global_trees[TI_COMPLEX_FLOATN_NX_TYPE_FIRST + (IDX)]
4333
4334 #define void_type_node                  global_trees[TI_VOID_TYPE]
4335 /* The C type `void *'.  */
4336 #define ptr_type_node                   global_trees[TI_PTR_TYPE]
4337 /* The C type `const void *'.  */
4338 #define const_ptr_type_node             global_trees[TI_CONST_PTR_TYPE]
4339 /* The C type `size_t'.  */
4340 #define size_type_node                  global_trees[TI_SIZE_TYPE]
4341 #define pid_type_node                   global_trees[TI_PID_TYPE]
4342 #define ptrdiff_type_node               global_trees[TI_PTRDIFF_TYPE]
4343 #define va_list_type_node               global_trees[TI_VA_LIST_TYPE]
4344 #define va_list_gpr_counter_field       global_trees[TI_VA_LIST_GPR_COUNTER_FIELD]
4345 #define va_list_fpr_counter_field       global_trees[TI_VA_LIST_FPR_COUNTER_FIELD]
4346 /* The C type `FILE *'.  */
4347 #define fileptr_type_node               global_trees[TI_FILEPTR_TYPE]
4348 /* The C type `const struct tm *'.  */
4349 #define const_tm_ptr_type_node          global_trees[TI_CONST_TM_PTR_TYPE]
4350 /* The C type `fenv_t *'.  */
4351 #define fenv_t_ptr_type_node            global_trees[TI_FENV_T_PTR_TYPE]
4352 #define const_fenv_t_ptr_type_node      global_trees[TI_CONST_FENV_T_PTR_TYPE]
4353 /* The C type `fexcept_t *'.  */
4354 #define fexcept_t_ptr_type_node         global_trees[TI_FEXCEPT_T_PTR_TYPE]
4355 #define const_fexcept_t_ptr_type_node   global_trees[TI_CONST_FEXCEPT_T_PTR_TYPE]
4356 #define pointer_sized_int_node          global_trees[TI_POINTER_SIZED_TYPE]
4357
4358 #define boolean_type_node               global_trees[TI_BOOLEAN_TYPE]
4359 #define boolean_false_node              global_trees[TI_BOOLEAN_FALSE]
4360 #define boolean_true_node               global_trees[TI_BOOLEAN_TRUE]
4361
4362 /* The decimal floating point types. */
4363 #define dfloat32_type_node              global_trees[TI_DFLOAT32_TYPE]
4364 #define dfloat64_type_node              global_trees[TI_DFLOAT64_TYPE]
4365 #define dfloat128_type_node             global_trees[TI_DFLOAT128_TYPE]
4366
4367 /* The fixed-point types.  */
4368 #define sat_short_fract_type_node       global_trees[TI_SAT_SFRACT_TYPE]
4369 #define sat_fract_type_node             global_trees[TI_SAT_FRACT_TYPE]
4370 #define sat_long_fract_type_node        global_trees[TI_SAT_LFRACT_TYPE]
4371 #define sat_long_long_fract_type_node   global_trees[TI_SAT_LLFRACT_TYPE]
4372 #define sat_unsigned_short_fract_type_node \
4373                                         global_trees[TI_SAT_USFRACT_TYPE]
4374 #define sat_unsigned_fract_type_node    global_trees[TI_SAT_UFRACT_TYPE]
4375 #define sat_unsigned_long_fract_type_node \
4376                                         global_trees[TI_SAT_ULFRACT_TYPE]
4377 #define sat_unsigned_long_long_fract_type_node \
4378                                         global_trees[TI_SAT_ULLFRACT_TYPE]
4379 #define short_fract_type_node           global_trees[TI_SFRACT_TYPE]
4380 #define fract_type_node                 global_trees[TI_FRACT_TYPE]
4381 #define long_fract_type_node            global_trees[TI_LFRACT_TYPE]
4382 #define long_long_fract_type_node       global_trees[TI_LLFRACT_TYPE]
4383 #define unsigned_short_fract_type_node  global_trees[TI_USFRACT_TYPE]
4384 #define unsigned_fract_type_node        global_trees[TI_UFRACT_TYPE]
4385 #define unsigned_long_fract_type_node   global_trees[TI_ULFRACT_TYPE]
4386 #define unsigned_long_long_fract_type_node \
4387                                         global_trees[TI_ULLFRACT_TYPE]
4388 #define sat_short_accum_type_node       global_trees[TI_SAT_SACCUM_TYPE]
4389 #define sat_accum_type_node             global_trees[TI_SAT_ACCUM_TYPE]
4390 #define sat_long_accum_type_node        global_trees[TI_SAT_LACCUM_TYPE]
4391 #define sat_long_long_accum_type_node   global_trees[TI_SAT_LLACCUM_TYPE]
4392 #define sat_unsigned_short_accum_type_node \
4393                                         global_trees[TI_SAT_USACCUM_TYPE]
4394 #define sat_unsigned_accum_type_node    global_trees[TI_SAT_UACCUM_TYPE]
4395 #define sat_unsigned_long_accum_type_node \
4396                                         global_trees[TI_SAT_ULACCUM_TYPE]
4397 #define sat_unsigned_long_long_accum_type_node \
4398                                         global_trees[TI_SAT_ULLACCUM_TYPE]
4399 #define short_accum_type_node           global_trees[TI_SACCUM_TYPE]
4400 #define accum_type_node                 global_trees[TI_ACCUM_TYPE]
4401 #define long_accum_type_node            global_trees[TI_LACCUM_TYPE]
4402 #define long_long_accum_type_node       global_trees[TI_LLACCUM_TYPE]
4403 #define unsigned_short_accum_type_node  global_trees[TI_USACCUM_TYPE]
4404 #define unsigned_accum_type_node        global_trees[TI_UACCUM_TYPE]
4405 #define unsigned_long_accum_type_node   global_trees[TI_ULACCUM_TYPE]
4406 #define unsigned_long_long_accum_type_node \
4407                                         global_trees[TI_ULLACCUM_TYPE]
4408 #define qq_type_node                    global_trees[TI_QQ_TYPE]
4409 #define hq_type_node                    global_trees[TI_HQ_TYPE]
4410 #define sq_type_node                    global_trees[TI_SQ_TYPE]
4411 #define dq_type_node                    global_trees[TI_DQ_TYPE]
4412 #define tq_type_node                    global_trees[TI_TQ_TYPE]
4413 #define uqq_type_node                   global_trees[TI_UQQ_TYPE]
4414 #define uhq_type_node                   global_trees[TI_UHQ_TYPE]
4415 #define usq_type_node                   global_trees[TI_USQ_TYPE]
4416 #define udq_type_node                   global_trees[TI_UDQ_TYPE]
4417 #define utq_type_node                   global_trees[TI_UTQ_TYPE]
4418 #define sat_qq_type_node                global_trees[TI_SAT_QQ_TYPE]
4419 #define sat_hq_type_node                global_trees[TI_SAT_HQ_TYPE]
4420 #define sat_sq_type_node                global_trees[TI_SAT_SQ_TYPE]
4421 #define sat_dq_type_node                global_trees[TI_SAT_DQ_TYPE]
4422 #define sat_tq_type_node                global_trees[TI_SAT_TQ_TYPE]
4423 #define sat_uqq_type_node               global_trees[TI_SAT_UQQ_TYPE]
4424 #define sat_uhq_type_node               global_trees[TI_SAT_UHQ_TYPE]
4425 #define sat_usq_type_node               global_trees[TI_SAT_USQ_TYPE]
4426 #define sat_udq_type_node               global_trees[TI_SAT_UDQ_TYPE]
4427 #define sat_utq_type_node               global_trees[TI_SAT_UTQ_TYPE]
4428 #define ha_type_node                    global_trees[TI_HA_TYPE]
4429 #define sa_type_node                    global_trees[TI_SA_TYPE]
4430 #define da_type_node                    global_trees[TI_DA_TYPE]
4431 #define ta_type_node                    global_trees[TI_TA_TYPE]
4432 #define uha_type_node                   global_trees[TI_UHA_TYPE]
4433 #define usa_type_node                   global_trees[TI_USA_TYPE]
4434 #define uda_type_node                   global_trees[TI_UDA_TYPE]
4435 #define uta_type_node                   global_trees[TI_UTA_TYPE]
4436 #define sat_ha_type_node                global_trees[TI_SAT_HA_TYPE]
4437 #define sat_sa_type_node                global_trees[TI_SAT_SA_TYPE]
4438 #define sat_da_type_node                global_trees[TI_SAT_DA_TYPE]
4439 #define sat_ta_type_node                global_trees[TI_SAT_TA_TYPE]
4440 #define sat_uha_type_node               global_trees[TI_SAT_UHA_TYPE]
4441 #define sat_usa_type_node               global_trees[TI_SAT_USA_TYPE]
4442 #define sat_uda_type_node               global_trees[TI_SAT_UDA_TYPE]
4443 #define sat_uta_type_node               global_trees[TI_SAT_UTA_TYPE]
4444
4445 /* The node that should be placed at the end of a parameter list to
4446    indicate that the function does not take a variable number of
4447    arguments.  The TREE_VALUE will be void_type_node and there will be
4448    no TREE_CHAIN.  Language-independent code should not assume
4449    anything else about this node.  */
4450 #define void_list_node                  global_trees[TI_VOID_LIST_NODE]
4451
4452 #define main_identifier_node            global_trees[TI_MAIN_IDENTIFIER]
4453 #define MAIN_NAME_P(NODE) \
4454   (IDENTIFIER_NODE_CHECK (NODE) == main_identifier_node)
4455
4456 /* Optimization options (OPTIMIZATION_NODE) to use for default and current
4457    functions.  */
4458 #define optimization_default_node       global_trees[TI_OPTIMIZATION_DEFAULT]
4459 #define optimization_current_node       global_trees[TI_OPTIMIZATION_CURRENT]
4460
4461 /* Default/current target options (TARGET_OPTION_NODE).  */
4462 #define target_option_default_node      global_trees[TI_TARGET_OPTION_DEFAULT]
4463 #define target_option_current_node      global_trees[TI_TARGET_OPTION_CURRENT]
4464
4465 /* Default tree list option(), optimize() pragmas to be linked into the
4466    attribute list.  */
4467 #define current_target_pragma           global_trees[TI_CURRENT_TARGET_PRAGMA]
4468 #define current_optimize_pragma         global_trees[TI_CURRENT_OPTIMIZE_PRAGMA]
4469
4470 /* SCEV analyzer global shared trees.  */
4471 #define chrec_not_analyzed_yet          NULL_TREE
4472 #define chrec_dont_know                 global_trees[TI_CHREC_DONT_KNOW]
4473 #define chrec_known                     global_trees[TI_CHREC_KNOWN]
4474
4475 #define char_type_node                  integer_types[itk_char]
4476 #define signed_char_type_node           integer_types[itk_signed_char]
4477 #define unsigned_char_type_node         integer_types[itk_unsigned_char]
4478 #define short_integer_type_node         integer_types[itk_short]
4479 #define short_unsigned_type_node        integer_types[itk_unsigned_short]
4480 #define integer_type_node               integer_types[itk_int]
4481 #define unsigned_type_node              integer_types[itk_unsigned_int]
4482 #define long_integer_type_node          integer_types[itk_long]
4483 #define long_unsigned_type_node         integer_types[itk_unsigned_long]
4484 #define long_long_integer_type_node     integer_types[itk_long_long]
4485 #define long_long_unsigned_type_node    integer_types[itk_unsigned_long_long]
4486
4487 /* True if T is an erroneous expression.  */
4488
4489 inline bool
4490 error_operand_p (const_tree t)
4491 {
4492   return (t == error_mark_node
4493           || (t && TREE_TYPE (t) == error_mark_node));
4494 }
4495
4496 /* Return the number of elements encoded directly in a VECTOR_CST.  */
4497
4498 inline unsigned int
4499 vector_cst_encoded_nelts (const_tree t)
4500 {
4501   return VECTOR_CST_NPATTERNS (t) * VECTOR_CST_NELTS_PER_PATTERN (t);
4502 }
4503
4504 extern tree decl_assembler_name (tree);
4505 extern void overwrite_decl_assembler_name (tree decl, tree name);
4506 extern tree decl_comdat_group (const_tree);
4507 extern tree decl_comdat_group_id (const_tree);
4508 extern const char *decl_section_name (const_tree);
4509 extern void set_decl_section_name (tree, const char *);
4510 extern void set_decl_section_name (tree, const_tree);
4511 extern enum tls_model decl_tls_model (const_tree);
4512 extern void set_decl_tls_model (tree, enum tls_model);
4513
4514 /* Compute the number of bytes occupied by 'node'.  This routine only
4515    looks at TREE_CODE and, if the code is TREE_VEC, TREE_VEC_LENGTH.  */
4516
4517 extern size_t tree_size (const_tree);
4518
4519 /* Compute the number of bytes occupied by a tree with code CODE.
4520    This function cannot be used for TREE_VEC or INTEGER_CST nodes,
4521    which are of variable length.  */
4522 extern size_t tree_code_size (enum tree_code);
4523
4524 /* Allocate and return a new UID from the DECL_UID namespace.  */
4525 extern int allocate_decl_uid (void);
4526
4527 /* Lowest level primitive for allocating a node.
4528    The TREE_CODE is the only argument.  Contents are initialized
4529    to zero except for a few of the common fields.  */
4530
4531 extern tree make_node (enum tree_code CXX_MEM_STAT_INFO);
4532
4533 /* Free tree node.  */
4534
4535 extern void free_node (tree);
4536
4537 /* Make a copy of a node, with all the same contents.  */
4538
4539 extern tree copy_node (tree CXX_MEM_STAT_INFO);
4540
4541 /* Make a copy of a chain of TREE_LIST nodes.  */
4542
4543 extern tree copy_list (tree);
4544
4545 /* Make a CASE_LABEL_EXPR.  */
4546
4547 extern tree build_case_label (tree, tree, tree);
4548
4549 /* Make a BINFO.  */
4550 extern tree make_tree_binfo (unsigned CXX_MEM_STAT_INFO);
4551
4552 /* Make an INTEGER_CST.  */
4553
4554 extern tree make_int_cst (int, int CXX_MEM_STAT_INFO);
4555
4556 /* Make a TREE_VEC.  */
4557
4558 extern tree make_tree_vec (int CXX_MEM_STAT_INFO);
4559
4560 /* Grow a TREE_VEC.  */
4561
4562 extern tree grow_tree_vec (tree v, int CXX_MEM_STAT_INFO);
4563
4564 /* Treat a TREE_VEC as a range of trees, e.g.
4565    for (tree e : tree_vec_range (v)) { ... }  */
4566
4567 class tree_vec_range
4568 {
4569   tree v;
4570 public:
4571   tree_vec_range(tree v) : v(v) { }
4572   tree *begin() { return TREE_VEC_BEGIN (v); }
4573   tree *end() { return TREE_VEC_END (v); }
4574 };
4575
4576 /* Construct various types of nodes.  */
4577
4578 extern tree build_nt (enum tree_code, ...);
4579 extern tree build_nt_call_vec (tree, vec<tree, va_gc> *);
4580
4581 extern tree build0 (enum tree_code, tree CXX_MEM_STAT_INFO);
4582 extern tree build1 (enum tree_code, tree, tree CXX_MEM_STAT_INFO);
4583 extern tree build2 (enum tree_code, tree, tree, tree CXX_MEM_STAT_INFO);
4584 extern tree build3 (enum tree_code, tree, tree, tree, tree CXX_MEM_STAT_INFO);
4585 extern tree build4 (enum tree_code, tree, tree, tree, tree,
4586                     tree CXX_MEM_STAT_INFO);
4587 extern tree build5 (enum tree_code, tree, tree, tree, tree, tree,
4588                     tree CXX_MEM_STAT_INFO);
4589
4590 /* _loc versions of build[1-5].  */
4591
4592 static inline tree
4593 build1_loc (location_t loc, enum tree_code code, tree type,
4594             tree arg1 CXX_MEM_STAT_INFO)
4595 {
4596   tree t = build1 (code, type, arg1 PASS_MEM_STAT);
4597   if (CAN_HAVE_LOCATION_P (t))
4598     SET_EXPR_LOCATION (t, loc);
4599   return t;
4600 }
4601
4602 static inline tree
4603 build2_loc (location_t loc, enum tree_code code, tree type, tree arg0,
4604             tree arg1 CXX_MEM_STAT_INFO)
4605 {
4606   tree t = build2 (code, type, arg0, arg1 PASS_MEM_STAT);
4607   if (CAN_HAVE_LOCATION_P (t))
4608     SET_EXPR_LOCATION (t, loc);
4609   return t;
4610 }
4611
4612 static inline tree
4613 build3_loc (location_t loc, enum tree_code code, tree type, tree arg0,
4614             tree arg1, tree arg2 CXX_MEM_STAT_INFO)
4615 {
4616   tree t = build3 (code, type, arg0, arg1, arg2 PASS_MEM_STAT);
4617   if (CAN_HAVE_LOCATION_P (t))
4618     SET_EXPR_LOCATION (t, loc);
4619   return t;
4620 }
4621
4622 static inline tree
4623 build4_loc (location_t loc, enum tree_code code, tree type, tree arg0,
4624             tree arg1, tree arg2, tree arg3 CXX_MEM_STAT_INFO)
4625 {
4626   tree t = build4 (code, type, arg0, arg1, arg2, arg3 PASS_MEM_STAT);
4627   if (CAN_HAVE_LOCATION_P (t))
4628     SET_EXPR_LOCATION (t, loc);
4629   return t;
4630 }
4631
4632 static inline tree
4633 build5_loc (location_t loc, enum tree_code code, tree type, tree arg0,
4634             tree arg1, tree arg2, tree arg3, tree arg4 CXX_MEM_STAT_INFO)
4635 {
4636   tree t = build5 (code, type, arg0, arg1, arg2, arg3,
4637                         arg4 PASS_MEM_STAT);
4638   if (CAN_HAVE_LOCATION_P (t))
4639     SET_EXPR_LOCATION (t, loc);
4640   return t;
4641 }
4642
4643 /* Constructs double_int from tree CST.  */
4644
4645 extern tree double_int_to_tree (tree, double_int);
4646
4647 extern tree wide_int_to_tree (tree type, const poly_wide_int_ref &cst);
4648 extern tree force_fit_type (tree, const poly_wide_int_ref &, int, bool);
4649
4650 /* Create an INT_CST node with a CST value zero extended.  */
4651
4652 /* static inline */
4653 extern tree build_int_cst (tree, poly_int64);
4654 extern tree build_int_cstu (tree type, poly_uint64);
4655 extern tree build_int_cst_type (tree, poly_int64);
4656 extern tree make_vector (unsigned, unsigned CXX_MEM_STAT_INFO);
4657 extern tree build_vector_from_ctor (tree, const vec<constructor_elt, va_gc> *);
4658 extern tree build_vector_from_val (tree, tree);
4659 extern tree build_uniform_cst (tree, tree);
4660 extern tree build_vec_series (tree, tree, tree);
4661 extern tree build_index_vector (tree, poly_uint64, poly_uint64);
4662 extern tree build_vector_a_then_b (tree, unsigned int, tree, tree);
4663 extern void recompute_constructor_flags (tree);
4664 extern void verify_constructor_flags (tree);
4665 extern tree build_constructor (tree, vec<constructor_elt, va_gc> * CXX_MEM_STAT_INFO);
4666 extern tree build_constructor_single (tree, tree, tree);
4667 extern tree build_constructor_from_list (tree, tree);
4668 extern tree build_constructor_from_vec (tree, const vec<tree, va_gc> *);
4669 extern tree build_constructor_va (tree, int, ...);
4670 extern tree build_clobber (tree, enum clobber_kind = CLOBBER_UNDEF);
4671 extern tree build_real_from_int_cst (tree, const_tree);
4672 extern tree build_real_from_wide (tree, const wide_int_ref &, signop);
4673 extern tree build_complex (tree, tree, tree);
4674 extern tree build_complex_inf (tree, bool);
4675 extern tree build_each_one_cst (tree);
4676 extern tree build_one_cst (tree);
4677 extern tree build_minus_one_cst (tree);
4678 extern tree build_all_ones_cst (tree);
4679 extern tree build_zero_cst (tree);
4680 extern tree build_string (unsigned, const char * = NULL);
4681 extern tree build_poly_int_cst (tree, const poly_wide_int_ref &);
4682 extern tree build_tree_list (tree, tree CXX_MEM_STAT_INFO);
4683 extern tree build_tree_list_vec (const vec<tree, va_gc> * CXX_MEM_STAT_INFO);
4684 extern tree build_decl (location_t, enum tree_code,
4685                         tree, tree CXX_MEM_STAT_INFO);
4686 extern tree build_debug_expr_decl (tree type);
4687 extern tree build_fn_decl (const char *, tree);
4688 extern tree build_translation_unit_decl (tree);
4689 extern tree build_block (tree, tree, tree, tree);
4690 extern tree build_empty_stmt (location_t);
4691 extern tree build_omp_clause (location_t, enum omp_clause_code);
4692
4693 extern tree build_vl_exp (enum tree_code, int CXX_MEM_STAT_INFO);
4694
4695 extern tree build_call_nary (tree, tree, int, ...);
4696 extern tree build_call_valist (tree, tree, int, va_list);
4697 #define build_call_array(T1,T2,N,T3)\
4698    build_call_array_loc (UNKNOWN_LOCATION, T1, T2, N, T3)
4699 extern tree build_call_array_loc (location_t, tree, tree, int, const tree *);
4700 extern tree build_call_vec (tree, tree, const vec<tree, va_gc> *);
4701 extern tree build_call_expr_loc_array (location_t, tree, int, tree *);
4702 extern tree build_call_expr_loc_vec (location_t, tree, vec<tree, va_gc> *);
4703 extern tree build_call_expr_loc (location_t, tree, int, ...);
4704 extern tree build_call_expr (tree, int, ...);
4705 extern tree build_call_expr_internal_loc (location_t, enum internal_fn,
4706                                           tree, int, ...);
4707 extern tree build_call_expr_internal_loc_array (location_t, enum internal_fn,
4708                                                 tree, int, const tree *);
4709 extern tree maybe_build_call_expr_loc (location_t, combined_fn, tree,
4710                                        int, ...);
4711 extern tree build_alloca_call_expr (tree, unsigned int, HOST_WIDE_INT);
4712 extern tree build_string_literal (unsigned, const char * = NULL,
4713                                   tree = char_type_node,
4714                                   unsigned HOST_WIDE_INT = HOST_WIDE_INT_M1U);
4715 inline tree build_string_literal (const char *p)
4716 { return build_string_literal (strlen (p) + 1, p); }
4717 inline tree build_string_literal (tree t)
4718 {
4719   return build_string_literal (IDENTIFIER_LENGTH (t) + 1,
4720                                IDENTIFIER_POINTER (t));
4721 }
4722
4723 /* Construct various nodes representing data types.  */
4724
4725 extern tree signed_or_unsigned_type_for (int, tree);
4726 extern tree signed_type_for (tree);
4727 extern tree unsigned_type_for (tree);
4728 extern bool is_truth_type_for (tree, tree);
4729 extern tree truth_type_for (tree);
4730 extern tree build_pointer_type_for_mode (tree, machine_mode, bool);
4731 extern tree build_pointer_type (tree);
4732 extern tree build_reference_type_for_mode (tree, machine_mode, bool);
4733 extern tree build_reference_type (tree);
4734 extern tree build_vector_type_for_mode (tree, machine_mode);
4735 extern tree build_vector_type (tree, poly_int64);
4736 extern tree build_truth_vector_type_for_mode (poly_uint64, machine_mode);
4737 extern tree build_opaque_vector_type (tree, poly_int64);
4738 extern tree build_index_type (tree);
4739 extern tree build_array_type_1 (tree, tree, bool, bool, bool);
4740 extern tree build_array_type (tree, tree, bool = false);
4741 extern tree build_nonshared_array_type (tree, tree);
4742 extern tree build_array_type_nelts (tree, poly_uint64);
4743 extern tree build_function_type (tree, tree, bool = false);
4744 extern tree build_function_type_list (tree, ...);
4745 extern tree build_varargs_function_type_list (tree, ...);
4746 extern tree build_function_type_array (tree, int, tree *);
4747 extern tree build_varargs_function_type_array (tree, int, tree *);
4748 #define build_function_type_vec(RET, V) \
4749   build_function_type_array (RET, vec_safe_length (V), vec_safe_address (V))
4750 #define build_varargs_function_type_vec(RET, V) \
4751   build_varargs_function_type_array (RET, vec_safe_length (V), \
4752                                      vec_safe_address (V))
4753 extern tree build_method_type_directly (tree, tree, tree);
4754 extern tree build_method_type (tree, tree);
4755 extern tree build_offset_type (tree, tree);
4756 extern tree build_complex_type (tree, bool named = false);
4757 extern tree array_type_nelts (const_tree);
4758
4759 extern tree value_member (tree, tree);
4760 extern tree purpose_member (const_tree, tree);
4761 extern bool vec_member (const_tree, vec<tree, va_gc> *);
4762 extern tree chain_index (int, tree);
4763
4764 /* Arguments may be null.  */
4765 extern int tree_int_cst_equal (const_tree, const_tree);
4766
4767 /* The following predicates are safe to call with a null argument.  */
4768 extern bool tree_fits_shwi_p (const_tree) ATTRIBUTE_PURE;
4769 extern bool tree_fits_poly_int64_p (const_tree) ATTRIBUTE_PURE;
4770 extern bool tree_fits_uhwi_p (const_tree) ATTRIBUTE_PURE;
4771 extern bool tree_fits_poly_uint64_p (const_tree) ATTRIBUTE_PURE;
4772
4773 extern HOST_WIDE_INT tree_to_shwi (const_tree)
4774   ATTRIBUTE_NONNULL (1) ATTRIBUTE_PURE;
4775 extern poly_int64 tree_to_poly_int64 (const_tree)
4776   ATTRIBUTE_NONNULL (1) ATTRIBUTE_PURE;
4777 extern unsigned HOST_WIDE_INT tree_to_uhwi (const_tree)
4778   ATTRIBUTE_NONNULL (1) ATTRIBUTE_PURE;
4779 extern poly_uint64 tree_to_poly_uint64 (const_tree)
4780   ATTRIBUTE_NONNULL (1) ATTRIBUTE_PURE;
4781 #if !defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 4003)
4782 extern inline __attribute__ ((__gnu_inline__)) HOST_WIDE_INT
4783 tree_to_shwi (const_tree t)
4784 {
4785   gcc_assert (tree_fits_shwi_p (t));
4786   return TREE_INT_CST_LOW (t);
4787 }
4788
4789 extern inline __attribute__ ((__gnu_inline__)) unsigned HOST_WIDE_INT
4790 tree_to_uhwi (const_tree t)
4791 {
4792   gcc_assert (tree_fits_uhwi_p (t));
4793   return TREE_INT_CST_LOW (t);
4794 }
4795 #if NUM_POLY_INT_COEFFS == 1
4796 extern inline __attribute__ ((__gnu_inline__)) poly_int64
4797 tree_to_poly_int64 (const_tree t)
4798 {
4799   gcc_assert (tree_fits_poly_int64_p (t));
4800   return TREE_INT_CST_LOW (t);
4801 }
4802
4803 extern inline __attribute__ ((__gnu_inline__)) poly_uint64
4804 tree_to_poly_uint64 (const_tree t)
4805 {
4806   gcc_assert (tree_fits_poly_uint64_p (t));
4807   return TREE_INT_CST_LOW (t);
4808 }
4809 #endif
4810 #endif
4811 extern int tree_int_cst_sgn (const_tree);
4812 extern int tree_int_cst_sign_bit (const_tree);
4813 extern unsigned int tree_int_cst_min_precision (tree, signop);
4814 extern tree strip_array_types (tree);
4815 extern tree excess_precision_type (tree);
4816
4817 /* Desription of the reason why the argument of valid_constant_size_p
4818    is not a valid size.  */
4819 enum cst_size_error {
4820   cst_size_ok,
4821   cst_size_not_constant,
4822   cst_size_negative,
4823   cst_size_too_big,
4824   cst_size_overflow
4825 };
4826
4827 extern bool valid_constant_size_p (const_tree, cst_size_error * = NULL);
4828 extern tree max_object_size ();
4829
4830 /* Return true if T holds a value that can be represented as a poly_int64
4831    without loss of precision.  Store the value in *VALUE if so.  */
4832
4833 inline bool
4834 poly_int_tree_p (const_tree t, poly_int64_pod *value)
4835 {
4836   if (tree_fits_poly_int64_p (t))
4837     {
4838       *value = tree_to_poly_int64 (t);
4839       return true;
4840     }
4841   return false;
4842 }
4843
4844 /* Return true if T holds a value that can be represented as a poly_uint64
4845    without loss of precision.  Store the value in *VALUE if so.  */
4846
4847 inline bool
4848 poly_int_tree_p (const_tree t, poly_uint64_pod *value)
4849 {
4850   if (tree_fits_poly_uint64_p (t))
4851     {
4852       *value = tree_to_poly_uint64 (t);
4853       return true;
4854     }
4855   return false;
4856 }
4857
4858 /* From expmed.cc.  Since rtl.h is included after tree.h, we can't
4859    put the prototype here.  Rtl.h does declare the prototype if
4860    tree.h had been included.  */
4861
4862 extern tree make_tree (tree, rtx);
4863
4864 /* Returns true iff CAND and BASE have equivalent language-specific
4865    qualifiers.  */
4866
4867 extern bool check_lang_type (const_tree cand, const_tree base);
4868
4869 /* Returns true iff unqualified CAND and BASE are equivalent.  */
4870
4871 extern bool check_base_type (const_tree cand, const_tree base);
4872
4873 /* Check whether CAND is suitable to be returned from get_qualified_type
4874    (BASE, TYPE_QUALS).  */
4875
4876 extern bool check_qualified_type (const_tree, const_tree, int);
4877
4878 /* Return a version of the TYPE, qualified as indicated by the
4879    TYPE_QUALS, if one exists.  If no qualified version exists yet,
4880    return NULL_TREE.  */
4881
4882 extern tree get_qualified_type (tree, int);
4883
4884 /* Like get_qualified_type, but creates the type if it does not
4885    exist.  This function never returns NULL_TREE.  */
4886
4887 extern tree build_qualified_type (tree, int CXX_MEM_STAT_INFO);
4888
4889 /* Create a variant of type T with alignment ALIGN.  */
4890
4891 extern tree build_aligned_type (tree, unsigned int);
4892
4893 /* Like build_qualified_type, but only deals with the `const' and
4894    `volatile' qualifiers.  This interface is retained for backwards
4895    compatibility with the various front-ends; new code should use
4896    build_qualified_type instead.  */
4897
4898 #define build_type_variant(TYPE, CONST_P, VOLATILE_P)                   \
4899   build_qualified_type ((TYPE),                                         \
4900                         ((CONST_P) ? TYPE_QUAL_CONST : 0)               \
4901                         | ((VOLATILE_P) ? TYPE_QUAL_VOLATILE : 0))
4902
4903 /* Make a copy of a type node.  */
4904
4905 extern tree build_distinct_type_copy (tree CXX_MEM_STAT_INFO);
4906 extern tree build_variant_type_copy (tree CXX_MEM_STAT_INFO);
4907
4908 /* Given a hashcode and a ..._TYPE node (for which the hashcode was made),
4909    return a canonicalized ..._TYPE node, so that duplicates are not made.
4910    How the hash code is computed is up to the caller, as long as any two
4911    callers that could hash identical-looking type nodes agree.  */
4912
4913 extern hashval_t type_hash_canon_hash (tree);
4914 extern tree type_hash_canon (unsigned int, tree);
4915
4916 extern tree convert (tree, tree);
4917 extern tree size_in_bytes_loc (location_t, const_tree);
4918 inline tree
4919 size_in_bytes (const_tree t)
4920 {
4921   return size_in_bytes_loc (input_location, t);
4922 }
4923
4924 extern HOST_WIDE_INT int_size_in_bytes (const_tree);
4925 extern HOST_WIDE_INT max_int_size_in_bytes (const_tree);
4926 extern tree bit_position (const_tree);
4927 extern tree byte_position (const_tree);
4928 extern HOST_WIDE_INT int_byte_position (const_tree);
4929
4930 /* Type for sizes of data-type.  */
4931
4932 #define sizetype sizetype_tab[(int) stk_sizetype]
4933 #define bitsizetype sizetype_tab[(int) stk_bitsizetype]
4934 #define ssizetype sizetype_tab[(int) stk_ssizetype]
4935 #define sbitsizetype sizetype_tab[(int) stk_sbitsizetype]
4936 #define size_int(L) size_int_kind (L, stk_sizetype)
4937 #define ssize_int(L) size_int_kind (L, stk_ssizetype)
4938 #define bitsize_int(L) size_int_kind (L, stk_bitsizetype)
4939 #define sbitsize_int(L) size_int_kind (L, stk_sbitsizetype)
4940
4941 /* Log2 of BITS_PER_UNIT.  */
4942
4943 #if BITS_PER_UNIT == 8
4944 #define LOG2_BITS_PER_UNIT 3
4945 #elif BITS_PER_UNIT == 16
4946 #define LOG2_BITS_PER_UNIT 4
4947 #else
4948 #error Unknown BITS_PER_UNIT
4949 #endif
4950
4951 /* Concatenate two lists (chains of TREE_LIST nodes) X and Y
4952    by making the last node in X point to Y.
4953    Returns X, except if X is 0 returns Y.  */
4954
4955 extern tree chainon (tree, tree);
4956
4957 /* Make a new TREE_LIST node from specified PURPOSE, VALUE and CHAIN.  */
4958
4959 extern tree tree_cons (tree, tree, tree CXX_MEM_STAT_INFO);
4960
4961 /* Return the last tree node in a chain.  */
4962
4963 extern tree tree_last (tree);
4964
4965 /* Reverse the order of elements in a chain, and return the new head.  */
4966
4967 extern tree nreverse (tree);
4968
4969 /* Returns the length of a chain of nodes
4970    (number of chain pointers to follow before reaching a null pointer).  */
4971
4972 extern int list_length (const_tree);
4973
4974 /* Returns the first/last FIELD_DECL in a RECORD_TYPE.  */
4975
4976 extern tree first_field (const_tree) ATTRIBUTE_NONNULL (1);
4977 extern tree last_field (const_tree) ATTRIBUTE_NONNULL (1);
4978
4979 /* Given an initializer INIT, return TRUE if INIT is zero or some
4980    aggregate of zeros.  Otherwise return FALSE.  If NONZERO is not
4981    null, set *NONZERO if and only if INIT is known not to be all
4982    zeros.  The combination of return value of false and *NONZERO
4983    false implies that INIT may but need not be all zeros.  Other
4984    combinations indicate definitive answers.  */
4985
4986 extern bool initializer_zerop (const_tree, bool * = NULL);
4987 extern bool initializer_each_zero_or_onep (const_tree);
4988
4989 extern tree vector_cst_elt (const_tree, unsigned int);
4990
4991 /* Given a vector VEC, return its first element if all elements are
4992    the same.  Otherwise return NULL_TREE.  */
4993
4994 extern tree uniform_vector_p (const_tree);
4995
4996 /* If the argument is INTEGER_CST, return it.  If the argument is vector
4997    with all elements the same INTEGER_CST, return that INTEGER_CST.  Otherwise
4998    return NULL_TREE.  */
4999
5000 extern tree uniform_integer_cst_p (tree);
5001
5002 extern int single_nonzero_element (const_tree);
5003
5004 /* Given a CONSTRUCTOR CTOR, return the element values as a vector.  */
5005
5006 extern vec<tree, va_gc> *ctor_to_vec (tree);
5007
5008 /* zerop (tree x) is nonzero if X is a constant of value 0.  */
5009
5010 extern bool zerop (const_tree);
5011
5012 /* integer_zerop (tree x) is nonzero if X is an integer constant of value 0.  */
5013
5014 extern bool integer_zerop (const_tree);
5015
5016 /* integer_onep (tree x) is nonzero if X is an integer constant of value 1.  */
5017
5018 extern bool integer_onep (const_tree);
5019
5020 /* integer_onep (tree x) is nonzero if X is an integer constant of value 1, or
5021    a vector or complex where each part is 1.  */
5022
5023 extern bool integer_each_onep (const_tree);
5024
5025 /* integer_all_onesp (tree x) is nonzero if X is an integer constant
5026    all of whose significant bits are 1.  */
5027
5028 extern bool integer_all_onesp (const_tree);
5029
5030 /* integer_minus_onep (tree x) is nonzero if X is an integer constant of
5031    value -1.  */
5032
5033 extern bool integer_minus_onep (const_tree);
5034
5035 /* integer_pow2p (tree x) is nonzero is X is an integer constant with
5036    exactly one bit 1.  */
5037
5038 extern bool integer_pow2p (const_tree);
5039
5040 /* Checks to see if T is a constant or a constant vector and if each element E
5041    adheres to ~E + 1 == pow2 then return ~E otherwise NULL_TREE.  */
5042
5043 extern tree bitmask_inv_cst_vector_p (tree);
5044
5045 /* integer_nonzerop (tree x) is nonzero if X is an integer constant
5046    with a nonzero value.  */
5047
5048 extern bool integer_nonzerop (const_tree);
5049
5050 /* integer_truep (tree x) is nonzero if X is an integer constant of value 1 or
5051    a vector where each element is an integer constant of value -1.  */
5052
5053 extern bool integer_truep (const_tree);
5054
5055 extern bool cst_and_fits_in_hwi (const_tree);
5056 extern tree num_ending_zeros (const_tree);
5057
5058 /* fixed_zerop (tree x) is nonzero if X is a fixed-point constant of
5059    value 0.  */
5060
5061 extern bool fixed_zerop (const_tree);
5062
5063 /* staticp (tree x) is nonzero if X is a reference to data allocated
5064    at a fixed address in memory.  Returns the outermost data.  */
5065
5066 extern tree staticp (tree);
5067
5068 /* save_expr (EXP) returns an expression equivalent to EXP
5069    but it can be used multiple times within context CTX
5070    and only evaluate EXP once.  */
5071
5072 extern tree save_expr (tree);
5073
5074 /* Return true if T is function-invariant.  */
5075
5076 extern bool tree_invariant_p (tree);
5077
5078 /* Look inside EXPR into any simple arithmetic operations.  Return the
5079    outermost non-arithmetic or non-invariant node.  */
5080
5081 extern tree skip_simple_arithmetic (tree);
5082
5083 /* Look inside EXPR into simple arithmetic operations involving constants.
5084    Return the outermost non-arithmetic or non-constant node.  */
5085
5086 extern tree skip_simple_constant_arithmetic (tree);
5087
5088 /* Return which tree structure is used by T.  */
5089
5090 enum tree_node_structure_enum tree_node_structure (const_tree);
5091
5092 /* Return true if EXP contains a PLACEHOLDER_EXPR, i.e. if it represents a
5093    size or offset that depends on a field within a record.  */
5094
5095 extern bool contains_placeholder_p (const_tree);
5096
5097 /* This macro calls the above function but short-circuits the common
5098    case of a constant to save time.  Also check for null.  */
5099
5100 #define CONTAINS_PLACEHOLDER_P(EXP) \
5101   ((EXP) != 0 && ! TREE_CONSTANT (EXP) && contains_placeholder_p (EXP))
5102
5103 /* Return true if any part of the structure of TYPE involves a PLACEHOLDER_EXPR
5104    directly.  This includes size, bounds, qualifiers (for QUAL_UNION_TYPE) and
5105    field positions.  */
5106
5107 extern bool type_contains_placeholder_p (tree);
5108
5109 /* Given a tree EXP, find all occurrences of references to fields
5110    in a PLACEHOLDER_EXPR and place them in vector REFS without
5111    duplicates.  Also record VAR_DECLs and CONST_DECLs.  Note that
5112    we assume here that EXP contains only arithmetic expressions
5113    or CALL_EXPRs with PLACEHOLDER_EXPRs occurring only in their
5114    argument list.  */
5115
5116 extern void find_placeholder_in_expr (tree, vec<tree> *);
5117
5118 /* This macro calls the above function but short-circuits the common
5119    case of a constant to save time and also checks for NULL.  */
5120
5121 #define FIND_PLACEHOLDER_IN_EXPR(EXP, V) \
5122 do {                                     \
5123   if((EXP) && !TREE_CONSTANT (EXP))      \
5124     find_placeholder_in_expr (EXP, V);   \
5125 } while (0)
5126
5127 /* Given a tree EXP, a FIELD_DECL F, and a replacement value R,
5128    return a tree with all occurrences of references to F in a
5129    PLACEHOLDER_EXPR replaced by R.  Also handle VAR_DECLs and
5130    CONST_DECLs.  Note that we assume here that EXP contains only
5131    arithmetic expressions or CALL_EXPRs with PLACEHOLDER_EXPRs
5132    occurring only in their argument list.  */
5133
5134 extern tree substitute_in_expr (tree, tree, tree);
5135
5136 /* This macro calls the above function but short-circuits the common
5137    case of a constant to save time and also checks for NULL.  */
5138
5139 #define SUBSTITUTE_IN_EXPR(EXP, F, R) \
5140   ((EXP) == 0 || TREE_CONSTANT (EXP) ? (EXP) : substitute_in_expr (EXP, F, R))
5141
5142 /* Similar, but look for a PLACEHOLDER_EXPR in EXP and find a replacement
5143    for it within OBJ, a tree that is an object or a chain of references.  */
5144
5145 extern tree substitute_placeholder_in_expr (tree, tree);
5146
5147 /* This macro calls the above function but short-circuits the common
5148    case of a constant to save time and also checks for NULL.  */
5149
5150 #define SUBSTITUTE_PLACEHOLDER_IN_EXPR(EXP, OBJ) \
5151   ((EXP) == 0 || TREE_CONSTANT (EXP) ? (EXP)    \
5152    : substitute_placeholder_in_expr (EXP, OBJ))
5153
5154
5155 /* stabilize_reference (EXP) returns a reference equivalent to EXP
5156    but it can be used multiple times
5157    and only evaluate the subexpressions once.  */
5158
5159 extern tree stabilize_reference (tree);
5160
5161 /* Return EXP, stripped of any conversions to wider types
5162    in such a way that the result of converting to type FOR_TYPE
5163    is the same as if EXP were converted to FOR_TYPE.
5164    If FOR_TYPE is 0, it signifies EXP's type.  */
5165
5166 extern tree get_unwidened (tree, tree);
5167
5168 /* Return OP or a simpler expression for a narrower value
5169    which can be sign-extended or zero-extended to give back OP.
5170    Store in *UNSIGNEDP_PTR either 1 if the value should be zero-extended
5171    or 0 if the value should be sign-extended.  */
5172
5173 extern tree get_narrower (tree, int *);
5174
5175 /* Return true if T is an expression that get_inner_reference handles.  */
5176
5177 static inline bool
5178 handled_component_p (const_tree t)
5179 {
5180   switch (TREE_CODE (t))
5181     {
5182     case COMPONENT_REF:
5183     case BIT_FIELD_REF:
5184     case ARRAY_REF:
5185     case ARRAY_RANGE_REF:
5186     case REALPART_EXPR:
5187     case IMAGPART_EXPR:
5188     case VIEW_CONVERT_EXPR:
5189       return true;
5190
5191     default:
5192       return false;
5193     }
5194 }
5195
5196 /* Return true T is a component with reverse storage order.  */
5197
5198 static inline bool
5199 reverse_storage_order_for_component_p (tree t)
5200 {
5201   /* The storage order only applies to scalar components.  */
5202   if (AGGREGATE_TYPE_P (TREE_TYPE (t))
5203       || POINTER_TYPE_P (TREE_TYPE (t))
5204       || VECTOR_TYPE_P (TREE_TYPE (t)))
5205     return false;
5206
5207   if (TREE_CODE (t) == REALPART_EXPR || TREE_CODE (t) == IMAGPART_EXPR)
5208     t = TREE_OPERAND (t, 0);
5209
5210   switch (TREE_CODE (t))
5211     {
5212     case ARRAY_REF:
5213     case COMPONENT_REF:
5214       /* ??? Fortran can take COMPONENT_REF of a VOID_TYPE.  */
5215       /* ??? UBSan can take COMPONENT_REF of a REFERENCE_TYPE.  */
5216       return AGGREGATE_TYPE_P (TREE_TYPE (TREE_OPERAND (t, 0)))
5217              && TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (TREE_OPERAND (t, 0)));
5218
5219     case BIT_FIELD_REF:
5220     case MEM_REF:
5221       return REF_REVERSE_STORAGE_ORDER (t);
5222
5223     case ARRAY_RANGE_REF:
5224     case VIEW_CONVERT_EXPR:
5225     default:
5226       return false;
5227     }
5228 }
5229
5230 /* Return true if T is a storage order barrier, i.e. a VIEW_CONVERT_EXPR
5231    that can modify the storage order of objects.  Note that, even if the
5232    TYPE_REVERSE_STORAGE_ORDER flag is set on both the inner type and the
5233    outer type, a VIEW_CONVERT_EXPR can modify the storage order because
5234    it can change the partition of the aggregate object into scalars.  */
5235
5236 static inline bool
5237 storage_order_barrier_p (const_tree t)
5238 {
5239   if (TREE_CODE (t) != VIEW_CONVERT_EXPR)
5240     return false;
5241
5242   if (AGGREGATE_TYPE_P (TREE_TYPE (t))
5243       && TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (t)))
5244     return true;
5245
5246   tree op = TREE_OPERAND (t, 0);
5247
5248   if (AGGREGATE_TYPE_P (TREE_TYPE (op))
5249       && TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (op)))
5250     return true;
5251
5252   return false;
5253 }
5254
5255 /* Given a DECL or TYPE, return the scope in which it was declared, or
5256    NUL_TREE if there is no containing scope.  */
5257
5258 extern tree get_containing_scope (const_tree);
5259
5260 /* Returns the ultimate TRANSLATION_UNIT_DECL context of DECL or NULL.  */
5261
5262 extern const_tree get_ultimate_context (const_tree);
5263
5264 /* Return the FUNCTION_DECL which provides this _DECL with its context,
5265    or zero if none.  */
5266 extern tree decl_function_context (const_tree);
5267
5268 /* Return the RECORD_TYPE, UNION_TYPE, or QUAL_UNION_TYPE which provides
5269    this _DECL with its context, or zero if none.  */
5270 extern tree decl_type_context (const_tree);
5271
5272 /* Return true if EXPR is the real constant zero.  */
5273 extern bool real_zerop (const_tree);
5274
5275 /* Initialize the iterator I with arguments from function FNDECL  */
5276
5277 static inline void
5278 function_args_iter_init (function_args_iterator *i, const_tree fntype)
5279 {
5280   i->next = TYPE_ARG_TYPES (fntype);
5281 }
5282
5283 /* Return a pointer that holds the next argument if there are more arguments to
5284    handle, otherwise return NULL.  */
5285
5286 static inline tree *
5287 function_args_iter_cond_ptr (function_args_iterator *i)
5288 {
5289   return (i->next) ? &TREE_VALUE (i->next) : NULL;
5290 }
5291
5292 /* Return the next argument if there are more arguments to handle, otherwise
5293    return NULL.  */
5294
5295 static inline tree
5296 function_args_iter_cond (function_args_iterator *i)
5297 {
5298   return (i->next) ? TREE_VALUE (i->next) : NULL_TREE;
5299 }
5300
5301 /* Advance to the next argument.  */
5302 static inline void
5303 function_args_iter_next (function_args_iterator *i)
5304 {
5305   gcc_assert (i->next != NULL_TREE);
5306   i->next = TREE_CHAIN (i->next);
5307 }
5308
5309 /* Returns true if a BLOCK has a source location.
5310    BLOCK_SOURCE_LOCATION is set only to inlined function entry points,
5311    so the function returns true for all but the innermost and outermost
5312    blocks into which an expression has been inlined.  */
5313
5314 static inline bool
5315 inlined_function_outer_scope_p (const_tree block)
5316 {
5317  return LOCATION_LOCUS (BLOCK_SOURCE_LOCATION (block)) != UNKNOWN_LOCATION;
5318 }
5319
5320 /* Loop over all function arguments of FNTYPE.  In each iteration, PTR is set
5321    to point to the next tree element.  ITER is an instance of
5322    function_args_iterator used to iterate the arguments.  */
5323 #define FOREACH_FUNCTION_ARGS_PTR(FNTYPE, PTR, ITER)                    \
5324   for (function_args_iter_init (&(ITER), (FNTYPE));                     \
5325        (PTR = function_args_iter_cond_ptr (&(ITER))) != NULL;           \
5326        function_args_iter_next (&(ITER)))
5327
5328 /* Loop over all function arguments of FNTYPE.  In each iteration, TREE is set
5329    to the next tree element.  ITER is an instance of function_args_iterator
5330    used to iterate the arguments.  */
5331 #define FOREACH_FUNCTION_ARGS(FNTYPE, TREE, ITER)                       \
5332   for (function_args_iter_init (&(ITER), (FNTYPE));                     \
5333        (TREE = function_args_iter_cond (&(ITER))) != NULL_TREE;         \
5334        function_args_iter_next (&(ITER)))
5335
5336 /* In tree.cc */
5337 extern unsigned crc32_unsigned_n (unsigned, unsigned, unsigned);
5338 extern unsigned crc32_string (unsigned, const char *);
5339 inline unsigned
5340 crc32_unsigned (unsigned chksum, unsigned value)
5341 {
5342   return crc32_unsigned_n (chksum, value, 4);
5343 }
5344 inline unsigned
5345 crc32_byte (unsigned chksum, char byte)
5346 {
5347   return crc32_unsigned_n (chksum, byte, 1);
5348 }
5349 extern void clean_symbol_name (char *);
5350 extern tree get_file_function_name (const char *);
5351 extern tree get_callee_fndecl (const_tree);
5352 extern combined_fn get_call_combined_fn (const_tree);
5353 extern int type_num_arguments (const_tree);
5354 extern tree type_argument_type (const_tree, unsigned) ATTRIBUTE_NONNULL (1);
5355 extern bool associative_tree_code (enum tree_code);
5356 extern bool commutative_tree_code (enum tree_code);
5357 extern bool commutative_ternary_tree_code (enum tree_code);
5358 extern bool operation_can_overflow (enum tree_code);
5359 extern bool operation_no_trapping_overflow (tree, enum tree_code);
5360 extern tree upper_bound_in_type (tree, tree);
5361 extern tree lower_bound_in_type (tree, tree);
5362 extern int operand_equal_for_phi_arg_p (const_tree, const_tree);
5363 extern tree create_artificial_label (location_t);
5364 extern const char *get_name (tree);
5365 extern bool stdarg_p (const_tree);
5366 extern bool prototype_p (const_tree);
5367 extern bool is_typedef_decl (const_tree x);
5368 extern bool typedef_variant_p (const_tree);
5369 extern bool auto_var_p (const_tree);
5370 extern bool auto_var_in_fn_p (const_tree, const_tree);
5371 extern tree build_low_bits_mask (tree, unsigned);
5372 extern bool tree_nop_conversion_p (const_tree, const_tree);
5373 extern tree tree_strip_nop_conversions (tree);
5374 extern tree tree_strip_sign_nop_conversions (tree);
5375 extern const_tree strip_invariant_refs (const_tree);
5376 extern tree lhd_gcc_personality (void);
5377 extern void assign_assembler_name_if_needed (tree);
5378 extern bool warn_deprecated_use (tree, tree);
5379 extern void error_unavailable_use (tree, tree);
5380 extern tree cache_integer_cst (tree, bool might_duplicate = false);
5381 extern const char *combined_fn_name (combined_fn);
5382
5383 /* Compare and hash for any structure which begins with a canonical
5384    pointer.  Assumes all pointers are interchangeable, which is sort
5385    of already assumed by gcc elsewhere IIRC.  */
5386
5387 static inline int
5388 struct_ptr_eq (const void *a, const void *b)
5389 {
5390   const void * const * x = (const void * const *) a;
5391   const void * const * y = (const void * const *) b;
5392   return *x == *y;
5393 }
5394
5395 static inline hashval_t
5396 struct_ptr_hash (const void *a)
5397 {
5398   const void * const * x = (const void * const *) a;
5399   return (intptr_t)*x >> 4;
5400 }
5401
5402 /* Return nonzero if CODE is a tree code that represents a truth value.  */
5403 static inline bool
5404 truth_value_p (enum tree_code code)
5405 {
5406   return (TREE_CODE_CLASS (code) == tcc_comparison
5407           || code == TRUTH_AND_EXPR || code == TRUTH_ANDIF_EXPR
5408           || code == TRUTH_OR_EXPR || code == TRUTH_ORIF_EXPR
5409           || code == TRUTH_XOR_EXPR || code == TRUTH_NOT_EXPR);
5410 }
5411
5412 /* Return whether TYPE is a type suitable for an offset for
5413    a POINTER_PLUS_EXPR.  */
5414 static inline bool
5415 ptrofftype_p (tree type)
5416 {
5417   return (INTEGRAL_TYPE_P (type)
5418           && TYPE_PRECISION (type) == TYPE_PRECISION (sizetype)
5419           && TYPE_UNSIGNED (type) == TYPE_UNSIGNED (sizetype));
5420 }
5421
5422 /* Return true if the argument is a complete type or an array
5423    of unknown bound (whose type is incomplete but) whose elements
5424    have complete type.  */
5425 static inline bool
5426 complete_or_array_type_p (const_tree type)
5427 {
5428   return COMPLETE_TYPE_P (type)
5429          || (TREE_CODE (type) == ARRAY_TYPE
5430              && COMPLETE_TYPE_P (TREE_TYPE (type)));
5431 }
5432
5433 /* Return true if the value of T could be represented as a poly_widest_int.  */
5434
5435 inline bool
5436 poly_int_tree_p (const_tree t)
5437 {
5438   return (TREE_CODE (t) == INTEGER_CST || POLY_INT_CST_P (t));
5439 }
5440
5441 /* Return the bit size of BIT_FIELD_REF T, in cases where it is known
5442    to be a poly_uint64.  (This is always true at the gimple level.)  */
5443
5444 inline poly_uint64
5445 bit_field_size (const_tree t)
5446 {
5447   return tree_to_poly_uint64 (TREE_OPERAND (t, 1));
5448 }
5449
5450 /* Return the starting bit offset of BIT_FIELD_REF T, in cases where it is
5451    known to be a poly_uint64.  (This is always true at the gimple level.)  */
5452
5453 inline poly_uint64
5454 bit_field_offset (const_tree t)
5455 {
5456   return tree_to_poly_uint64 (TREE_OPERAND (t, 2));
5457 }
5458
5459 extern tree strip_float_extensions (tree);
5460 extern bool really_constant_p (const_tree);
5461 extern bool ptrdiff_tree_p (const_tree, poly_int64_pod *);
5462 extern bool decl_address_invariant_p (const_tree);
5463 extern bool decl_address_ip_invariant_p (const_tree);
5464 extern bool int_fits_type_p (const_tree, const_tree)
5465   ATTRIBUTE_NONNULL (1) ATTRIBUTE_NONNULL (2) ATTRIBUTE_PURE;
5466 #ifndef GENERATOR_FILE
5467 extern void get_type_static_bounds (const_tree, mpz_t, mpz_t);
5468 #endif
5469 extern bool variably_modified_type_p (tree, tree);
5470 extern int tree_log2 (const_tree);
5471 extern int tree_floor_log2 (const_tree);
5472 extern unsigned int tree_ctz (const_tree);
5473 extern int simple_cst_equal (const_tree, const_tree);
5474
5475 namespace inchash
5476 {
5477
5478 extern void add_expr (const_tree, hash &, unsigned int = 0);
5479
5480 }
5481
5482 /* Compat version until all callers are converted. Return hash for
5483    TREE with SEED.  */
5484 static inline hashval_t iterative_hash_expr(const_tree tree, hashval_t seed)
5485 {
5486   inchash::hash hstate (seed);
5487   inchash::add_expr (tree, hstate);
5488   return hstate.end ();
5489 }
5490
5491 extern int compare_tree_int (const_tree, unsigned HOST_WIDE_INT);
5492 extern bool type_list_equal (const_tree, const_tree);
5493 extern bool chain_member (const_tree, const_tree);
5494 extern void dump_tree_statistics (void);
5495 extern void recompute_tree_invariant_for_addr_expr (tree);
5496 extern bool needs_to_live_in_memory (const_tree);
5497 extern tree reconstruct_complex_type (tree, tree);
5498 extern bool real_onep (const_tree);
5499 extern bool real_minus_onep (const_tree);
5500 extern void init_ttree (void);
5501 extern void build_common_tree_nodes (bool);
5502 extern void build_common_builtin_nodes (void);
5503 extern void tree_cc_finalize (void);
5504 extern tree build_nonstandard_integer_type (unsigned HOST_WIDE_INT, int);
5505 extern tree build_nonstandard_boolean_type (unsigned HOST_WIDE_INT);
5506 extern tree build_range_type (tree, tree, tree);
5507 extern tree build_nonshared_range_type (tree, tree, tree);
5508 extern bool subrange_type_for_debug_p (const_tree, tree *, tree *);
5509 extern HOST_WIDE_INT int_cst_value (const_tree);
5510 extern tree tree_block (tree);
5511 extern void tree_set_block (tree, tree);
5512 extern location_t *block_nonartificial_location (tree);
5513 extern location_t tree_nonartificial_location (tree);
5514 extern location_t tree_inlined_location (tree, bool = true);
5515 extern tree block_ultimate_origin (const_tree);
5516 extern tree get_binfo_at_offset (tree, poly_int64, tree);
5517 extern bool virtual_method_call_p (const_tree, bool = false);
5518 extern tree obj_type_ref_class (const_tree ref, bool = false);
5519 extern bool types_same_for_odr (const_tree type1, const_tree type2);
5520 extern bool contains_bitfld_component_ref_p (const_tree);
5521 extern bool block_may_fallthru (const_tree);
5522 extern void using_eh_for_cleanups (void);
5523 extern bool using_eh_for_cleanups_p (void);
5524 extern const char *get_tree_code_name (enum tree_code);
5525 extern void set_call_expr_flags (tree, int);
5526 extern tree walk_tree_1 (tree*, walk_tree_fn, void*, hash_set<tree>*,
5527                          walk_tree_lh);
5528 extern tree walk_tree_without_duplicates_1 (tree*, walk_tree_fn, void*,
5529                                             walk_tree_lh);
5530 #define walk_tree(a,b,c,d) \
5531         walk_tree_1 (a, b, c, d, NULL)
5532 #define walk_tree_without_duplicates(a,b,c) \
5533         walk_tree_without_duplicates_1 (a, b, c, NULL)
5534
5535 extern tree drop_tree_overflow (tree);
5536
5537 /* Given a memory reference expression T, return its base address.
5538    The base address of a memory reference expression is the main
5539    object being referenced.  */
5540 extern tree get_base_address (tree t);
5541
5542 /* Return a tree of sizetype representing the size, in bytes, of the element
5543    of EXP, an ARRAY_REF or an ARRAY_RANGE_REF.  */
5544 extern tree array_ref_element_size (tree);
5545
5546 /* Return a typenode for the "standard" C type with a given name.  */
5547 extern tree get_typenode_from_name (const char *);
5548
5549 /* Return a tree representing the upper bound of the array mentioned in
5550    EXP, an ARRAY_REF or an ARRAY_RANGE_REF.  */
5551 extern tree array_ref_up_bound (tree);
5552
5553 /* Return a tree representing the lower bound of the array mentioned in
5554    EXP, an ARRAY_REF or an ARRAY_RANGE_REF.  */
5555 extern tree array_ref_low_bound (tree);
5556
5557 /* Returns true if REF is an array reference, a component reference,
5558    or a memory reference to an array whose actual size might be larger
5559    than its upper bound implies.  */
5560 extern bool array_ref_flexible_size_p (tree);
5561
5562 /* Return a tree representing the offset, in bytes, of the field referenced
5563    by EXP.  This does not include any offset in DECL_FIELD_BIT_OFFSET.  */
5564 extern tree component_ref_field_offset (tree);
5565
5566 /* Describes a "special" array member due to which component_ref_size
5567    returns null.  */
5568 enum struct special_array_member
5569   {
5570     none,       /* Not a special array member.  */
5571     int_0,      /* Interior array member with size zero.  */
5572     trail_0,    /* Trailing array member with size zero.  */
5573     trail_1     /* Trailing array member with one element.  */
5574   };
5575
5576 /* Return the size of the member referenced by the COMPONENT_REF, using
5577    its initializer expression if necessary in order to determine the size
5578    of an initialized flexible array member.  The size might be zero for
5579    an object with an uninitialized flexible array member or null if it
5580    cannot be determined.  */
5581 extern tree component_ref_size (tree, special_array_member * = NULL);
5582
5583 extern int tree_map_base_eq (const void *, const void *);
5584 extern unsigned int tree_map_base_hash (const void *);
5585 extern int tree_map_base_marked_p (const void *);
5586 extern void DEBUG_FUNCTION verify_type (const_tree t);
5587 extern bool gimple_canonical_types_compatible_p (const_tree, const_tree,
5588                                                  bool trust_type_canonical = true);
5589 extern bool type_with_interoperable_signedness (const_tree);
5590 extern bitmap get_nonnull_args (const_tree);
5591 extern int get_range_pos_neg (tree);
5592
5593 /* Return true for a valid pair of new and delete operators.  */
5594 extern bool valid_new_delete_pair_p (tree, tree, bool * = NULL);
5595
5596 /* Return simplified tree code of type that is used for canonical type
5597    merging.  */
5598 inline enum tree_code
5599 tree_code_for_canonical_type_merging (enum tree_code code)
5600 {
5601   /* By C standard, each enumerated type shall be compatible with char,
5602      a signed integer, or an unsigned integer.  The choice of type is
5603      implementation defined (in our case it depends on -fshort-enum).
5604
5605      For this reason we make no distinction between ENUMERAL_TYPE and INTEGER
5606      type and compare only by their signedness and precision.  */
5607   if (code == ENUMERAL_TYPE)
5608     return INTEGER_TYPE;
5609   /* To allow inter-operability between languages having references and
5610      C, we consider reference types and pointers alike.  Note that this is
5611      not strictly necessary for C-Fortran 2008 interoperability because
5612      Fortran define C_PTR type that needs to be compatible with C pointers
5613      and we handle this one as ptr_type_node.  */
5614   if (code == REFERENCE_TYPE)
5615     return POINTER_TYPE;
5616   return code;
5617 }
5618
5619 /* Return ture if get_alias_set care about TYPE_CANONICAL of given type.
5620    We don't define the types for pointers, arrays and vectors.  The reason is
5621    that pointers are handled specially: ptr_type_node accesses conflict with
5622    accesses to all other pointers.  This is done by alias.cc.
5623    Because alias sets of arrays and vectors are the same as types of their
5624    elements, we can't compute canonical type either.  Otherwise we could go
5625    form void *[10] to int *[10] (because they are equivalent for canonical type
5626    machinery) and get wrong TBAA.  */
5627
5628 inline bool
5629 canonical_type_used_p (const_tree t)
5630 {
5631   return !(POINTER_TYPE_P (t)
5632            || TREE_CODE (t) == ARRAY_TYPE
5633            || TREE_CODE (t) == VECTOR_TYPE);
5634 }
5635
5636 /* Kinds of access to pass-by-reference arguments to functions.  */
5637 enum access_mode
5638 {
5639   access_none = 0,
5640   access_read_only = 1,
5641   access_write_only = 2,
5642   access_read_write = access_read_only | access_write_only,
5643   access_deferred = 4
5644 };
5645
5646 #define tree_map_eq tree_map_base_eq
5647 extern unsigned int tree_map_hash (const void *);
5648 #define tree_map_marked_p tree_map_base_marked_p
5649
5650 #define tree_decl_map_eq tree_map_base_eq
5651 extern unsigned int tree_decl_map_hash (const void *);
5652 #define tree_decl_map_marked_p tree_map_base_marked_p
5653
5654 struct tree_decl_map_cache_hasher : ggc_cache_ptr_hash<tree_decl_map>
5655 {
5656   static hashval_t hash (tree_decl_map *m) { return tree_decl_map_hash (m); }
5657   static bool
5658   equal (tree_decl_map *a, tree_decl_map *b)
5659   {
5660     return tree_decl_map_eq (a, b);
5661   }
5662
5663   static int
5664   keep_cache_entry (tree_decl_map *&m)
5665   {
5666     return ggc_marked_p (m->base.from);
5667   }
5668 };
5669
5670 #define tree_int_map_eq tree_map_base_eq
5671 #define tree_int_map_hash tree_map_base_hash
5672 #define tree_int_map_marked_p tree_map_base_marked_p
5673
5674 #define tree_vec_map_eq tree_map_base_eq
5675 #define tree_vec_map_hash tree_decl_map_hash
5676 #define tree_vec_map_marked_p tree_map_base_marked_p
5677
5678 struct tree_vec_map_cache_hasher : ggc_cache_ptr_hash<tree_vec_map>
5679 {
5680   static hashval_t hash (tree_vec_map *m) { return DECL_UID (m->base.from); }
5681
5682   static bool
5683   equal (tree_vec_map *a, tree_vec_map *b)
5684   {
5685     return a->base.from == b->base.from;
5686   }
5687
5688   static int
5689   keep_cache_entry (tree_vec_map *&m)
5690   {
5691     return ggc_marked_p (m->base.from);
5692   }
5693 };
5694
5695 /* Hasher for tree decls.  Pointer equality is enough here, but the DECL_UID
5696    is a better hash than the pointer value and gives a predictable traversal
5697    order.  Additionally it can be used across PCH save/restore.  */
5698 struct tree_decl_hash : ggc_ptr_hash <tree_node>
5699 {
5700   static inline hashval_t hash (tree);
5701 };
5702
5703 inline hashval_t
5704 tree_decl_hash::hash (tree t)
5705 {
5706   return DECL_UID (t);
5707 }
5708
5709 /* Similarly for types.  Uses TYPE_UID as hash function.  */
5710 struct tree_type_hash : ggc_ptr_hash <tree_node>
5711 {
5712   static inline hashval_t hash (tree);
5713 };
5714
5715 inline hashval_t
5716 tree_type_hash::hash (tree t)
5717 {
5718   return TYPE_UID (t);
5719 }
5720
5721 /* Hash for SSA_NAMEs in the same function.  Pointer equality is enough
5722    here, but the SSA_NAME_VERSION is a better hash than the pointer
5723    value and gives a predictable traversal order.  */
5724 struct tree_ssa_name_hash : ggc_ptr_hash <tree_node>
5725 {
5726   static inline hashval_t hash (tree);
5727 };
5728
5729 inline hashval_t
5730 tree_ssa_name_hash::hash (tree t)
5731 {
5732   return SSA_NAME_VERSION (t);
5733 }
5734
5735 /* Hasher for general trees, based on their TREE_HASH.  */
5736 struct tree_hash : ggc_ptr_hash <tree_node>
5737 {
5738   static hashval_t hash (tree);
5739 };
5740
5741 inline hashval_t
5742 tree_hash::hash (tree t)
5743 {
5744   return TREE_HASH (t);
5745 }
5746
5747 /* A hash_map of two trees for use with GTY((cache)).  Garbage collection for
5748    such a map will not mark keys, and will mark values if the key is already
5749    marked.  */
5750 struct tree_cache_traits
5751   : simple_cache_map_traits<default_hash_traits<tree>, tree> { };
5752 typedef hash_map<tree,tree,tree_cache_traits> tree_cache_map;
5753
5754 /* Similarly, but use DECL_UID as hash function rather than pointer hashing.
5755    This is for hash_maps from decls to trees that need to work across PCH.  */
5756 struct decl_tree_cache_traits
5757   : simple_cache_map_traits<tree_decl_hash, tree> { };
5758 typedef hash_map<tree,tree,decl_tree_cache_traits> decl_tree_cache_map;
5759
5760 /* Similarly, but use TYPE_UID as hash function rather than pointer hashing.
5761    This is for hash_maps from types to trees that need to work across PCH.  */
5762 struct type_tree_cache_traits
5763   : simple_cache_map_traits<tree_type_hash, tree> { };
5764 typedef hash_map<tree,tree,type_tree_cache_traits> type_tree_cache_map;
5765
5766 /* Similarly to decl_tree_cache_map, but without caching.  */
5767 struct decl_tree_traits
5768   : simple_hashmap_traits<tree_decl_hash, tree> { };
5769 typedef hash_map<tree,tree,decl_tree_traits> decl_tree_map;
5770
5771 /* Initialize the abstract argument list iterator object ITER with the
5772    arguments from CALL_EXPR node EXP.  */
5773 static inline void
5774 init_call_expr_arg_iterator (tree exp, call_expr_arg_iterator *iter)
5775 {
5776   iter->t = exp;
5777   iter->n = call_expr_nargs (exp);
5778   iter->i = 0;
5779 }
5780
5781 static inline void
5782 init_const_call_expr_arg_iterator (const_tree exp, const_call_expr_arg_iterator *iter)
5783 {
5784   iter->t = exp;
5785   iter->n = call_expr_nargs (exp);
5786   iter->i = 0;
5787 }
5788
5789 /* Return the next argument from abstract argument list iterator object ITER,
5790    and advance its state.  Return NULL_TREE if there are no more arguments.  */
5791 static inline tree
5792 next_call_expr_arg (call_expr_arg_iterator *iter)
5793 {
5794   tree result;
5795   if (iter->i >= iter->n)
5796     return NULL_TREE;
5797   result = CALL_EXPR_ARG (iter->t, iter->i);
5798   iter->i++;
5799   return result;
5800 }
5801
5802 static inline const_tree
5803 next_const_call_expr_arg (const_call_expr_arg_iterator *iter)
5804 {
5805   const_tree result;
5806   if (iter->i >= iter->n)
5807     return NULL_TREE;
5808   result = CALL_EXPR_ARG (iter->t, iter->i);
5809   iter->i++;
5810   return result;
5811 }
5812
5813 /* Initialize the abstract argument list iterator object ITER, then advance
5814    past and return the first argument.  Useful in for expressions, e.g.
5815      for (arg = first_call_expr_arg (exp, &iter); arg;
5816           arg = next_call_expr_arg (&iter))   */
5817 static inline tree
5818 first_call_expr_arg (tree exp, call_expr_arg_iterator *iter)
5819 {
5820   init_call_expr_arg_iterator (exp, iter);
5821   return next_call_expr_arg (iter);
5822 }
5823
5824 static inline const_tree
5825 first_const_call_expr_arg (const_tree exp, const_call_expr_arg_iterator *iter)
5826 {
5827   init_const_call_expr_arg_iterator (exp, iter);
5828   return next_const_call_expr_arg (iter);
5829 }
5830
5831 /* Test whether there are more arguments in abstract argument list iterator
5832    ITER, without changing its state.  */
5833 static inline bool
5834 more_call_expr_args_p (const call_expr_arg_iterator *iter)
5835 {
5836   return (iter->i < iter->n);
5837 }
5838
5839 /* Iterate through each argument ARG of CALL_EXPR CALL, using variable ITER
5840    (of type call_expr_arg_iterator) to hold the iteration state.  */
5841 #define FOR_EACH_CALL_EXPR_ARG(arg, iter, call)                 \
5842   for ((arg) = first_call_expr_arg ((call), &(iter)); (arg);    \
5843        (arg) = next_call_expr_arg (&(iter)))
5844
5845 #define FOR_EACH_CONST_CALL_EXPR_ARG(arg, iter, call)                   \
5846   for ((arg) = first_const_call_expr_arg ((call), &(iter)); (arg);      \
5847        (arg) = next_const_call_expr_arg (&(iter)))
5848
5849 /* Return true if tree node T is a language-specific node.  */
5850 static inline bool
5851 is_lang_specific (const_tree t)
5852 {
5853   return TREE_CODE (t) == LANG_TYPE || TREE_CODE (t) >= NUM_TREE_CODES;
5854 }
5855
5856 /* Valid builtin number.  */
5857 #define BUILTIN_VALID_P(FNCODE) \
5858   (IN_RANGE ((int)FNCODE, ((int)BUILT_IN_NONE) + 1, ((int) END_BUILTINS) - 1))
5859
5860 /* Obtain a pointer to the identifier string holding the asm name for
5861    BUILTIN, a BUILT_IN code.  This is handy if the target
5862    mangles/overrides the function name that implements the
5863    builtin.  */
5864 #define BUILTIN_ASM_NAME_PTR(BUILTIN) \
5865   (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (builtin_decl_explicit (BUILTIN))))
5866
5867 /* Return the tree node for an explicit standard builtin function or NULL.  */
5868 static inline tree
5869 builtin_decl_explicit (enum built_in_function fncode)
5870 {
5871   gcc_checking_assert (BUILTIN_VALID_P (fncode));
5872
5873   return builtin_info[(size_t)fncode].decl;
5874 }
5875
5876 /* Return the tree node for an implicit builtin function or NULL.  */
5877 static inline tree
5878 builtin_decl_implicit (enum built_in_function fncode)
5879 {
5880   size_t uns_fncode = (size_t)fncode;
5881   gcc_checking_assert (BUILTIN_VALID_P (fncode));
5882
5883   if (!builtin_info[uns_fncode].implicit_p)
5884     return NULL_TREE;
5885
5886   return builtin_info[uns_fncode].decl;
5887 }
5888
5889 /* For BUILTIN_UNREACHABLE, use one of these or
5890    gimple_build_builtin_unreachable instead of one of the above.  */
5891 extern tree builtin_decl_unreachable ();
5892 extern tree build_builtin_unreachable (location_t);
5893
5894 /* Set explicit builtin function nodes and whether it is an implicit
5895    function.  */
5896
5897 static inline void
5898 set_builtin_decl (enum built_in_function fncode, tree decl, bool implicit_p)
5899 {
5900   size_t ufncode = (size_t)fncode;
5901
5902   gcc_checking_assert (BUILTIN_VALID_P (fncode)
5903                        && (decl != NULL_TREE || !implicit_p));
5904
5905   builtin_info[ufncode].decl = decl;
5906   builtin_info[ufncode].implicit_p = implicit_p;
5907   builtin_info[ufncode].declared_p = false;
5908 }
5909
5910 /* Set the implicit flag for a builtin function.  */
5911
5912 static inline void
5913 set_builtin_decl_implicit_p (enum built_in_function fncode, bool implicit_p)
5914 {
5915   size_t uns_fncode = (size_t)fncode;
5916
5917   gcc_checking_assert (BUILTIN_VALID_P (fncode)
5918                        && builtin_info[uns_fncode].decl != NULL_TREE);
5919
5920   builtin_info[uns_fncode].implicit_p = implicit_p;
5921 }
5922
5923 /* Set the declared flag for a builtin function.  */
5924
5925 static inline void
5926 set_builtin_decl_declared_p (enum built_in_function fncode, bool declared_p)
5927 {
5928   size_t uns_fncode = (size_t)fncode;
5929
5930   gcc_checking_assert (BUILTIN_VALID_P (fncode)
5931                        && builtin_info[uns_fncode].decl != NULL_TREE);
5932
5933   builtin_info[uns_fncode].declared_p = declared_p;
5934 }
5935
5936 /* Return whether the standard builtin function can be used as an explicit
5937    function.  */
5938
5939 static inline bool
5940 builtin_decl_explicit_p (enum built_in_function fncode)
5941 {
5942   gcc_checking_assert (BUILTIN_VALID_P (fncode));
5943   return (builtin_info[(size_t)fncode].decl != NULL_TREE);
5944 }
5945
5946 /* Return whether the standard builtin function can be used implicitly.  */
5947
5948 static inline bool
5949 builtin_decl_implicit_p (enum built_in_function fncode)
5950 {
5951   size_t uns_fncode = (size_t)fncode;
5952
5953   gcc_checking_assert (BUILTIN_VALID_P (fncode));
5954   return (builtin_info[uns_fncode].decl != NULL_TREE
5955           && builtin_info[uns_fncode].implicit_p);
5956 }
5957
5958 /* Return whether the standard builtin function was declared.  */
5959
5960 static inline bool
5961 builtin_decl_declared_p (enum built_in_function fncode)
5962 {
5963   size_t uns_fncode = (size_t)fncode;
5964
5965   gcc_checking_assert (BUILTIN_VALID_P (fncode));
5966   return (builtin_info[uns_fncode].decl != NULL_TREE
5967           && builtin_info[uns_fncode].declared_p);
5968 }
5969
5970 /* Determine if the function identified by FNDECL is one that
5971    makes sense to match by name, for those places where we detect
5972    "magic" functions by name.
5973
5974    Return true if FNDECL has a name and is an extern fndecl at file scope.
5975    FNDECL must be a non-NULL decl.
5976
5977    Avoid using this, as it's generally better to use attributes rather
5978    than to check for functions by name.  */
5979
5980 static inline bool
5981 maybe_special_function_p (const_tree fndecl)
5982 {
5983   tree name_decl = DECL_NAME (fndecl);
5984   if (name_decl
5985       /* Exclude functions not at the file scope, or not `extern',
5986          since they are not the magic functions we would otherwise
5987          think they are.  */
5988       && (DECL_CONTEXT (fndecl) == NULL_TREE
5989           || TREE_CODE (DECL_CONTEXT (fndecl)) == TRANSLATION_UNIT_DECL)
5990       && TREE_PUBLIC (fndecl))
5991     return true;
5992   return false;
5993 }
5994
5995 /* Return true if T (assumed to be a DECL) is a global variable.
5996    A variable is considered global if its storage is not automatic.  */
5997
5998 static inline bool
5999 is_global_var (const_tree t)
6000 {
6001   return (TREE_STATIC (t) || DECL_EXTERNAL (t));
6002 }
6003
6004 /* Return true if VAR may be aliased.  A variable is considered as
6005    maybe aliased if it has its address taken by the local TU
6006    or possibly by another TU and might be modified through a pointer.  */
6007
6008 static inline bool
6009 may_be_aliased (const_tree var)
6010 {
6011   return (TREE_CODE (var) != CONST_DECL
6012           && (TREE_PUBLIC (var)
6013               || DECL_EXTERNAL (var)
6014               || TREE_ADDRESSABLE (var))
6015           && !((TREE_STATIC (var) || TREE_PUBLIC (var) || DECL_EXTERNAL (var))
6016                && (TREE_READONLY (var)
6017                    || (TREE_CODE (var) == VAR_DECL
6018                        && DECL_NONALIASED (var)))));
6019 }
6020
6021 /* Return pointer to optimization flags of FNDECL.  */
6022 static inline struct cl_optimization *
6023 opts_for_fn (const_tree fndecl)
6024 {
6025   tree fn_opts = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl);
6026   if (fn_opts == NULL_TREE)
6027     fn_opts = optimization_default_node;
6028   return TREE_OPTIMIZATION (fn_opts);
6029 }
6030
6031 /* Return pointer to target flags of FNDECL.  */
6032 static inline cl_target_option *
6033 target_opts_for_fn (const_tree fndecl)
6034 {
6035   tree fn_opts = DECL_FUNCTION_SPECIFIC_TARGET (fndecl);
6036   if (fn_opts == NULL_TREE)
6037     fn_opts = target_option_default_node;
6038   return fn_opts == NULL_TREE ? NULL : TREE_TARGET_OPTION (fn_opts);
6039 }
6040
6041 /* opt flag for function FNDECL, e.g. opts_for_fn (fndecl, optimize) is
6042    the optimization level of function fndecl.  */
6043 #define opt_for_fn(fndecl, opt) (opts_for_fn (fndecl)->x_##opt)
6044
6045 /* For anonymous aggregate types, we need some sort of name to
6046    hold on to.  In practice, this should not appear, but it should
6047    not be harmful if it does.  Identifiers returned will be
6048    IDENTIFIER_ANON_P.  */
6049 extern tree make_anon_name ();
6050
6051 /* The tree and const_tree overload templates.   */
6052 namespace wi
6053 {
6054   class unextended_tree
6055   {
6056   private:
6057     const_tree m_t;
6058
6059   public:
6060     unextended_tree () {}
6061     unextended_tree (const_tree t) : m_t (t) {}
6062
6063     unsigned int get_precision () const;
6064     const HOST_WIDE_INT *get_val () const;
6065     unsigned int get_len () const;
6066     const_tree get_tree () const { return m_t; }
6067   };
6068
6069   template <>
6070   struct int_traits <unextended_tree>
6071   {
6072     static const enum precision_type precision_type = VAR_PRECISION;
6073     static const bool host_dependent_precision = false;
6074     static const bool is_sign_extended = false;
6075   };
6076
6077   template <int N>
6078   class extended_tree
6079   {
6080   private:
6081     const_tree m_t;
6082
6083   public:
6084     extended_tree () {}
6085     extended_tree (const_tree);
6086
6087     unsigned int get_precision () const;
6088     const HOST_WIDE_INT *get_val () const;
6089     unsigned int get_len () const;
6090     const_tree get_tree () const { return m_t; }
6091   };
6092
6093   template <int N>
6094   struct int_traits <extended_tree <N> >
6095   {
6096     static const enum precision_type precision_type = CONST_PRECISION;
6097     static const bool host_dependent_precision = false;
6098     static const bool is_sign_extended = true;
6099     static const unsigned int precision = N;
6100   };
6101
6102   typedef extended_tree <WIDE_INT_MAX_PRECISION> widest_extended_tree;
6103   typedef extended_tree <ADDR_MAX_PRECISION> offset_extended_tree;
6104
6105   typedef const generic_wide_int <widest_extended_tree> tree_to_widest_ref;
6106   typedef const generic_wide_int <offset_extended_tree> tree_to_offset_ref;
6107   typedef const generic_wide_int<wide_int_ref_storage<false, false> >
6108     tree_to_wide_ref;
6109
6110   tree_to_widest_ref to_widest (const_tree);
6111   tree_to_offset_ref to_offset (const_tree);
6112   tree_to_wide_ref to_wide (const_tree);
6113   wide_int to_wide (const_tree, unsigned int);
6114
6115   typedef const poly_int <NUM_POLY_INT_COEFFS,
6116                           generic_wide_int <widest_extended_tree> >
6117     tree_to_poly_widest_ref;
6118   typedef const poly_int <NUM_POLY_INT_COEFFS,
6119                           generic_wide_int <offset_extended_tree> >
6120     tree_to_poly_offset_ref;
6121   typedef const poly_int <NUM_POLY_INT_COEFFS,
6122                           generic_wide_int <unextended_tree> >
6123     tree_to_poly_wide_ref;
6124
6125   tree_to_poly_widest_ref to_poly_widest (const_tree);
6126   tree_to_poly_offset_ref to_poly_offset (const_tree);
6127   tree_to_poly_wide_ref to_poly_wide (const_tree);
6128
6129   template <int N>
6130   struct ints_for <generic_wide_int <extended_tree <N> >, CONST_PRECISION>
6131   {
6132     typedef generic_wide_int <extended_tree <N> > extended;
6133     static extended zero (const extended &);
6134   };
6135
6136   template <>
6137   struct ints_for <generic_wide_int <unextended_tree>, VAR_PRECISION>
6138   {
6139     typedef generic_wide_int <unextended_tree> unextended;
6140     static unextended zero (const unextended &);
6141   };
6142 }
6143
6144 /* Used to convert a tree to a widest2_int like this:
6145    widest2_int foo = widest2_int_cst (some_tree).  */
6146 typedef generic_wide_int <wi::extended_tree <WIDE_INT_MAX_PRECISION * 2> >
6147   widest2_int_cst;
6148
6149 /* Refer to INTEGER_CST T as though it were a widest_int.
6150
6151    This function gives T's actual numerical value, influenced by the
6152    signedness of its type.  For example, a signed byte with just the
6153    top bit set would be -128 while an unsigned byte with the same
6154    bit pattern would be 128.
6155
6156    This is the right choice when operating on groups of INTEGER_CSTs
6157    that might have different signedness or precision.  It is also the
6158    right choice in code that specifically needs an approximation of
6159    infinite-precision arithmetic instead of normal modulo arithmetic.
6160
6161    The approximation of infinite precision is good enough for realistic
6162    numbers of additions and subtractions of INTEGER_CSTs (where
6163    "realistic" includes any number less than 1 << 31) but it cannot
6164    represent the result of multiplying the two largest supported
6165    INTEGER_CSTs.  The overflow-checking form of wi::mul provides a way
6166    of multiplying two arbitrary INTEGER_CSTs and checking that the
6167    result is representable as a widest_int.
6168
6169    Note that any overflow checking done on these values is relative to
6170    the range of widest_int rather than the range of a TREE_TYPE.
6171
6172    Calling this function should have no overhead in release builds,
6173    so it is OK to call it several times for the same tree.  If it is
6174    useful for readability reasons to reduce the number of calls,
6175    it is more efficient to use:
6176
6177      wi::tree_to_widest_ref wt = wi::to_widest (t);
6178
6179    instead of:
6180
6181      widest_int wt = wi::to_widest (t).  */
6182
6183 inline wi::tree_to_widest_ref
6184 wi::to_widest (const_tree t)
6185 {
6186   return t;
6187 }
6188
6189 /* Refer to INTEGER_CST T as though it were an offset_int.
6190
6191    This function is an optimisation of wi::to_widest for cases
6192    in which T is known to be a bit or byte count in the range
6193    (-(2 ^ (N + BITS_PER_UNIT)), 2 ^ (N + BITS_PER_UNIT)), where N is
6194    the target's address size in bits.
6195
6196    This is the right choice when operating on bit or byte counts as
6197    untyped numbers rather than M-bit values.  The wi::to_widest comments
6198    about addition, subtraction and multiplication apply here: sequences
6199    of 1 << 31 additions and subtractions do not induce overflow, but
6200    multiplying the largest sizes might.  Again,
6201
6202      wi::tree_to_offset_ref wt = wi::to_offset (t);
6203
6204    is more efficient than:
6205
6206      offset_int wt = wi::to_offset (t).  */
6207
6208 inline wi::tree_to_offset_ref
6209 wi::to_offset (const_tree t)
6210 {
6211   return t;
6212 }
6213
6214 /* Refer to INTEGER_CST T as though it were a wide_int.
6215
6216    In contrast to the approximation of infinite-precision numbers given
6217    by wi::to_widest and wi::to_offset, this function treats T as a
6218    signless collection of N bits, where N is the precision of T's type.
6219    As with machine registers, signedness is determined by the operation
6220    rather than the operands; for example, there is a distinction between
6221    signed and unsigned division.
6222
6223    This is the right choice when operating on values with the same type
6224    using normal modulo arithmetic.  The overflow-checking forms of things
6225    like wi::add check whether the result can be represented in T's type.
6226
6227    Calling this function should have no overhead in release builds,
6228    so it is OK to call it several times for the same tree.  If it is
6229    useful for readability reasons to reduce the number of calls,
6230    it is more efficient to use:
6231
6232      wi::tree_to_wide_ref wt = wi::to_wide (t);
6233
6234    instead of:
6235
6236      wide_int wt = wi::to_wide (t).  */
6237
6238 inline wi::tree_to_wide_ref
6239 wi::to_wide (const_tree t)
6240 {
6241   return wi::storage_ref (&TREE_INT_CST_ELT (t, 0), TREE_INT_CST_NUNITS (t),
6242                           TYPE_PRECISION (TREE_TYPE (t)));
6243 }
6244
6245 /* Convert INTEGER_CST T to a wide_int of precision PREC, extending or
6246    truncating as necessary.  When extending, use sign extension if T's
6247    type is signed and zero extension if T's type is unsigned.  */
6248
6249 inline wide_int
6250 wi::to_wide (const_tree t, unsigned int prec)
6251 {
6252   return wide_int::from (wi::to_wide (t), prec, TYPE_SIGN (TREE_TYPE (t)));
6253 }
6254
6255 template <int N>
6256 inline wi::extended_tree <N>::extended_tree (const_tree t)
6257   : m_t (t)
6258 {
6259   gcc_checking_assert (TYPE_PRECISION (TREE_TYPE (t)) <= N);
6260 }
6261
6262 template <int N>
6263 inline unsigned int
6264 wi::extended_tree <N>::get_precision () const
6265 {
6266   return N;
6267 }
6268
6269 template <int N>
6270 inline const HOST_WIDE_INT *
6271 wi::extended_tree <N>::get_val () const
6272 {
6273   return &TREE_INT_CST_ELT (m_t, 0);
6274 }
6275
6276 template <int N>
6277 inline unsigned int
6278 wi::extended_tree <N>::get_len () const
6279 {
6280   if (N == ADDR_MAX_PRECISION)
6281     return TREE_INT_CST_OFFSET_NUNITS (m_t);
6282   else if (N >= WIDE_INT_MAX_PRECISION)
6283     return TREE_INT_CST_EXT_NUNITS (m_t);
6284   else
6285     /* This class is designed to be used for specific output precisions
6286        and needs to be as fast as possible, so there is no fallback for
6287        other casees.  */
6288     gcc_unreachable ();
6289 }
6290
6291 inline unsigned int
6292 wi::unextended_tree::get_precision () const
6293 {
6294   return TYPE_PRECISION (TREE_TYPE (m_t));
6295 }
6296
6297 inline const HOST_WIDE_INT *
6298 wi::unextended_tree::get_val () const
6299 {
6300   return &TREE_INT_CST_ELT (m_t, 0);
6301 }
6302
6303 inline unsigned int
6304 wi::unextended_tree::get_len () const
6305 {
6306   return TREE_INT_CST_NUNITS (m_t);
6307 }
6308
6309 /* Return the value of a POLY_INT_CST in its native precision.  */
6310
6311 inline wi::tree_to_poly_wide_ref
6312 poly_int_cst_value (const_tree x)
6313 {
6314   poly_int <NUM_POLY_INT_COEFFS, generic_wide_int <wi::unextended_tree> > res;
6315   for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
6316     res.coeffs[i] = POLY_INT_CST_COEFF (x, i);
6317   return res;
6318 }
6319
6320 /* Access INTEGER_CST or POLY_INT_CST tree T as if it were a
6321    poly_widest_int.  See wi::to_widest for more details.  */
6322
6323 inline wi::tree_to_poly_widest_ref
6324 wi::to_poly_widest (const_tree t)
6325 {
6326   if (POLY_INT_CST_P (t))
6327     {
6328       poly_int <NUM_POLY_INT_COEFFS,
6329                 generic_wide_int <widest_extended_tree> > res;
6330       for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
6331         res.coeffs[i] = POLY_INT_CST_COEFF (t, i);
6332       return res;
6333     }
6334   return t;
6335 }
6336
6337 /* Access INTEGER_CST or POLY_INT_CST tree T as if it were a
6338    poly_offset_int.  See wi::to_offset for more details.  */
6339
6340 inline wi::tree_to_poly_offset_ref
6341 wi::to_poly_offset (const_tree t)
6342 {
6343   if (POLY_INT_CST_P (t))
6344     {
6345       poly_int <NUM_POLY_INT_COEFFS,
6346                 generic_wide_int <offset_extended_tree> > res;
6347       for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
6348         res.coeffs[i] = POLY_INT_CST_COEFF (t, i);
6349       return res;
6350     }
6351   return t;
6352 }
6353
6354 /* Access INTEGER_CST or POLY_INT_CST tree T as if it were a
6355    poly_wide_int.  See wi::to_wide for more details.  */
6356
6357 inline wi::tree_to_poly_wide_ref
6358 wi::to_poly_wide (const_tree t)
6359 {
6360   if (POLY_INT_CST_P (t))
6361     return poly_int_cst_value (t);
6362   return t;
6363 }
6364
6365 template <int N>
6366 inline generic_wide_int <wi::extended_tree <N> >
6367 wi::ints_for <generic_wide_int <wi::extended_tree <N> >,
6368               wi::CONST_PRECISION>::zero (const extended &x)
6369 {
6370   return build_zero_cst (TREE_TYPE (x.get_tree ()));
6371 }
6372
6373 inline generic_wide_int <wi::unextended_tree>
6374 wi::ints_for <generic_wide_int <wi::unextended_tree>,
6375               wi::VAR_PRECISION>::zero (const unextended &x)
6376 {
6377   return build_zero_cst (TREE_TYPE (x.get_tree ()));
6378 }
6379
6380 namespace wi
6381 {
6382   template <typename T>
6383   bool fits_to_boolean_p (const T &x, const_tree);
6384
6385   template <typename T>
6386   bool fits_to_tree_p (const T &x, const_tree);
6387
6388   wide_int min_value (const_tree);
6389   wide_int max_value (const_tree);
6390   wide_int from_mpz (const_tree, mpz_t, bool);
6391 }
6392
6393 template <typename T>
6394 bool
6395 wi::fits_to_boolean_p (const T &x, const_tree type)
6396 {
6397   typedef typename poly_int_traits<T>::int_type int_type;
6398   return (known_eq (x, int_type (0))
6399           || known_eq (x, int_type (TYPE_UNSIGNED (type) ? 1 : -1)));
6400 }
6401
6402 template <typename T>
6403 bool
6404 wi::fits_to_tree_p (const T &x, const_tree type)
6405 {
6406   /* Non-standard boolean types can have arbitrary precision but various
6407      transformations assume that they can only take values 0 and +/-1.  */
6408   if (TREE_CODE (type) == BOOLEAN_TYPE)
6409     return fits_to_boolean_p (x, type);
6410
6411   if (TYPE_UNSIGNED (type))
6412     return known_eq (x, zext (x, TYPE_PRECISION (type)));
6413   else
6414     return known_eq (x, sext (x, TYPE_PRECISION (type)));
6415 }
6416
6417 /* Produce the smallest number that is represented in TYPE.  The precision
6418    and sign are taken from TYPE.  */
6419 inline wide_int
6420 wi::min_value (const_tree type)
6421 {
6422   return min_value (TYPE_PRECISION (type), TYPE_SIGN (type));
6423 }
6424
6425 /* Produce the largest number that is represented in TYPE.  The precision
6426    and sign are taken from TYPE.  */
6427 inline wide_int
6428 wi::max_value (const_tree type)
6429 {
6430   return max_value (TYPE_PRECISION (type), TYPE_SIGN (type));
6431 }
6432
6433 /* Return true if INTEGER_CST T1 is less than INTEGER_CST T2,
6434    extending both according to their respective TYPE_SIGNs.  */
6435
6436 inline bool
6437 tree_int_cst_lt (const_tree t1, const_tree t2)
6438 {
6439   return wi::to_widest (t1) < wi::to_widest (t2);
6440 }
6441
6442 /* Return true if INTEGER_CST T1 is less than or equal to INTEGER_CST T2,
6443    extending both according to their respective TYPE_SIGNs.  */
6444
6445 inline bool
6446 tree_int_cst_le (const_tree t1, const_tree t2)
6447 {
6448   return wi::to_widest (t1) <= wi::to_widest (t2);
6449 }
6450
6451 /* Returns -1 if T1 < T2, 0 if T1 == T2, and 1 if T1 > T2.  T1 and T2
6452    are both INTEGER_CSTs and their values are extended according to their
6453    respective TYPE_SIGNs.  */
6454
6455 inline int
6456 tree_int_cst_compare (const_tree t1, const_tree t2)
6457 {
6458   return wi::cmps (wi::to_widest (t1), wi::to_widest (t2));
6459 }
6460
6461 /* FIXME - These declarations belong in builtins.h, expr.h and emit-rtl.h,
6462    but none of these files are allowed to be included from front ends.
6463    They should be split in two. One suitable for the FEs, the other suitable
6464    for the BE.  */
6465
6466 /* Assign the RTX to declaration.  */
6467 extern void set_decl_rtl (tree, rtx);
6468 extern bool complete_ctor_at_level_p (const_tree, HOST_WIDE_INT, const_tree);
6469
6470 /* Given an expression EXP that is a handled_component_p,
6471    look for the ultimate containing object, which is returned and specify
6472    the access position and size.  */
6473 extern tree get_inner_reference (tree, poly_int64_pod *, poly_int64_pod *,
6474                                  tree *, machine_mode *, int *, int *, int *);
6475
6476 extern tree build_personality_function (const char *);
6477
6478 struct GTY(()) int_n_trees_t {
6479   /* These parts are initialized at runtime */
6480   tree signed_type;
6481   tree unsigned_type;
6482 };
6483
6484 /* This is also in machmode.h */
6485 extern bool int_n_enabled_p[NUM_INT_N_ENTS];
6486 extern GTY(()) struct int_n_trees_t int_n_trees[NUM_INT_N_ENTS];
6487
6488 /* Like bit_position, but return as an integer.  It must be representable in
6489    that way (since it could be a signed value, we don't have the
6490    option of returning -1 like int_size_in_byte can.  */
6491
6492 inline HOST_WIDE_INT
6493 int_bit_position (const_tree field)
6494 {
6495   return ((wi::to_offset (DECL_FIELD_OFFSET (field)) << LOG2_BITS_PER_UNIT)
6496           + wi::to_offset (DECL_FIELD_BIT_OFFSET (field))).to_shwi ();
6497 }
6498
6499 /* Return true if it makes sense to consider alias set for a type T.  */
6500
6501 inline bool
6502 type_with_alias_set_p (const_tree t)
6503 {
6504   /* Function and method types are never accessed as memory locations.  */
6505   if (TREE_CODE (t) == FUNCTION_TYPE || TREE_CODE (t) == METHOD_TYPE)
6506     return false;
6507
6508   if (COMPLETE_TYPE_P (t))
6509     return true;
6510
6511   /* Incomplete types cannot be accessed in general except for arrays
6512      where we can fetch its element despite we have no array bounds.  */
6513   if (TREE_CODE (t) == ARRAY_TYPE && COMPLETE_TYPE_P (TREE_TYPE (t)))
6514     return true;
6515
6516   return false;
6517 }
6518
6519 extern location_t set_block (location_t loc, tree block);
6520
6521 extern void gt_ggc_mx (tree &);
6522 extern void gt_pch_nx (tree &);
6523 extern void gt_pch_nx (tree &, gt_pointer_operator, void *);
6524
6525 extern bool nonnull_arg_p (const_tree);
6526 extern bool is_empty_type (const_tree);
6527 extern bool default_is_empty_record (const_tree);
6528 extern bool flexible_array_type_p (const_tree);
6529 extern HOST_WIDE_INT arg_int_size_in_bytes (const_tree);
6530 extern tree arg_size_in_bytes (const_tree);
6531 extern bool expr_type_first_operand_type_p (tree_code);
6532
6533 extern location_t
6534 set_source_range (tree expr, location_t start, location_t finish);
6535
6536 extern location_t
6537 set_source_range (tree expr, source_range src_range);
6538
6539 /* Return true if it makes sense to promote/demote from_type to to_type. */
6540 inline bool
6541 desired_pro_or_demotion_p (const_tree to_type, const_tree from_type)
6542 {
6543   unsigned int to_type_precision = TYPE_PRECISION (to_type);
6544
6545   /* OK to promote if to_type is no bigger than word_mode. */
6546   if (to_type_precision <= GET_MODE_PRECISION (word_mode))
6547     return true;
6548
6549   /* Otherwise, allow only if narrowing or same precision conversions. */
6550   return to_type_precision <= TYPE_PRECISION (from_type);
6551 }
6552
6553 /* Pointer type used to declare builtins before we have seen its real
6554    declaration.  */
6555 class builtin_structptr_type
6556 {
6557 public:
6558   tree& node;
6559   tree& base;
6560   const char *str;
6561 };
6562 extern const builtin_structptr_type builtin_structptr_types[6];
6563
6564 /* Return true if type T has the same precision as its underlying mode.  */
6565
6566 inline bool
6567 type_has_mode_precision_p (const_tree t)
6568 {
6569   return known_eq (TYPE_PRECISION (t), GET_MODE_PRECISION (TYPE_MODE (t)));
6570 }
6571
6572 /* Return true if a FUNCTION_DECL NODE is a GCC built-in function.
6573
6574    Note that it is different from the DECL_IS_UNDECLARED_BUILTIN
6575    accessor, as this is impervious to user declaration.  */
6576
6577 inline bool
6578 fndecl_built_in_p (const_tree node)
6579 {
6580   return DECL_BUILT_IN_CLASS (node) != NOT_BUILT_IN;
6581 }
6582
6583 /* Return true if a FUNCTION_DECL NODE is a GCC built-in function
6584    of class KLASS.  */
6585
6586 inline bool
6587 fndecl_built_in_p (const_tree node, built_in_class klass)
6588 {
6589   return fndecl_built_in_p (node) && DECL_BUILT_IN_CLASS (node) == klass;
6590 }
6591
6592 /* Return true if a FUNCTION_DECL NODE is a GCC built-in function
6593    of class KLASS with name equal to NAME.  */
6594
6595 inline bool
6596 fndecl_built_in_p (const_tree node, unsigned int name, built_in_class klass)
6597 {
6598   return (fndecl_built_in_p (node, klass)
6599           && DECL_UNCHECKED_FUNCTION_CODE (node) == name);
6600 }
6601
6602 /* Return true if a FUNCTION_DECL NODE is a GCC built-in function
6603    of BUILT_IN_NORMAL class with name equal to NAME.  */
6604
6605 inline bool
6606 fndecl_built_in_p (const_tree node, built_in_function name)
6607 {
6608   return (fndecl_built_in_p (node, BUILT_IN_NORMAL)
6609           && DECL_FUNCTION_CODE (node) == name);
6610 }
6611
6612 /* A struct for encapsulating location information about an operator
6613    and the operation built from it.
6614
6615    m_operator_loc is the location of the operator
6616    m_combined_loc is the location of the compound expression.
6617
6618    For example, given "a && b" the, operator location is:
6619       a && b
6620         ^~
6621    and the combined location is:
6622       a && b
6623       ~~^~~~
6624    Capturing this information allows for class binary_op_rich_location
6625    to provide detailed information about e.g. type mismatches in binary
6626    operations where enough location information is available:
6627
6628      arg_0 op arg_1
6629      ~~~~~ ^~ ~~~~~
6630        |        |
6631        |        arg1 type
6632        arg0 type
6633
6634    falling back to just showing the combined location:
6635
6636      arg_0 op arg_1
6637      ~~~~~~^~~~~~~~
6638
6639    where it is not.  */
6640
6641 class op_location_t
6642 {
6643 public:
6644   location_t m_operator_loc;
6645   location_t m_combined_loc;
6646
6647   /* 1-argument ctor, for constructing from a combined location.  */
6648   op_location_t (location_t combined_loc)
6649   : m_operator_loc (UNKNOWN_LOCATION), m_combined_loc (combined_loc)
6650   {}
6651
6652   /* 2-argument ctor, for distinguishing between the operator's location
6653      and the combined location.  */
6654   op_location_t (location_t operator_loc, location_t combined_loc)
6655   : m_operator_loc (operator_loc), m_combined_loc (combined_loc)
6656   {}
6657
6658   /* Implicitly convert back to a location_t, using the combined location.  */
6659   operator location_t () const { return m_combined_loc; }
6660 };
6661
6662 /* Code that doesn't refer to any warning.  Has no effect on suppression
6663    functions.  */
6664 constexpr opt_code no_warning = opt_code ();
6665 /* Wildcard code that refers to all warnings.  */
6666 constexpr opt_code all_warnings = N_OPTS;
6667
6668 /* Return the disposition for a warning (or all warnings by default)
6669    at a location.  */
6670 extern bool warning_suppressed_at (location_t, opt_code = all_warnings);
6671 /* Set the disposition for a warning (or all warnings by default)
6672    at a location to disabled by default.  */
6673 extern bool suppress_warning_at (location_t, opt_code = all_warnings,
6674                                  bool = true);
6675 /* Copy warning disposition from one location to another.  */
6676 extern void copy_warning (location_t, location_t);
6677
6678 /* Return the disposition for a warning (or all warnings by default)
6679    for an expression.  */
6680 extern bool warning_suppressed_p (const_tree, opt_code = all_warnings);
6681 /* Set the disposition for a warning (or all warnings by default)
6682    at a location to disabled by default.  */
6683 extern void suppress_warning (tree, opt_code = all_warnings, bool = true)
6684   ATTRIBUTE_NONNULL (1);
6685 /* Copy warning disposition from one expression to another.  */
6686 extern void copy_warning (tree, const_tree);
6687
6688 /* Return the zero-based number corresponding to the argument being
6689    deallocated if FNDECL is a deallocation function or an out-of-bounds
6690    value if it isn't.  */
6691 extern unsigned fndecl_dealloc_argno (tree);
6692
6693 /* If an expression refers to a character array or pointer declared
6694    attribute nonstring, return a decl for that array or pointer and
6695    if nonnull, set the second argument to the referenced enclosing
6696    object or pointer.  Otherwise return null.  */
6697 extern tree get_attr_nonstring_decl (tree, tree * = NULL);
6698
6699 extern int get_target_clone_attr_len (tree);
6700
6701 #endif  /* GCC_TREE_H  */