| 1 |
/**************************************************************************** |
| 2 |
* * |
| 3 |
* GNAT COMPILER COMPONENTS * |
| 4 |
* * |
| 5 |
* A D A - T R E E * |
| 6 |
* * |
| 7 |
* C Header File * |
| 8 |
* * |
| 9 |
* Copyright (C) 1992-2025, Free Software Foundation, Inc. * |
| 10 |
* * |
| 11 |
* GNAT is free software; you can redistribute it and/or modify it under * |
| 12 |
* terms of the GNU General Public License as published by the Free Soft- * |
| 13 |
* ware Foundation; either version 3, or (at your option) any later ver- * |
| 14 |
* sion. GNAT is distributed in the hope that it will be useful, but WITH- * |
| 15 |
* OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * |
| 16 |
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * |
| 17 |
* for more details. You should have received a copy of the GNU General * |
| 18 |
* Public License along with GCC; see the file COPYING3. If not see * |
| 19 |
* <http://www.gnu.org/licenses/>. * |
| 20 |
* * |
| 21 |
* GNAT was originally developed by the GNAT team at New York University. * |
| 22 |
* Extensive contributions were provided by Ada Core Technologies Inc. * |
| 23 |
* * |
| 24 |
****************************************************************************/ |
| 25 |
|
| 26 |
/* The resulting tree type. */ |
| 27 |
union GTY((desc ("0"), |
| 28 |
chain_next ("CODE_CONTAINS_STRUCT (TREE_CODE (&%h.generic), TS_COMMON) ? ((union lang_tree_node *) TREE_CHAIN (&%h.generic)) : NULL"))) |
| 29 |
lang_tree_node |
| 30 |
{ |
| 31 |
union tree_node GTY((tag ("0"), |
| 32 |
desc ("tree_node_structure (&%h)"))) generic; |
| 33 |
}; |
| 34 |
|
| 35 |
/* Ada uses the lang_decl and lang_type fields to hold a tree. */ |
| 36 |
struct GTY(()) lang_type { tree t1; tree t2; }; |
| 37 |
struct GTY(()) lang_decl { tree t; }; |
| 38 |
|
| 39 |
extern struct lang_type *get_lang_specific (tree node); |
| 40 |
|
| 41 |
/* Macros to get and set the trees in TYPE_LANG_SPECIFIC. */ |
| 42 |
#define GET_TYPE_LANG_SPECIFIC(NODE) \ |
| 43 |
(TYPE_LANG_SPECIFIC (NODE) ? TYPE_LANG_SPECIFIC (NODE)->t1 : NULL_TREE) |
| 44 |
|
| 45 |
#define SET_TYPE_LANG_SPECIFIC(NODE, X) (get_lang_specific (NODE)->t1 = (X)) |
| 46 |
|
| 47 |
#define GET_TYPE_LANG_SPECIFIC2(NODE) \ |
| 48 |
(TYPE_LANG_SPECIFIC (NODE) ? TYPE_LANG_SPECIFIC (NODE)->t2 : NULL_TREE) |
| 49 |
|
| 50 |
#define SET_TYPE_LANG_SPECIFIC2(NODE, X) (get_lang_specific (NODE)->t2 = (X)) |
| 51 |
|
| 52 |
/* Macros to get and set the tree in DECL_LANG_SPECIFIC. */ |
| 53 |
#define GET_DECL_LANG_SPECIFIC(NODE) \ |
| 54 |
(DECL_LANG_SPECIFIC (NODE) ? DECL_LANG_SPECIFIC (NODE)->t : NULL_TREE) |
| 55 |
|
| 56 |
#define SET_DECL_LANG_SPECIFIC(NODE, X) \ |
| 57 |
do { \ |
| 58 |
tree tmp = (X); \ |
| 59 |
if (!DECL_LANG_SPECIFIC (NODE)) \ |
| 60 |
DECL_LANG_SPECIFIC (NODE) \ |
| 61 |
= ggc_alloc<struct lang_decl> (); \ |
| 62 |
DECL_LANG_SPECIFIC (NODE)->t = tmp; \ |
| 63 |
} while (0) |
| 64 |
|
| 65 |
|
| 66 |
/* Flags added to type nodes. */ |
| 67 |
|
| 68 |
/* For RECORD_TYPE, UNION_TYPE, and QUAL_UNION_TYPE, nonzero if this is a |
| 69 |
record being used as a fat pointer (only true for RECORD_TYPE). */ |
| 70 |
#define TYPE_FAT_POINTER_P(NODE) \ |
| 71 |
TYPE_LANG_FLAG_0 (RECORD_OR_UNION_CHECK (NODE)) |
| 72 |
|
| 73 |
#define TYPE_IS_FAT_POINTER_P(NODE) \ |
| 74 |
(TREE_CODE (NODE) == RECORD_TYPE && TYPE_FAT_POINTER_P (NODE)) |
| 75 |
|
| 76 |
/* For integral types and array types, nonzero if this is an implementation |
| 77 |
type for a bit-packed array type. Such types should not be extended to a |
| 78 |
larger size or validated against a specified size. */ |
| 79 |
#define TYPE_BIT_PACKED_ARRAY_TYPE_P(NODE) \ |
| 80 |
TYPE_LANG_FLAG_0 (TREE_CHECK2 (NODE, INTEGER_TYPE, ARRAY_TYPE)) |
| 81 |
|
| 82 |
#define BIT_PACKED_ARRAY_TYPE_P(NODE) \ |
| 83 |
((TREE_CODE (NODE) == INTEGER_TYPE || TREE_CODE (NODE) == ARRAY_TYPE) \ |
| 84 |
&& TYPE_BIT_PACKED_ARRAY_TYPE_P (NODE)) |
| 85 |
|
| 86 |
/* For FUNCTION_TYPE and METHOD_TYPE, nonzero if the function returns by |
| 87 |
direct reference, i.e. the callee returns a pointer to a memory location |
| 88 |
it has allocated and the caller only needs to dereference the pointer. */ |
| 89 |
#define TYPE_RETURN_BY_DIRECT_REF_P(NODE) \ |
| 90 |
TYPE_LANG_FLAG_0 (FUNC_OR_METHOD_CHECK (NODE)) |
| 91 |
|
| 92 |
/* For INTEGER_TYPE, nonzero if this is a modular type with a modulus that |
| 93 |
is not equal to two to the power of its mode's size. */ |
| 94 |
#define TYPE_MODULAR_P(NODE) TYPE_LANG_FLAG_1 (INTEGER_TYPE_CHECK (NODE)) |
| 95 |
|
| 96 |
/* For ARRAY_TYPE, nonzero if this type corresponds to a dimension of |
| 97 |
an Ada array other than the first. */ |
| 98 |
#define TYPE_MULTI_ARRAY_P(NODE) TYPE_LANG_FLAG_1 (ARRAY_TYPE_CHECK (NODE)) |
| 99 |
|
| 100 |
/* For RECORD_TYPE, UNION_TYPE, and QUAL_UNION_TYPE, nonzero if this denotes |
| 101 |
a justified modular type (will only be true for RECORD_TYPE). */ |
| 102 |
#define TYPE_JUSTIFIED_MODULAR_P(NODE) \ |
| 103 |
TYPE_LANG_FLAG_1 (RECORD_OR_UNION_CHECK (NODE)) |
| 104 |
|
| 105 |
/* Nonzero in an arithmetic subtype if this is a subtype not known to the |
| 106 |
front-end. */ |
| 107 |
#define TYPE_EXTRA_SUBTYPE_P(NODE) TYPE_LANG_FLAG_2 (INTEGER_TYPE_CHECK (NODE)) |
| 108 |
|
| 109 |
#define TYPE_IS_EXTRA_SUBTYPE_P(NODE) \ |
| 110 |
(TREE_CODE (NODE) == INTEGER_TYPE && TYPE_EXTRA_SUBTYPE_P (NODE)) |
| 111 |
|
| 112 |
/* Nonzero for an aggregate type if this is a by-reference type. We also |
| 113 |
set this on an ENUMERAL_TYPE that is dummy. */ |
| 114 |
#define TYPE_BY_REFERENCE_P(NODE) \ |
| 115 |
TYPE_LANG_FLAG_2 (TREE_CHECK5 (NODE, RECORD_TYPE, UNION_TYPE, \ |
| 116 |
ARRAY_TYPE, UNCONSTRAINED_ARRAY_TYPE, \ |
| 117 |
ENUMERAL_TYPE)) |
| 118 |
|
| 119 |
#define TYPE_IS_BY_REFERENCE_P(NODE) \ |
| 120 |
((TREE_CODE (NODE) == RECORD_TYPE \ |
| 121 |
|| TREE_CODE (NODE) == UNION_TYPE \ |
| 122 |
|| TREE_CODE (NODE) == ARRAY_TYPE \ |
| 123 |
|| TREE_CODE (NODE) == UNCONSTRAINED_ARRAY_TYPE \ |
| 124 |
|| TREE_CODE (NODE) == ENUMERAL_TYPE) \ |
| 125 |
&& TYPE_BY_REFERENCE_P (NODE)) |
| 126 |
|
| 127 |
/* For RECORD_TYPE, UNION_TYPE, and QUAL_UNION_TYPE, nonzero if this is the |
| 128 |
type for an object whose type includes its template in addition to |
| 129 |
its value (only true for RECORD_TYPE). */ |
| 130 |
#define TYPE_CONTAINS_TEMPLATE_P(NODE) \ |
| 131 |
TYPE_LANG_FLAG_3 (RECORD_OR_UNION_CHECK (NODE)) |
| 132 |
|
| 133 |
/* For INTEGER_TYPE, nonzero if it implements a fixed-point type. */ |
| 134 |
#define TYPE_FIXED_POINT_P(NODE) \ |
| 135 |
TYPE_LANG_FLAG_3 (INTEGER_TYPE_CHECK (NODE)) |
| 136 |
|
| 137 |
#define TYPE_IS_FIXED_POINT_P(NODE) \ |
| 138 |
(TREE_CODE (NODE) == INTEGER_TYPE && TYPE_FIXED_POINT_P (NODE)) |
| 139 |
|
| 140 |
/* True if NODE is a thin pointer. */ |
| 141 |
#define TYPE_IS_THIN_POINTER_P(NODE) \ |
| 142 |
(POINTER_TYPE_P (NODE) \ |
| 143 |
&& TREE_CODE (TREE_TYPE (NODE)) == RECORD_TYPE \ |
| 144 |
&& TYPE_CONTAINS_TEMPLATE_P (TREE_TYPE (NODE))) |
| 145 |
|
| 146 |
/* True if TYPE is either a fat or thin pointer to an unconstrained |
| 147 |
array. */ |
| 148 |
#define TYPE_IS_FAT_OR_THIN_POINTER_P(NODE) \ |
| 149 |
(TYPE_IS_FAT_POINTER_P (NODE) || TYPE_IS_THIN_POINTER_P (NODE)) |
| 150 |
|
| 151 |
/* For INTEGER_TYPEs, nonzero if the type has a biased representation. */ |
| 152 |
#define TYPE_BIASED_REPRESENTATION_P(NODE) \ |
| 153 |
TYPE_LANG_FLAG_4 (INTEGER_TYPE_CHECK (NODE)) |
| 154 |
|
| 155 |
/* For ARRAY_TYPEs, nonzero if the array type has Convention_Fortran. */ |
| 156 |
#define TYPE_CONVENTION_FORTRAN_P(NODE) \ |
| 157 |
TYPE_LANG_FLAG_4 (ARRAY_TYPE_CHECK (NODE)) |
| 158 |
|
| 159 |
/* For RECORD_TYPE, UNION_TYPE and ENUMERAL_TYPE, nonzero if this is a dummy |
| 160 |
type, made to correspond to a private or incomplete type. */ |
| 161 |
#define TYPE_DUMMY_P(NODE) \ |
| 162 |
TYPE_LANG_FLAG_4 (TREE_CHECK3 (NODE, RECORD_TYPE, UNION_TYPE, ENUMERAL_TYPE)) |
| 163 |
|
| 164 |
#define TYPE_IS_DUMMY_P(NODE) \ |
| 165 |
((TREE_CODE (NODE) == RECORD_TYPE \ |
| 166 |
|| TREE_CODE (NODE) == UNION_TYPE \ |
| 167 |
|| TREE_CODE (NODE) == ENUMERAL_TYPE) \ |
| 168 |
&& TYPE_DUMMY_P (NODE)) |
| 169 |
|
| 170 |
/* For an INTEGER_TYPE, nonzero if TYPE_ACTUAL_BOUNDS is present. */ |
| 171 |
#define TYPE_HAS_ACTUAL_BOUNDS_P(NODE) \ |
| 172 |
TYPE_LANG_FLAG_5 (INTEGER_TYPE_CHECK (NODE)) |
| 173 |
|
| 174 |
/* For a RECORD_TYPE, nonzero if this was made just to supply needed |
| 175 |
padding or alignment. */ |
| 176 |
#define TYPE_PADDING_P(NODE) TYPE_LANG_FLAG_5 (RECORD_TYPE_CHECK (NODE)) |
| 177 |
|
| 178 |
#define TYPE_IS_PADDING_P(NODE) \ |
| 179 |
(TREE_CODE (NODE) == RECORD_TYPE && TYPE_PADDING_P (NODE)) |
| 180 |
|
| 181 |
/* True for a non-dummy type if TYPE can alias any other types. */ |
| 182 |
#define TYPE_UNIVERSAL_ALIASING_P(NODE) TYPE_LANG_FLAG_6 (NODE) |
| 183 |
|
| 184 |
/* True for a dummy type if TYPE appears in a profile. */ |
| 185 |
#define TYPE_DUMMY_IN_PROFILE_P(NODE) TYPE_LANG_FLAG_6 (NODE) |
| 186 |
|
| 187 |
/* True if objects of this type are guaranteed to be properly aligned. */ |
| 188 |
#define TYPE_ALIGN_OK(NODE) TYPE_LANG_FLAG_7 (NODE) |
| 189 |
|
| 190 |
/* True for types that implement a packed array and for original packed array |
| 191 |
types. */ |
| 192 |
#define TYPE_IMPL_PACKED_ARRAY_P(NODE) \ |
| 193 |
((TREE_CODE (NODE) == ARRAY_TYPE && TYPE_PACKED (NODE)) \ |
| 194 |
|| (TREE_CODE (NODE) == INTEGER_TYPE && TYPE_BIT_PACKED_ARRAY_TYPE_P (NODE))) |
| 195 |
|
| 196 |
/* True for types that can hold a debug type. */ |
| 197 |
#define TYPE_CAN_HAVE_DEBUG_TYPE_P(NODE) (!TYPE_IMPL_PACKED_ARRAY_P (NODE)) |
| 198 |
|
| 199 |
/* For RECORD_TYPE, UNION_TYPE, and QUAL_UNION_TYPE, this holds the maximum |
| 200 |
alignment value the type ought to have. */ |
| 201 |
#define TYPE_MAX_ALIGN(NODE) (TYPE_PRECISION (RECORD_OR_UNION_CHECK (NODE))) |
| 202 |
|
| 203 |
/* For an UNCONSTRAINED_ARRAY_TYPE, this is the record containing both the |
| 204 |
template and the object. |
| 205 |
|
| 206 |
??? We also put this on an ENUMERAL_TYPE that is dummy. Technically, |
| 207 |
this is a conflict on the minval field, but there doesn't seem to be |
| 208 |
simple fix, so we'll live with this kludge for now. */ |
| 209 |
#define TYPE_OBJECT_RECORD_TYPE(NODE) \ |
| 210 |
(TYPE_MIN_VALUE_RAW (TREE_CHECK2 ((NODE), UNCONSTRAINED_ARRAY_TYPE, \ |
| 211 |
ENUMERAL_TYPE))) |
| 212 |
|
| 213 |
/* For numerical types, this is the GCC lower bound of the type. The GCC |
| 214 |
type system is based on the invariant that an object X of a given type |
| 215 |
cannot hold at run time a value smaller than its lower bound; otherwise |
| 216 |
the behavior is undefined. The optimizer takes advantage of this and |
| 217 |
considers that the assertion X >= LB is always true. */ |
| 218 |
#define TYPE_GCC_MIN_VALUE(NODE) \ |
| 219 |
(TYPE_MIN_VALUE_RAW (NUMERICAL_TYPE_CHECK (NODE))) |
| 220 |
|
| 221 |
/* For numerical types, this is the GCC upper bound of the type. The GCC |
| 222 |
type system is based on the invariant that an object X of a given type |
| 223 |
cannot hold at run time a value larger than its upper bound; otherwise |
| 224 |
the behavior is undefined. The optimizer takes advantage of this and |
| 225 |
considers that the assertion X <= UB is always true. */ |
| 226 |
#define TYPE_GCC_MAX_VALUE(NODE) \ |
| 227 |
(TYPE_MAX_VALUE_RAW (NUMERICAL_TYPE_CHECK (NODE))) |
| 228 |
|
| 229 |
/* For a FUNCTION_TYPE and METHOD_TYPE, if the function has parameters passed |
| 230 |
by copy in/copy out, this is the list of nodes used to specify the return |
| 231 |
values of these parameters. For a full description of the copy in/copy out |
| 232 |
parameter passing mechanism refer to the routine gnat_to_gnu_entity. */ |
| 233 |
#define TYPE_CI_CO_LIST(NODE) TYPE_LANG_SLOT_1 (FUNC_OR_METHOD_CHECK (NODE)) |
| 234 |
|
| 235 |
/* For an ARRAY_TYPE with variable size, this is the padding type built for |
| 236 |
the array type when it is itself the component type of another array. */ |
| 237 |
#define TYPE_PADDING_FOR_COMPONENT(NODE) \ |
| 238 |
TYPE_LANG_SLOT_1 (ARRAY_TYPE_CHECK (NODE)) |
| 239 |
|
| 240 |
/* For a VECTOR_TYPE, this is the representative array type. */ |
| 241 |
#define TYPE_REPRESENTATIVE_ARRAY(NODE) \ |
| 242 |
TYPE_LANG_SLOT_1 (VECTOR_TYPE_CHECK (NODE)) |
| 243 |
|
| 244 |
/* For numerical types, this holds various RM-defined values. */ |
| 245 |
#define TYPE_RM_VALUES(NODE) TYPE_LANG_SLOT_1 (NUMERICAL_TYPE_CHECK (NODE)) |
| 246 |
|
| 247 |
/* Macros to get and set the individual values in TYPE_RM_VALUES. */ |
| 248 |
#define TYPE_RM_VALUE(NODE, N) \ |
| 249 |
(TYPE_RM_VALUES (NODE) \ |
| 250 |
? TREE_VEC_ELT (TYPE_RM_VALUES (NODE), (N)) : NULL_TREE) |
| 251 |
|
| 252 |
#define SET_TYPE_RM_VALUE(NODE, N, X) \ |
| 253 |
do { \ |
| 254 |
tree tmp = (X); \ |
| 255 |
if (!TYPE_RM_VALUES (NODE)) \ |
| 256 |
TYPE_RM_VALUES (NODE) = make_tree_vec (3); \ |
| 257 |
/* ??? The field is not visited by the generic \ |
| 258 |
code so we need to mark it manually. */ \ |
| 259 |
MARK_VISITED (tmp); \ |
| 260 |
TREE_VEC_ELT (TYPE_RM_VALUES (NODE), (N)) = tmp; \ |
| 261 |
} while (0) |
| 262 |
|
| 263 |
/* For numerical types, this is the RM size of the type, aka its precision. |
| 264 |
There is a discrepancy between what is called precision here (and more |
| 265 |
generally throughout gigi) and what is called precision in the GCC type |
| 266 |
system: in the former case it's TYPE_RM_SIZE whereas it's TYPE_PRECISION |
| 267 |
in the latter case. They are not identical because of the need to support |
| 268 |
invalid values. |
| 269 |
|
| 270 |
These values can be outside the range of values allowed by the RM size |
| 271 |
but they must nevertheless be valid in the GCC type system, otherwise |
| 272 |
the optimizer can pretend that they simply don't exist. Therefore they |
| 273 |
must be within the range of values allowed by the precision in the GCC |
| 274 |
sense, hence TYPE_PRECISION be set to the Esize, not the RM size. */ |
| 275 |
#define TYPE_RM_SIZE(NODE) TYPE_RM_VALUE ((NODE), 0) |
| 276 |
#define SET_TYPE_RM_SIZE(NODE, X) SET_TYPE_RM_VALUE ((NODE), 0, (X)) |
| 277 |
|
| 278 |
/* For numerical types, this is the RM lower bound of the type. There is |
| 279 |
again a discrepancy between this lower bound and the GCC lower bound, |
| 280 |
again because of the need to support invalid values. |
| 281 |
|
| 282 |
These values can be outside the range of values allowed by the RM lower |
| 283 |
bound but they must nevertheless be valid in the GCC type system, otherwise |
| 284 |
the optimizer can pretend that they simply don't exist. Therefore they |
| 285 |
must be within the range of values allowed by the lower bound in the GCC |
| 286 |
sense, hence the GCC lower bound be set to that of the base type. |
| 287 |
|
| 288 |
This lower bound is translated directly without the adjustments that may |
| 289 |
be required for type compatibility, so it will generally be necessary to |
| 290 |
convert it to the base type of the numerical type before using it. */ |
| 291 |
#define TYPE_RM_MIN_VALUE(NODE) TYPE_RM_VALUE ((NODE), 1) |
| 292 |
#define SET_TYPE_RM_MIN_VALUE(NODE, X) SET_TYPE_RM_VALUE ((NODE), 1, (X)) |
| 293 |
|
| 294 |
/* For numerical types, this is the RM upper bound of the type. There is |
| 295 |
again a discrepancy between this upper bound and the GCC upper bound, |
| 296 |
again because of the need to support invalid values. |
| 297 |
|
| 298 |
These values can be outside the range of values allowed by the RM upper |
| 299 |
bound but they must nevertheless be valid in the GCC type system, otherwise |
| 300 |
the optimizer can pretend that they simply don't exist. Therefore they |
| 301 |
must be within the range of values allowed by the upper bound in the GCC |
| 302 |
sense, hence the GCC upper bound be set to that of the base type. |
| 303 |
|
| 304 |
This upper bound is translated directly without the adjustments that may |
| 305 |
be required for type compatibility, so it will generally be necessary to |
| 306 |
convert it to the base type of the numerical type before using it. */ |
| 307 |
#define TYPE_RM_MAX_VALUE(NODE) TYPE_RM_VALUE ((NODE), 2) |
| 308 |
#define SET_TYPE_RM_MAX_VALUE(NODE, X) SET_TYPE_RM_VALUE ((NODE), 2, (X)) |
| 309 |
|
| 310 |
/* For numerical types, this is the lower bound of the type, i.e. the RM lower |
| 311 |
bound for language-defined types and the GCC lower bound for others. */ |
| 312 |
#undef TYPE_MIN_VALUE |
| 313 |
#define TYPE_MIN_VALUE(NODE) \ |
| 314 |
(TYPE_RM_MIN_VALUE (NODE) \ |
| 315 |
? TYPE_RM_MIN_VALUE (NODE) : TYPE_GCC_MIN_VALUE (NODE)) |
| 316 |
|
| 317 |
/* For numerical types, this is the upper bound of the type, i.e. the RM upper |
| 318 |
bound for language-defined types and the GCC upper bound for others. */ |
| 319 |
#undef TYPE_MAX_VALUE |
| 320 |
#define TYPE_MAX_VALUE(NODE) \ |
| 321 |
(TYPE_RM_MAX_VALUE (NODE) \ |
| 322 |
? TYPE_RM_MAX_VALUE (NODE) : TYPE_GCC_MAX_VALUE (NODE)) |
| 323 |
|
| 324 |
/* For an INTEGER_TYPE with TYPE_MODULAR_P, this is the value of the |
| 325 |
modulus. */ |
| 326 |
#define TYPE_MODULUS(NODE) \ |
| 327 |
GET_TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE)) |
| 328 |
#define SET_TYPE_MODULUS(NODE, X) \ |
| 329 |
SET_TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE), X) |
| 330 |
|
| 331 |
/* For an INTEGER_TYPE that is the TYPE_DOMAIN of some ARRAY_TYPE, this is |
| 332 |
the type corresponding to the Ada index type. It is necessary to keep |
| 333 |
these 2 views for every array type because the TYPE_DOMAIN is subject |
| 334 |
to strong constraints in GENERIC: it must be a subtype of SIZETYPE and |
| 335 |
may not be superflat, i.e. the upper bound must always be larger or |
| 336 |
equal to the lower bound minus 1 (i.e. the canonical length formula |
| 337 |
must always yield a non-negative number), which means that at least |
| 338 |
one of the bounds may need to be a conditional expression. There are |
| 339 |
no such constraints on the TYPE_INDEX_TYPE because gigi is prepared to |
| 340 |
deal with the superflat case; moreover the TYPE_INDEX_TYPE is used as |
| 341 |
the index type for the debug info and, therefore, needs to be as close |
| 342 |
as possible to the source index type. */ |
| 343 |
#define TYPE_INDEX_TYPE(NODE) \ |
| 344 |
GET_TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE)) |
| 345 |
#define SET_TYPE_INDEX_TYPE(NODE, X) \ |
| 346 |
SET_TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE), X) |
| 347 |
|
| 348 |
/* For an INTEGER_TYPE with TYPE_HAS_ACTUAL_BOUNDS_P or an ARRAY_TYPE, this is |
| 349 |
the index type that should be used when the actual bounds are required for |
| 350 |
a template. This is used in the case of packed arrays. */ |
| 351 |
#define TYPE_ACTUAL_BOUNDS(NODE) \ |
| 352 |
GET_TYPE_LANG_SPECIFIC (TREE_CHECK2 (NODE, INTEGER_TYPE, ARRAY_TYPE)) |
| 353 |
#define SET_TYPE_ACTUAL_BOUNDS(NODE, X) \ |
| 354 |
SET_TYPE_LANG_SPECIFIC (TREE_CHECK2 (NODE, INTEGER_TYPE, ARRAY_TYPE), X) |
| 355 |
|
| 356 |
/* For a POINTER_TYPE that points to the template type of an unconstrained |
| 357 |
array type, this is the address to be used in a null fat pointer. */ |
| 358 |
#define TYPE_NULL_BOUNDS(NODE) \ |
| 359 |
GET_TYPE_LANG_SPECIFIC (POINTER_TYPE_CHECK (NODE)) |
| 360 |
#define SET_TYPE_NULL_BOUNDS(NODE, X) \ |
| 361 |
SET_TYPE_LANG_SPECIFIC (POINTER_TYPE_CHECK (NODE), X) |
| 362 |
|
| 363 |
/* For a RECORD_TYPE that is a fat pointer, this is the type for the |
| 364 |
unconstrained array. Likewise for a RECORD_TYPE that is pointed |
| 365 |
to by a thin pointer, if it is made for the unconstrained array |
| 366 |
type itself; the field is NULL_TREE if the RECORD_TYPE is made |
| 367 |
for a constrained subtype of the array type. */ |
| 368 |
#define TYPE_UNCONSTRAINED_ARRAY(NODE) \ |
| 369 |
GET_TYPE_LANG_SPECIFIC (RECORD_TYPE_CHECK (NODE)) |
| 370 |
#define SET_TYPE_UNCONSTRAINED_ARRAY(NODE, X) \ |
| 371 |
SET_TYPE_LANG_SPECIFIC (RECORD_TYPE_CHECK (NODE), X) |
| 372 |
|
| 373 |
/* For other RECORD_TYPEs and all UNION_TYPEs and QUAL_UNION_TYPEs, this is |
| 374 |
the Ada size of the object. This differs from the GCC size in that it |
| 375 |
does not include any rounding up to the alignment of the type. */ |
| 376 |
#define TYPE_ADA_SIZE(NODE) \ |
| 377 |
GET_TYPE_LANG_SPECIFIC (RECORD_OR_UNION_CHECK (NODE)) |
| 378 |
#define SET_TYPE_ADA_SIZE(NODE, X) \ |
| 379 |
SET_TYPE_LANG_SPECIFIC (RECORD_OR_UNION_CHECK (NODE), X) |
| 380 |
|
| 381 |
/* For an INTEGER_TYPE with TYPE_IS_FIXED_POINT_P, this is the value of the |
| 382 |
scale factor. Modular types, index types (sizetype subtypes) and |
| 383 |
fixed-point types are totally distinct types, so there is no problem with |
| 384 |
sharing type lang specific's first slot. */ |
| 385 |
#define TYPE_SCALE_FACTOR(NODE) \ |
| 386 |
GET_TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE)) |
| 387 |
#define SET_TYPE_SCALE_FACTOR(NODE, X) \ |
| 388 |
SET_TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE), X) |
| 389 |
|
| 390 |
/* For types with TYPE_CAN_HAVE_DEBUG_TYPE_P, this is the type to use in |
| 391 |
debugging information. */ |
| 392 |
#define TYPE_DEBUG_TYPE(NODE) \ |
| 393 |
GET_TYPE_LANG_SPECIFIC2 (NODE) |
| 394 |
#define SET_TYPE_DEBUG_TYPE(NODE, X) \ |
| 395 |
SET_TYPE_LANG_SPECIFIC2 (NODE, X) |
| 396 |
|
| 397 |
/* For types with TYPE_IMPL_PACKED_ARRAY_P, this is the original packed |
| 398 |
array type. Note that this predicate is true for original packed array |
| 399 |
types, so these cannot have a debug type. */ |
| 400 |
#define TYPE_ORIGINAL_PACKED_ARRAY(NODE) \ |
| 401 |
GET_TYPE_LANG_SPECIFIC2 (NODE) |
| 402 |
#define SET_TYPE_ORIGINAL_PACKED_ARRAY(NODE, X) \ |
| 403 |
SET_TYPE_LANG_SPECIFIC2 (NODE, X) |
| 404 |
|
| 405 |
|
| 406 |
/* Flags added to decl nodes. */ |
| 407 |
|
| 408 |
/* Nonzero in a VAR_DECL if it is guaranteed to be constant after having |
| 409 |
been elaborated and TREE_READONLY is not set on it. */ |
| 410 |
#define DECL_READONLY_ONCE_ELAB(NODE) DECL_LANG_FLAG_0 (VAR_DECL_CHECK (NODE)) |
| 411 |
|
| 412 |
/* Nonzero in a CONST_DECL if its value is (essentially) the address of a |
| 413 |
constant CONSTRUCTOR. */ |
| 414 |
#define DECL_CONST_ADDRESS_P(NODE) DECL_LANG_FLAG_0 (CONST_DECL_CHECK (NODE)) |
| 415 |
|
| 416 |
/* Nonzero in a FIELD_DECL if it is declared as aliased. */ |
| 417 |
#define DECL_ALIASED_P(NODE) DECL_LANG_FLAG_0 (FIELD_DECL_CHECK (NODE)) |
| 418 |
|
| 419 |
/* Nonzero in a TYPE_DECL if this is the declaration of a Taft amendment type |
| 420 |
in the main unit, i.e. the full declaration is available. */ |
| 421 |
#define DECL_TAFT_TYPE_P(NODE) DECL_LANG_FLAG_0 (TYPE_DECL_CHECK (NODE)) |
| 422 |
|
| 423 |
/* Nonzero in a PARM_DECL passed by reference but for which only a restricted |
| 424 |
form of aliasing is allowed. The first restriction comes explicitly from |
| 425 |
the RM 6.2(12) clause: there is no read-after-write dependency between a |
| 426 |
store based on such a PARM_DECL and a load not based on this PARM_DECL, |
| 427 |
so stores based on such PARM_DECLs can be sunk past all loads based on |
| 428 |
a distinct object. The second restriction can be inferred from the same |
| 429 |
clause: there is no write-after-write dependency between a store based |
| 430 |
on such a PARM_DECL and a store based on a distinct such PARM_DECL, as |
| 431 |
the compiler would be allowed to pass the parameters by copy and the |
| 432 |
order of assignment to actual parameters after a call is arbitrary as |
| 433 |
per the RM 6.4.1(17) clause, so stores based on distinct such PARM_DECLs |
| 434 |
can be swapped. */ |
| 435 |
#define DECL_RESTRICTED_ALIASING_P(NODE) \ |
| 436 |
DECL_LANG_FLAG_0 (PARM_DECL_CHECK (NODE)) |
| 437 |
|
| 438 |
/* Nonzero in a DECL if it is always used by reference, i.e. an INDIRECT_REF |
| 439 |
is needed to access the object. */ |
| 440 |
#define DECL_BY_REF_P(NODE) DECL_LANG_FLAG_1 (NODE) |
| 441 |
|
| 442 |
/* Nonzero in a DECL if it is made for a pointer that can never be null. */ |
| 443 |
#define DECL_CAN_NEVER_BE_NULL_P(NODE) DECL_LANG_FLAG_2 (NODE) |
| 444 |
|
| 445 |
/* Nonzero in a VAR_DECL if it is made for a loop parameter. */ |
| 446 |
#define DECL_LOOP_PARM_P(NODE) DECL_LANG_FLAG_3 (VAR_DECL_CHECK (NODE)) |
| 447 |
|
| 448 |
/* Nonzero in a FIELD_DECL that is a dummy built for some internal reason. */ |
| 449 |
#define DECL_INTERNAL_P(NODE) DECL_LANG_FLAG_3 (FIELD_DECL_CHECK (NODE)) |
| 450 |
|
| 451 |
/* Nonzero in a PARM_DECL if it is made for an Ada array being passed to a |
| 452 |
foreign convention subprogram. */ |
| 453 |
#define DECL_BY_COMPONENT_PTR_P(NODE) DECL_LANG_FLAG_3 (PARM_DECL_CHECK (NODE)) |
| 454 |
|
| 455 |
/* Nonzero in a FUNCTION_DECL that corresponds to an elaboration procedure. */ |
| 456 |
#define DECL_ELABORATION_PROC_P(NODE) \ |
| 457 |
DECL_LANG_FLAG_3 (FUNCTION_DECL_CHECK (NODE)) |
| 458 |
|
| 459 |
/* Nonzero in a CONST_DECL, VAR_DECL or PARM_DECL if it is made for a pointer |
| 460 |
that points to something which is readonly. */ |
| 461 |
#define DECL_POINTS_TO_READONLY_P(NODE) DECL_LANG_FLAG_4 (NODE) |
| 462 |
|
| 463 |
/* Nonzero in a FIELD_DECL if it is invariant once set, for example if it is |
| 464 |
a discriminant of a discriminated type without default expression. */ |
| 465 |
#define DECL_INVARIANT_P(NODE) DECL_LANG_FLAG_4 (FIELD_DECL_CHECK (NODE)) |
| 466 |
|
| 467 |
/* Nonzero in a FUNCTION_DECL if this is a definition, i.e. if it was created |
| 468 |
by a call to gnat_to_gnu_entity with definition set to True. */ |
| 469 |
#define DECL_FUNCTION_IS_DEF(NODE) \ |
| 470 |
DECL_LANG_FLAG_4 (FUNCTION_DECL_CHECK (NODE)) |
| 471 |
|
| 472 |
/* Nonzero in a VAR_DECL if it is a temporary created to hold the return |
| 473 |
value of a function call or 'reference to a function call. */ |
| 474 |
#define DECL_RETURN_VALUE_P(NODE) DECL_LANG_FLAG_5 (VAR_DECL_CHECK (NODE)) |
| 475 |
|
| 476 |
/* Nonzero in a PARM_DECL if its mechanism was forced to by-reference. */ |
| 477 |
#define DECL_FORCED_BY_REF_P(NODE) DECL_LANG_FLAG_5 (PARM_DECL_CHECK (NODE)) |
| 478 |
|
| 479 |
/* In a FIELD_DECL corresponding to a discriminant, contains the |
| 480 |
discriminant number. */ |
| 481 |
#define DECL_DISCRIMINANT_NUMBER(NODE) DECL_INITIAL (FIELD_DECL_CHECK (NODE)) |
| 482 |
|
| 483 |
/* In a CONST_DECL, points to a VAR_DECL that is allocatable to |
| 484 |
memory. Used when a scalar constant is aliased or has its |
| 485 |
address taken. */ |
| 486 |
#define DECL_CONST_CORRESPONDING_VAR(NODE) \ |
| 487 |
GET_DECL_LANG_SPECIFIC (CONST_DECL_CHECK (NODE)) |
| 488 |
#define SET_DECL_CONST_CORRESPONDING_VAR(NODE, X) \ |
| 489 |
SET_DECL_LANG_SPECIFIC (CONST_DECL_CHECK (NODE), X) |
| 490 |
|
| 491 |
/* In a FIELD_DECL, points to the FIELD_DECL that was the ultimate |
| 492 |
source of the decl. */ |
| 493 |
#define DECL_ORIGINAL_FIELD(NODE) \ |
| 494 |
GET_DECL_LANG_SPECIFIC (FIELD_DECL_CHECK (NODE)) |
| 495 |
#define SET_DECL_ORIGINAL_FIELD(NODE, X) \ |
| 496 |
SET_DECL_LANG_SPECIFIC (FIELD_DECL_CHECK (NODE), X) |
| 497 |
|
| 498 |
/* Set DECL_ORIGINAL_FIELD of FIELD1 to (that of) FIELD2. */ |
| 499 |
#define SET_DECL_ORIGINAL_FIELD_TO_FIELD(FIELD1, FIELD2) \ |
| 500 |
SET_DECL_ORIGINAL_FIELD ((FIELD1), \ |
| 501 |
DECL_ORIGINAL_FIELD (FIELD2) \ |
| 502 |
? DECL_ORIGINAL_FIELD (FIELD2) : (FIELD2)) |
| 503 |
|
| 504 |
/* Return true if FIELD1 and FIELD2 represent the same field. */ |
| 505 |
#define SAME_FIELD_P(FIELD1, FIELD2) \ |
| 506 |
((FIELD1) == (FIELD2) \ |
| 507 |
|| DECL_ORIGINAL_FIELD (FIELD1) == (FIELD2) \ |
| 508 |
|| (FIELD1) == DECL_ORIGINAL_FIELD (FIELD2) \ |
| 509 |
|| (DECL_ORIGINAL_FIELD (FIELD1) \ |
| 510 |
&& (DECL_ORIGINAL_FIELD (FIELD1) == DECL_ORIGINAL_FIELD (FIELD2)))) |
| 511 |
|
| 512 |
/* In a VAR_DECL with the DECL_LOOP_PARM_P flag set, points to the special |
| 513 |
induction variable that is built under certain circumstances, if any. */ |
| 514 |
#define DECL_INDUCTION_VAR(NODE) \ |
| 515 |
GET_DECL_LANG_SPECIFIC (VAR_DECL_CHECK (NODE)) |
| 516 |
#define SET_DECL_INDUCTION_VAR(NODE, X) \ |
| 517 |
SET_DECL_LANG_SPECIFIC (VAR_DECL_CHECK (NODE), X) |
| 518 |
|
| 519 |
/* In a TYPE_DECL, points to the parallel type if any, otherwise 0. */ |
| 520 |
#define DECL_PARALLEL_TYPE(NODE) \ |
| 521 |
GET_DECL_LANG_SPECIFIC (TYPE_DECL_CHECK (NODE)) |
| 522 |
#define SET_DECL_PARALLEL_TYPE(NODE, X) \ |
| 523 |
SET_DECL_LANG_SPECIFIC (TYPE_DECL_CHECK (NODE), X) |
| 524 |
|
| 525 |
|
| 526 |
/* Flags added to ref nodes. */ |
| 527 |
|
| 528 |
/* Nonzero means this node will not trap. */ |
| 529 |
#undef TREE_THIS_NOTRAP |
| 530 |
#define TREE_THIS_NOTRAP(NODE) \ |
| 531 |
(TREE_CHECK4 (NODE, INDIRECT_REF, ARRAY_REF, UNCONSTRAINED_ARRAY_REF, \ |
| 532 |
ARRAY_RANGE_REF)->base.nothrow_flag) |
| 533 |
|
| 534 |
|
| 535 |
/* Fields and macros for statements. */ |
| 536 |
#define IS_ADA_STMT(NODE) \ |
| 537 |
(STATEMENT_CLASS_P (NODE) && TREE_CODE (NODE) >= STMT_STMT) |
| 538 |
|
| 539 |
#define STMT_STMT_STMT(NODE) TREE_OPERAND_CHECK_CODE (NODE, STMT_STMT, 0) |
| 540 |
|
| 541 |
#define LOOP_STMT_COND(NODE) TREE_OPERAND_CHECK_CODE (NODE, LOOP_STMT, 0) |
| 542 |
#define LOOP_STMT_UPDATE(NODE) TREE_OPERAND_CHECK_CODE (NODE, LOOP_STMT, 1) |
| 543 |
#define LOOP_STMT_BODY(NODE) TREE_OPERAND_CHECK_CODE (NODE, LOOP_STMT, 2) |
| 544 |
#define LOOP_STMT_LABEL(NODE) TREE_OPERAND_CHECK_CODE (NODE, LOOP_STMT, 3) |
| 545 |
|
| 546 |
/* A loop statement is conceptually made up of 6 sub-statements: |
| 547 |
|
| 548 |
loop: |
| 549 |
TOP_CONDITION |
| 550 |
TOP_UPDATE |
| 551 |
BODY |
| 552 |
BOTTOM_CONDITION |
| 553 |
BOTTOM_UPDATE |
| 554 |
GOTO loop |
| 555 |
|
| 556 |
However, only 4 of them can exist for a given loop, the pair of conditions |
| 557 |
and the pair of updates being mutually exclusive. The default setting is |
| 558 |
TOP_CONDITION and BOTTOM_UPDATE and the following couple of flags are used |
| 559 |
to toggle the individual settings. */ |
| 560 |
#define LOOP_STMT_BOTTOM_COND_P(NODE) TREE_LANG_FLAG_0 (LOOP_STMT_CHECK (NODE)) |
| 561 |
#define LOOP_STMT_TOP_UPDATE_P(NODE) TREE_LANG_FLAG_1 (LOOP_STMT_CHECK (NODE)) |
| 562 |
|
| 563 |
/* Optimization hints on loops. */ |
| 564 |
#define LOOP_STMT_IVDEP(NODE) TREE_LANG_FLAG_2 (LOOP_STMT_CHECK (NODE)) |
| 565 |
#define LOOP_STMT_NO_UNROLL(NODE) TREE_LANG_FLAG_3 (LOOP_STMT_CHECK (NODE)) |
| 566 |
#define LOOP_STMT_UNROLL(NODE) TREE_LANG_FLAG_4 (LOOP_STMT_CHECK (NODE)) |
| 567 |
#define LOOP_STMT_NO_VECTOR(NODE) TREE_LANG_FLAG_5 (LOOP_STMT_CHECK (NODE)) |
| 568 |
#define LOOP_STMT_VECTOR(NODE) TREE_LANG_FLAG_6 (LOOP_STMT_CHECK (NODE)) |
| 569 |
|
| 570 |
#define EXIT_STMT_COND(NODE) TREE_OPERAND_CHECK_CODE (NODE, EXIT_STMT, 0) |
| 571 |
#define EXIT_STMT_LABEL(NODE) TREE_OPERAND_CHECK_CODE (NODE, EXIT_STMT, 1) |
| 572 |
|
| 573 |
/* Small kludge to be able to define Ada built-in functions locally. |
| 574 |
We overload them on top of the C++ coroutines builtin functions. */ |
| 575 |
#define BUILT_IN_LIKELY BUILT_IN_CORO_PROMISE |
| 576 |
#define BUILT_IN_UNLIKELY BUILT_IN_CORO_RESUME |
| 577 |
#define BUILT_IN_RETURN_SLOT BUILT_IN_CORO_DESTROY |