1 /****************************************************************************
3 * GNAT COMPILER COMPONENTS *
9 * Copyright (C) 1992-2003 Free Software Foundation, Inc. *
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 2, 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 distributed with GNAT; see file COPYING. If not, write *
19 * to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, *
20 * MA 02111-1307, USA. *
22 * GNAT was originally developed by the GNAT team at New York University. *
23 * Extensive contributions were provided by Ada Core Technologies Inc. *
25 ****************************************************************************/
27 /* Ada language-specific GC tree codes. */
28 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) SYM,
30 __DUMMY = LAST_AND_UNUSED_TREE_CODE,
31 #include "ada-tree.def"
36 /* A tree to hold a loop ID. */
37 struct tree_loop_id GTY(())
39 struct tree_common common;
40 struct nesting *loop_id;
43 /* The language-specific tree. */
45 GTY((desc ("TREE_CODE (&%h.generic) == GNAT_LOOP_ID"),
46 chain_next ("(union lang_tree_node *)TREE_CHAIN (&%h.generic)")))
48 union tree_node GTY ((tag ("0"),
49 desc ("tree_node_structure (&%h)")))
51 struct tree_loop_id GTY ((tag ("1"))) loop_id;
54 /* Ada uses the lang_decl and lang_type fields to hold more trees. */
55 struct lang_decl GTY(())
58 GTY((desc ("TREE_CODE (&%h.generic) == GNAT_LOOP_ID"))) t;
60 struct lang_type GTY(())
63 GTY((desc ("TREE_CODE (&%h.generic) == GNAT_LOOP_ID"))) t;
66 /* Flags added to GCC type nodes. */
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_IS_FAT_POINTER_P(NODE) TYPE_LANG_FLAG_0 (NODE)
72 #define TYPE_FAT_POINTER_P(NODE) \
73 (TREE_CODE (NODE) == RECORD_TYPE && TYPE_IS_FAT_POINTER_P (NODE))
75 /* For integral types, nonzero if this is a packed array type. Such
76 types should not be extended to a larger size. */
77 #define TYPE_PACKED_ARRAY_TYPE_P(NODE) TYPE_LANG_FLAG_0 (NODE)
79 /* For INTEGER_TYPE, nonzero if this is a modular type with a modulus that
80 is not equal to two to the power of its mode's size. */
81 #define TYPE_MODULAR_P(NODE) TYPE_LANG_FLAG_1 (INTEGER_TYPE_CHECK (NODE))
83 /* For ARRAY_TYPE, nonzero if this type corresponds to a dimension of
84 an Ada array other than the first. */
85 #define TYPE_MULTI_ARRAY_P(NODE) TYPE_LANG_FLAG_1 (ARRAY_TYPE_CHECK (NODE))
87 /* For FUNCTION_TYPE, nonzero if this denotes a function returning an
88 unconstrained array or record. */
89 #define TYPE_RETURNS_UNCONSTRAINED_P(NODE) \
90 TYPE_LANG_FLAG_1 (FUNCTION_TYPE_CHECK (NODE))
92 /* For RECORD_TYPE, UNION_TYPE, and QUAL_UNION_TYPE, nonzero if this denotes
93 a left-justified modular type (will only be true for RECORD_TYPE). */
94 #define TYPE_LEFT_JUSTIFIED_MODULAR_P(NODE) TYPE_LANG_FLAG_1 (NODE)
96 /* Nonzero in an arithmetic subtype if this is a subtype not known to the
98 #define TYPE_EXTRA_SUBTYPE_P(NODE) TYPE_LANG_FLAG_2 (NODE)
100 /* Nonzero for composite types if this is a by-reference type. */
101 #define TYPE_BY_REFERENCE_P(NODE) TYPE_LANG_FLAG_2 (NODE)
103 /* For RECORD_TYPE, UNION_TYPE, and QUAL_UNION_TYPE, nonzero if this is the
104 type for an object whose type includes its template in addition to
105 its value (only true for RECORD_TYPE). */
106 #define TYPE_CONTAINS_TEMPLATE_P(NODE) TYPE_LANG_FLAG_3 (NODE)
108 /* For INTEGER_TYPE, nonzero if this really represents a VAX
109 floating-point type. */
110 #define TYPE_VAX_FLOATING_POINT_P(NODE) \
111 TYPE_LANG_FLAG_3 (INTEGER_TYPE_CHECK (NODE))
113 /* True if NODE is a thin pointer. */
114 #define TYPE_THIN_POINTER_P(NODE) \
115 (POINTER_TYPE_P (NODE) \
116 && TREE_CODE (TREE_TYPE (NODE)) == RECORD_TYPE \
117 && TYPE_CONTAINS_TEMPLATE_P (TREE_TYPE (NODE)))
119 /* True if TYPE is either a fat or thin pointer to an unconstrained
121 #define TYPE_FAT_OR_THIN_POINTER_P(NODE) \
122 (TYPE_FAT_POINTER_P (NODE) || TYPE_THIN_POINTER_P (NODE))
124 /* For INTEGER_TYPEs, nonzero if the type has a biased representation. */
125 #define TYPE_BIASED_REPRESENTATION_P(NODE) \
126 TYPE_LANG_FLAG_4 (INTEGER_TYPE_CHECK (NODE))
128 /* For ARRAY_TYPEs, nonzero if the array type has Convention_Fortran. */
129 #define TYPE_CONVENTION_FORTRAN_P(NODE) \
130 TYPE_LANG_FLAG_4 (ARRAY_TYPE_CHECK (NODE))
132 /* For FUNCTION_TYPEs, nonzero if the function returns by reference. */
133 #define TYPE_RETURNS_BY_REF_P(NODE) \
134 TYPE_LANG_FLAG_4 (FUNCTION_TYPE_CHECK (NODE))
136 /* For VOID_TYPE, ENUMERAL_TYPE, UNION_TYPE, and RECORD_TYPE, nonzero if this
137 is a dummy type, made to correspond to a private or incomplete type. */
138 #define TYPE_DUMMY_P(NODE) TYPE_LANG_FLAG_4 (NODE)
140 /* True if TYPE is such a dummy type. */
141 #define TYPE_IS_DUMMY_P(NODE) \
142 ((TREE_CODE (NODE) == VOID_TYPE || TREE_CODE (NODE) == RECORD_TYPE \
143 || TREE_CODE (NODE) == UNION_TYPE || TREE_CODE (NODE) == ENUMERAL_TYPE) \
144 && TYPE_DUMMY_P (NODE))
146 /* For an INTEGER_TYPE, nonzero if TYPE_ACTUAL_BOUNDS is present. */
147 #define TYPE_HAS_ACTUAL_BOUNDS_P(NODE) \
148 TYPE_LANG_FLAG_5 (INTEGER_TYPE_CHECK (NODE))
150 /* For a RECORD_TYPE, nonzero if this was made just to supply needed
151 padding or alignment. */
152 #define TYPE_IS_PADDING_P(NODE) TYPE_LANG_FLAG_5 (RECORD_TYPE_CHECK (NODE))
154 /* This field is only defined for FUNCTION_TYPE nodes. If the Ada
155 subprogram contains no parameters passed by copy in/copy out then this
156 field is 0. Otherwise it points to a list of nodes used to specify the
157 return values of the out (or in out) parameters that qualify to be passed
158 by copy in copy out. It is a CONSTRUCTOR. For a full description of the
159 cico parameter passing mechanism refer to the routine gnat_to_gnu_entity. */
160 #define TYPE_CI_CO_LIST(NODE) \
161 (&TYPE_LANG_SPECIFIC (FUNCTION_TYPE_CHECK (NODE))->t.generic)
162 #define SET_TYPE_CI_CO_LIST(NODE, X) \
163 (TYPE_LANG_SPECIFIC (FUNCTION_TYPE_CHECK (NODE)) = (struct lang_type *)(X))
165 /* For an INTEGER_TYPE with TYPE_MODULAR_P, this is the value of the
167 #define TYPE_MODULUS(NODE) \
168 (&TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE))->t.generic)
169 #define SET_TYPE_MODULUS(NODE, X) \
170 (TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE)) = (struct lang_type *)(X))
172 /* For an INTEGER_TYPE that is the TYPE_DOMAIN of some ARRAY_TYPE, points to
173 the type corresponding to the Ada index type. */
174 #define TYPE_INDEX_TYPE(NODE) \
175 (&TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE))->t.generic)
176 #define SET_TYPE_INDEX_TYPE(NODE, X) \
177 (TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE)) = (struct lang_type *)(X))
179 /* For an INTEGER_TYPE with TYPE_VAX_FLOATING_POINT_P, stores the
181 #define TYPE_DIGITS_VALUE(NODE) \
182 ((long) TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE)))
183 #define SET_TYPE_DIGITS_VALUE(NODE, X) \
184 (TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE)) = (struct lang_type *)(size_t)(X))
186 /* For INTEGER_TYPE, stores the RM_Size of the type. */
187 #define TYPE_RM_SIZE_INT(NODE) TYPE_VALUES (INTEGER_TYPE_CHECK (NODE))
189 /* Likewise for ENUMERAL_TYPE. */
190 #define TYPE_RM_SIZE_ENUM(NODE) \
191 (&TYPE_LANG_SPECIFIC (ENUMERAL_TYPE_CHECK (NODE))->t.generic)
192 #define SET_TYPE_RM_SIZE_ENUM(NODE, X) \
193 (TYPE_LANG_SPECIFIC (ENUMERAL_TYPE_CHECK (NODE)) = (struct lang_type *)(X))
195 #define TYPE_RM_SIZE(NODE) \
196 (TREE_CODE (NODE) == ENUMERAL_TYPE ? TYPE_RM_SIZE_ENUM (NODE) \
197 : TREE_CODE (NODE) == INTEGER_TYPE ? TYPE_RM_SIZE_INT (NODE) \
200 /* For a RECORD_TYPE that is a fat pointer, point to the type for the
201 unconstrained object. Likewise for a RECORD_TYPE that is pointed
202 to by a thin pointer. */
203 #define TYPE_UNCONSTRAINED_ARRAY(NODE) \
204 (&TYPE_LANG_SPECIFIC (RECORD_TYPE_CHECK (NODE))->t.generic)
205 #define SET_TYPE_UNCONSTRAINED_ARRAY(NODE, X) \
206 (TYPE_LANG_SPECIFIC (RECORD_TYPE_CHECK (NODE)) = (struct lang_type *)(X))
208 /* For other RECORD_TYPEs and all UNION_TYPEs and QUAL_UNION_TYPEs, the Ada
209 size of the object. This differs from the GCC size in that it does not
210 include any rounding up to the alignment of the type. */
211 #define TYPE_ADA_SIZE(NODE) (&TYPE_LANG_SPECIFIC (NODE)->t.generic)
212 #define SET_TYPE_ADA_SIZE(NODE, X) \
213 (TYPE_LANG_SPECIFIC (NODE) = (struct lang_type *)(X))
215 /* For an INTEGER_TYPE with TYPE_HAS_ACTUAL_BOUNDS_P or an ARRAY_TYPE, this is
216 the index type that should be used when the actual bounds are required for
217 a template. This is used in the case of packed arrays. */
218 #define TYPE_ACTUAL_BOUNDS(NODE) (&TYPE_LANG_SPECIFIC (NODE)->t.generic)
219 #define SET_TYPE_ACTUAL_BOUNDS(NODE, X) \
220 (TYPE_LANG_SPECIFIC (NODE) = (struct lang_type *)(X))
222 /* In an UNCONSTRAINED_ARRAY_TYPE, points to the record containing both
223 the template and object. */
224 #define TYPE_OBJECT_RECORD_TYPE(NODE) TYPE_MIN_VALUE (NODE)
226 /* Nonzero in a FUNCTION_DECL that represents a stubbed function
228 #define DECL_STUBBED_P(NODE) DECL_LANG_FLAG_0 (FUNCTION_DECL_CHECK (NODE))
230 /* Nonzero if this decl is always used by reference; i.e., an INDIRECT_REF
231 is needed to access the object. */
232 #define DECL_BY_REF_P(NODE) DECL_LANG_FLAG_1 (NODE)
234 /* Nonzero if this decl is a PARM_DECL for an Ada array being passed to a
235 foreign convention subprogram. */
236 #define DECL_BY_COMPONENT_PTR_P(NODE) DECL_LANG_FLAG_2 (PARM_DECL_CHECK (NODE))
238 /* Nonzero in a FIELD_DECL that is a dummy built for some internal reason. */
239 #define DECL_INTERNAL_P(NODE) DECL_LANG_FLAG_3 (FIELD_DECL_CHECK (NODE))
241 /* Nonzero in a FUNCTION_DECL that corresponds to an elaboration procedure. */
242 #define DECL_ELABORATION_PROC_P(NODE) \
243 DECL_LANG_FLAG_3 (FUNCTION_DECL_CHECK (NODE))
245 /* Nonzero if this is a decl for a pointer that points to something which
246 is readonly. Used mostly for fat pointers. */
247 #define DECL_POINTS_TO_READONLY_P(NODE) DECL_LANG_FLAG_4 (NODE)
249 /* Nonzero in a FIELD_DECL if there was a record rep clause. */
250 #define DECL_HAS_REP_P(NODE) DECL_LANG_FLAG_5 (FIELD_DECL_CHECK (NODE))
252 /* Nonzero in a PARM_DECL if we are to pass by descriptor. */
253 #define DECL_BY_DESCRIPTOR_P(NODE) DECL_LANG_FLAG_5 (PARM_DECL_CHECK (NODE))
255 /* In a CONST_DECL, points to a VAR_DECL that is allocatable to
256 memory. Used when a scalar constant is aliased or has its
258 #define DECL_CONST_CORRESPONDING_VAR(NODE) \
259 (&DECL_LANG_SPECIFIC (CONST_DECL_CHECK (NODE))->t.generic)
260 #define SET_DECL_CONST_CORRESPONDING_VAR(NODE, X) \
261 (DECL_LANG_SPECIFIC (CONST_DECL_CHECK (NODE)) = (struct lang_decl *)(X))
263 /* In a FIELD_DECL, points to the FIELD_DECL that was the ultimate
264 source of the decl. */
265 #define DECL_ORIGINAL_FIELD(NODE) \
266 (&DECL_LANG_SPECIFIC (FIELD_DECL_CHECK (NODE))->t.generic)
267 #define SET_DECL_ORIGINAL_FIELD(NODE, X) \
268 (DECL_LANG_SPECIFIC (FIELD_DECL_CHECK (NODE)) = (struct lang_decl *)(X))
270 /* In a FIELD_DECL corresponding to a discriminant, contains the
271 discriminant number. */
272 #define DECL_DISCRIMINANT_NUMBER(NODE) DECL_INITIAL (FIELD_DECL_CHECK (NODE))
274 /* This is a horrible kludge to store the loop_id of a loop into a tree
275 node. We need to find some other place to store it! */
276 #define TREE_LOOP_ID(NODE) \
277 (((union lang_tree_node *)TREE_CHECK (NODE, GNAT_LOOP_ID))->loop_id.loop_id)
279 /* Define fields and macros for statements.
281 Start by defining which tree codes are used for statements. */
282 #define IS_STMT(NODE) (TREE_CODE_CLASS (TREE_CODE (NODE)) == 's')
284 /* We store the Sloc in statement nodes. */
285 #define TREE_SLOC(NODE) TREE_COMPLEXITY (STMT_CHECK (NODE))
287 /* There is just one field in an EXPR_STMT: the expression. */
288 #define EXPR_STMT_EXPR(NODE) TREE_OPERAND_CHECK_CODE (NODE, EXPR_STMT, 0)