]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/ada/gigi.h
44b5937d7c17ed7a3a43751ba0135ac2ef0508fc
[thirdparty/gcc.git] / gcc / ada / gigi.h
1 /****************************************************************************
2 * *
3 * GNAT COMPILER COMPONENTS *
4 * *
5 * G I G I *
6 * *
7 * C Header File *
8 * *
9 * *
10 * Copyright (C) 1992-2002 Free Software Foundation, Inc. *
11 * *
12 * GNAT is free software; you can redistribute it and/or modify it under *
13 * terms of the GNU General Public License as published by the Free Soft- *
14 * ware Foundation; either version 2, or (at your option) any later ver- *
15 * sion. GNAT is distributed in the hope that it will be useful, but WITH- *
16 * OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
17 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
18 * for more details. You should have received a copy of the GNU General *
19 * Public License distributed with GNAT; see file COPYING. If not, write *
20 * to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, *
21 * MA 02111-1307, USA. *
22 * *
23 * As a special exception, if you link this file with other files to *
24 * produce an executable, this file does not by itself cause the resulting *
25 * executable to be covered by the GNU General Public License. This except- *
26 * ion does not however invalidate any other reasons why the executable *
27 * file might be covered by the GNU Public License. *
28 * *
29 * GNAT was originally developed by the GNAT team at New York University. *
30 * It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). *
31 * *
32 ****************************************************************************/
33
34 /* Declare all functions and types used by gigi. */
35
36 /* See if DECL has an RTL that is indirect via a pseudo-register or a
37 memory location and replace it with an indirect reference if so.
38 This improves the debugger's ability to display the value. */
39 extern void adjust_decl_rtl PARAMS ((tree));
40
41 /* Record the current code position in GNAT_NODE. */
42 extern void record_code_position PARAMS ((Node_Id));
43
44 /* Insert the code for GNAT_NODE at the position saved for that node. */
45 extern void insert_code_for PARAMS ((Node_Id));
46
47 /* Routine called by gcc for emitting a stack check. GNU_EXPR is the
48 expression that contains the last address on the stack to check. */
49 extern tree emit_stack_check PARAMS ((tree));
50
51 /* Make a TRANSFORM_EXPR to later expand GNAT_NODE into code. */
52 extern tree make_transform_expr PARAMS ((Node_Id));
53
54 /* Update the setjmp buffer BUF with the current stack pointer. We assume
55 here that a __builtin_setjmp was done to BUF. */
56 extern void update_setjmp_buf PARAMS ((tree));
57
58 /* GNU_TYPE is a type. Determine if it should be passed by reference by
59 default. */
60 extern int default_pass_by_ref PARAMS ((tree));
61
62 /* GNU_TYPE is the type of a subprogram parameter. Determine from the type
63 if it should be passed by reference. */
64 extern int must_pass_by_ref PARAMS ((tree));
65
66 /* This function returns the version of GCC being used. Here it's GCC 3. */
67 extern int gcc_version PARAMS ((void));
68
69 /* Elaboration routines for the front end. */
70 extern void elab_all_gnat PARAMS ((void));
71
72 /* Initialize DUMMY_NODE_TABLE. */
73 extern void init_dummy_type PARAMS ((void));
74
75 /* Given GNAT_ENTITY, a GNAT defining identifier node, which denotes some Ada
76 entity, this routine returns the equivalent GCC tree for that entity
77 (an ..._DECL node) and associates the ..._DECL node with the input GNAT
78 defining identifier.
79
80 If GNAT_ENTITY is a variable or a constant declaration, GNU_EXPR gives its
81 initial value (in GCC tree form). This is optional for variables.
82 For renamed entities, GNU_EXPR gives the object being renamed.
83
84 DEFINITION is nonzero if this call is intended for a definition. This is
85 used for separate compilation where it necessary to know whether an
86 external declaration or a definition should be created if the GCC equivalent
87 was not created previously. The value of 1 is normally used for a non-zero
88 DEFINITION, but a value of 2 is used in special circumstances, defined in
89 the code. */
90 extern tree gnat_to_gnu_entity PARAMS ((Entity_Id, tree, int));
91
92 /* Given GNAT_ENTITY, an entity in the incoming GNAT tree, return a
93 GCC type corresponding to that entity. GNAT_ENTITY is assumed to
94 refer to an Ada type. */
95 extern tree gnat_to_gnu_type PARAMS ((Entity_Id));
96
97 /* Given GNAT_ENTITY, elaborate all expressions that are required to
98 be elaborated at the point of its definition, but do nothing else. */
99 extern void elaborate_entity PARAMS ((Entity_Id));
100
101 /* Mark GNAT_ENTITY as going out of scope at this point. Recursively mark
102 any entities on its entity chain similarly. */
103 extern void mark_out_of_scope PARAMS ((Entity_Id));
104
105 /* Make a dummy type corresponding to GNAT_TYPE. */
106 extern tree make_dummy_type PARAMS ((Entity_Id));
107
108 /* Get the unpadded version of a GNAT type. */
109 extern tree get_unpadded_type PARAMS ((Entity_Id));
110
111 /* Called when we need to protect a variable object using a save_expr. */
112 extern tree maybe_variable PARAMS ((tree, Node_Id));
113
114 /* Create a record type that contains a field of TYPE with a starting bit
115 position so that it is aligned to ALIGN bits. */
116 /* Create a record type that contains a field of TYPE with a starting bit
117 position so that it is aligned to ALIGN bits and is SIZE bytes long. */
118 extern tree make_aligning_type PARAMS ((tree, int, tree));
119
120 /* Given a GNU tree and a GNAT list of choices, generate an expression to test
121 the value passed against the list of choices. */
122 extern tree choices_to_gnu PARAMS ((tree, Node_Id));
123
124 /* Given a type T, a FIELD_DECL F, and a replacement value R,
125 return a new type with all size expressions that contain F
126 updated by replacing F with R. This is identical to GCC's
127 substitute_in_type except that it knows about TYPE_INDEX_TYPE. */
128 extern tree gnat_substitute_in_type PARAMS ((tree, tree, tree));
129
130 /* Return the "RM size" of GNU_TYPE. This is the actual number of bits
131 needed to represent the object. */
132 extern tree rm_size PARAMS ((tree));
133
134 /* Given GNU_ID, an IDENTIFIER_NODE containing a name and SUFFIX, a
135 string, return a new IDENTIFIER_NODE that is the concatenation of
136 the name in GNU_ID and SUFFIX. */
137 extern tree concat_id_with_name PARAMS ((tree, const char *));
138
139 /* Return the name to be used for GNAT_ENTITY. If a type, create a
140 fully-qualified name, possibly with type information encoding.
141 Otherwise, return the name. */
142 extern tree get_entity_name PARAMS ((Entity_Id));
143
144 /* Return a name for GNAT_ENTITY concatenated with two underscores and
145 SUFFIX. */
146 extern tree create_concat_name PARAMS ((Entity_Id, const char *));
147
148 /* Flag indicating whether file names are discarded in exception messages */
149 extern int discard_file_names;
150
151 /* If true, then gigi is being called on an analyzed but unexpanded
152 tree, and the only purpose of the call is to properly annotate
153 types with representation information */
154 extern int type_annotate_only;
155
156 /* Current file name without path */
157 extern const char *ref_filename;
158
159 /* List of TREE_LIST nodes representing a block stack. TREE_VALUE
160 of each gives the variable used for the setjmp buffer in the current
161 block, if any. */
162 extern tree gnu_block_stack;
163
164 /* This is the main program of the back-end. It sets up all the table
165 structures and then generates code. */
166
167 extern void gigi PARAMS ((Node_Id, int, int, struct Node *,
168 Node_Id *, Node_Id *,
169 struct Elist_Header *,
170 struct Elmt_Item *,
171 struct String_Entry *,
172 Char_Code *,
173 struct List_Header *,
174 Int, char *,
175 Entity_Id, Entity_Id, Entity_Id,
176 Int));
177
178 /* This function is the driver of the GNAT to GCC tree transformation process.
179 GNAT_NODE is the root of some gnat tree. It generates code for that
180 part of the tree. */
181 extern void gnat_to_code PARAMS ((Node_Id));
182
183 /* GNAT_NODE is the root of some GNAT tree. Return the root of the
184 GCC tree corresponding to that GNAT tree. Normally, no code is generated;
185 we just return an equivalent tree which is used elsewhere to generate
186 code. */
187 extern tree gnat_to_gnu PARAMS ((Node_Id));
188
189 /* Do the processing for the declaration of a GNAT_ENTITY, a type. If
190 a separate Freeze node exists, delay the bulk of the processing. Otherwise
191 make a GCC type for GNAT_ENTITY and set up the correspondance. */
192
193 extern void process_type PARAMS ((Entity_Id));
194
195 /* Determine the input_filename and the lineno from the source location
196 (Sloc) of GNAT_NODE node. Set the global variable input_filename and
197 lineno. If WRITE_NOTE_P is true, emit a line number note. */
198 extern void set_lineno PARAMS ((Node_Id, int));
199
200 /* Post an error message. MSG is the error message, properly annotated.
201 NODE is the node at which to post the error and the node to use for the
202 "&" substitution. */
203 extern void post_error PARAMS ((const char *, Node_Id));
204
205 /* Similar, but NODE is the node at which to post the error and ENT
206 is the node to use for the "&" substitution. */
207 extern void post_error_ne PARAMS ((const char *, Node_Id, Entity_Id));
208
209 /* Similar, but NODE is the node at which to post the error, ENT is the node
210 to use for the "&" substitution, and N is the number to use for the ^. */
211 extern void post_error_ne_num PARAMS ((const char *, Node_Id, Entity_Id,
212 int));
213
214 /* Similar to post_error_ne_num, but T is a GCC tree representing the number
215 to write. If the tree represents a constant that fits within a
216 host integer, the text inside curly brackets in MSG will be output
217 (presumably including a '^'). Otherwise that text will not be output
218 and the text inside square brackets will be output instead. */
219 extern void post_error_ne_tree PARAMS ((const char *, Node_Id, Entity_Id,
220 tree));
221
222 /* Similar to post_error_ne_tree, except that NUM is a second
223 integer to write in the message. */
224 extern void post_error_ne_tree_2 PARAMS ((const char *, Node_Id, Entity_Id,
225 tree, int));
226
227 /* Set the node for a second '&' in the error message. */
228 extern void set_second_error_entity PARAMS ((Entity_Id));
229
230 /* Protect EXP from multiple evaluation. This may make a SAVE_EXPR. */
231 extern tree protect_multiple_eval PARAMS ((tree));
232
233 /* Signal abort, with "Gigi abort" as the error label, and error_gnat_node
234 as the relevant node that provides the location info for the error.
235 The single parameter CODE is an integer code that is included in the
236 additional error message generated. */
237 extern void gigi_abort PARAMS ((int)) ATTRIBUTE_NORETURN;
238
239 /* Initialize the table that maps GNAT codes to GCC codes for simple
240 binary and unary operations. */
241 extern void init_code_table PARAMS ((void));
242
243 /* Current node being treated, in case gigi_abort or Check_Elaboration_Code
244 called. */
245 extern Node_Id error_gnat_node;
246
247 /* This is equivalent to stabilize_reference in GCC's tree.c, but we know
248 how to handle our new nodes and we take an extra argument that says
249 whether to force evaluation of everything. */
250
251 extern tree gnat_stabilize_reference PARAMS ((tree, int));
252
253 /* Highest number in the front-end node table. */
254 extern int max_gnat_nodes;
255
256 /* If nonzero, pretend we are allocating at global level. */
257 extern int force_global;
258
259 /* Standard data type sizes. Most of these are not used. */
260
261 #ifndef CHAR_TYPE_SIZE
262 #define CHAR_TYPE_SIZE BITS_PER_UNIT
263 #endif
264
265 #ifndef SHORT_TYPE_SIZE
266 #define SHORT_TYPE_SIZE (BITS_PER_UNIT * MIN ((UNITS_PER_WORD + 1) / 2, 2))
267 #endif
268
269 #ifndef INT_TYPE_SIZE
270 #define INT_TYPE_SIZE BITS_PER_WORD
271 #endif
272
273 #ifndef LONG_TYPE_SIZE
274 #define LONG_TYPE_SIZE BITS_PER_WORD
275 #endif
276
277 #ifndef LONG_LONG_TYPE_SIZE
278 #define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2)
279 #endif
280
281 #ifndef FLOAT_TYPE_SIZE
282 #define FLOAT_TYPE_SIZE BITS_PER_WORD
283 #endif
284
285 #ifndef DOUBLE_TYPE_SIZE
286 #define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
287 #endif
288
289 #ifndef LONG_DOUBLE_TYPE_SIZE
290 #define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
291 #endif
292
293 /* The choice of SIZE_TYPE here is very problematic. We need a signed
294 type whose bit width is Pmode. Assume "long" is such a type here. */
295 #undef SIZE_TYPE
296 #define SIZE_TYPE "long int"
297
298 \f
299 /* Data structures used to represent attributes. */
300
301 enum attr_type {ATTR_MACHINE_ATTRIBUTE, ATTR_LINK_ALIAS,
302 ATTR_LINK_SECTION, ATTR_WEAK_EXTERNAL};
303
304 struct attrib
305 {
306 struct attrib *next;
307 enum attr_type type;
308 tree name;
309 tree arg;
310 Node_Id error_point;
311 };
312
313 /* Define the entries in the standard data array. */
314 enum standard_datatypes
315 {
316 /* Various standard data types and nodes. */
317 ADT_longest_float_type,
318 ADT_void_type_decl,
319
320 /* The type of an exception. */
321 ADT_except_type,
322
323 /* Type declaration node <==> typedef void *T */
324 ADT_ptr_void_type,
325
326 /* Function type declaration -- void T() */
327 ADT_void_ftype,
328
329 /* Type declaration node <==> typedef void *T() */
330 ADT_ptr_void_ftype,
331
332 /* A function declaration node for a run-time function for allocating memory.
333 Ada allocators cause calls to this function to be generated. */
334 ADT_malloc_decl,
335
336 /* Likewise for freeing memory. */
337 ADT_free_decl,
338
339 /* Types and decls used by our temporary exception mechanism. See
340 init_gigi_decls for details. */
341 ADT_jmpbuf_type,
342 ADT_jmpbuf_ptr_type,
343 ADT_get_jmpbuf_decl,
344 ADT_set_jmpbuf_decl,
345 ADT_get_excptr_decl,
346 ADT_setjmp_decl,
347 ADT_longjmp_decl,
348 ADT_raise_nodefer_decl,
349 ADT_LAST};
350
351 extern tree gnat_std_decls[(int) ADT_LAST];
352 extern tree gnat_raise_decls[(int) LAST_REASON_CODE + 1];
353
354 #define longest_float_type_node gnat_std_decls[(int) ADT_longest_float_type]
355 #define void_type_decl_node gnat_std_decls[(int) ADT_void_type_decl]
356 #define except_type_node gnat_std_decls[(int) ADT_except_type]
357 #define ptr_void_type_node gnat_std_decls[(int) ADT_ptr_void_type]
358 #define void_ftype gnat_std_decls[(int) ADT_void_ftype]
359 #define ptr_void_ftype gnat_std_decls[(int) ADT_ptr_void_ftype]
360 #define malloc_decl gnat_std_decls[(int) ADT_malloc_decl]
361 #define free_decl gnat_std_decls[(int) ADT_free_decl]
362 #define jmpbuf_type gnat_std_decls[(int) ADT_jmpbuf_type]
363 #define jmpbuf_ptr_type gnat_std_decls[(int) ADT_jmpbuf_ptr_type]
364 #define get_jmpbuf_decl gnat_std_decls[(int) ADT_get_jmpbuf_decl]
365 #define set_jmpbuf_decl gnat_std_decls[(int) ADT_set_jmpbuf_decl]
366 #define get_excptr_decl gnat_std_decls[(int) ADT_get_excptr_decl]
367 #define setjmp_decl gnat_std_decls[(int) ADT_setjmp_decl]
368 #define longjmp_decl gnat_std_decls[(int) ADT_longjmp_decl]
369 #define raise_nodefer_decl gnat_std_decls[(int) ADT_raise_nodefer_decl]
370
371 /* Routines expected by the gcc back-end. They must have exactly the same
372 prototype and names as below. */
373
374 /* Returns non-zero if we are currently in the global binding level */
375 extern int global_bindings_p PARAMS ((void));
376
377 /* Returns the list of declarations in the current level. Note that this list
378 is in reverse order (it has to be so for back-end compatibility). */
379 extern tree getdecls PARAMS ((void));
380
381 /* Nonzero if the current level needs to have a BLOCK made. */
382 extern int kept_level_p PARAMS ((void));
383
384 /* Enter a new binding level. The input parameter is ignored, but has to be
385 specified for back-end compatibility. */
386 extern void pushlevel PARAMS ((int));
387
388 /* Exit a binding level.
389 Pop the level off, and restore the state of the identifier-decl mappings
390 that were in effect when this level was entered.
391
392 If KEEP is nonzero, this level had explicit declarations, so
393 and create a "block" (a BLOCK node) for the level
394 to record its declarations and subblocks for symbol table output.
395
396 If FUNCTIONBODY is nonzero, this level is the body of a function,
397 so create a block as if KEEP were set and also clear out all
398 label names.
399
400 If REVERSE is nonzero, reverse the order of decls before putting
401 them into the BLOCK. */
402 extern tree poplevel PARAMS ((int,int, int));
403
404 /* Insert BLOCK at the end of the list of subblocks of the
405 current binding level. This is used when a BIND_EXPR is expanded,
406 to handle the BLOCK node inside the BIND_EXPR. */
407 extern void insert_block PARAMS ((tree));
408
409 /* Set the BLOCK node for the innermost scope
410 (the one we are currently in). */
411 extern void set_block PARAMS ((tree));
412
413 /* Records a ..._DECL node DECL as belonging to the current lexical scope.
414 Returns the ..._DECL node. */
415 extern tree pushdecl PARAMS ((tree));
416
417 /* Create the predefined scalar types such as `integer_type_node' needed
418 in the gcc back-end and initialize the global binding level. */
419 extern void gnat_init_decl_processing PARAMS ((void));
420 extern void init_gigi_decls PARAMS ((tree, tree));
421 extern void gnat_init_gcc_eh PARAMS ((void));
422
423 /* Return an integer type with the number of bits of precision given by
424 PRECISION. UNSIGNEDP is nonzero if the type is unsigned; otherwise
425 it is a signed type. */
426 extern tree gnat_type_for_size PARAMS ((unsigned, int));
427
428 /* Return a data type that has machine mode MODE. UNSIGNEDP selects
429 an unsigned type; otherwise a signed type is returned. */
430 extern tree gnat_type_for_mode PARAMS ((enum machine_mode, int));
431
432 /* Return the unsigned version of a TYPE_NODE, a scalar type. */
433 extern tree gnat_unsigned_type PARAMS ((tree));
434
435 /* Return the signed version of a TYPE_NODE, a scalar type. */
436 extern tree gnat_signed_type PARAMS ((tree));
437
438 /* Return a type the same as TYPE except unsigned or signed according to
439 UNSIGNEDP. */
440 extern tree gnat_signed_or_unsigned_type PARAMS ((int, tree));
441
442 /* This function is called indirectly from toplev.c to handle incomplete
443 declarations, i.e. VAR_DECL nodes whose DECL_SIZE is zero. To be precise,
444 compile_file in toplev.c makes an indirect call through the function pointer
445 incomplete_decl_finalize_hook which is initialized to this routine in
446 init_decl_processing. */
447 extern void gnat_finish_incomplete_decl PARAMS ((tree));
448
449 /* Create an expression whose value is that of EXPR,
450 converted to type TYPE. The TREE_TYPE of the value
451 is always TYPE. This function implements all reasonable
452 conversions; callers should filter out those that are
453 not permitted by the language being compiled. */
454 extern tree convert PARAMS ((tree, tree));
455
456 /* Routines created solely for the tree translator's sake. Their prototypes
457 can be changed as desired. */
458
459 /* GNAT_ENTITY is a GNAT tree node for a defining identifier.
460 GNU_DECL is the GCC tree which is to be associated with
461 GNAT_ENTITY. Such gnu tree node is always an ..._DECL node.
462 If NO_CHECK is nonzero, the latter check is suppressed.
463 If GNU_DECL is zero, a previous association is to be reset. */
464 extern void save_gnu_tree PARAMS ((Entity_Id, tree, int));
465
466 /* GNAT_ENTITY is a GNAT tree node for a defining identifier.
467 Return the ..._DECL node that was associated with it. If there is no tree
468 node associated with GNAT_ENTITY, abort. */
469 extern tree get_gnu_tree PARAMS ((Entity_Id));
470
471 /* Return nonzero if a GCC tree has been associated with GNAT_ENTITY. */
472 extern int present_gnu_tree PARAMS ((Entity_Id));
473
474 /* Initialize tables for above routines. */
475 extern void init_gnat_to_gnu PARAMS ((void));
476
477 /* Given a record type (RECORD_TYPE) and a chain of FIELD_DECL
478 nodes (FIELDLIST), finish constructing the record or union type.
479 If HAS_REP is nonzero, this record has a rep clause; don't call
480 layout_type but merely set the size and alignment ourselves.
481 If DEFER_DEBUG is nonzero, do not call the debugging routines
482 on this type; it will be done later. */
483 extern void finish_record_type PARAMS ((tree, tree, int, int));
484
485 /* Returns a FUNCTION_TYPE node. RETURN_TYPE is the type returned by the
486 subprogram. If it is void_type_node, then we are dealing with a procedure,
487 otherwise we are dealing with a function. PARAM_DECL_LIST is a list of
488 PARM_DECL nodes that are the subprogram arguments. CICO_LIST is the
489 copy-in/copy-out list to be stored into TYPE_CI_CO_LIST.
490 RETURNS_UNCONSTRAINED is nonzero if the function returns an unconstrained
491 object. RETURNS_BY_REF is nonzero if the function returns by reference.
492 RETURNS_WITH_DSP is nonzero if the function is to return with a
493 depressed stack pointer. */
494 extern tree create_subprog_type PARAMS ((tree, tree, tree, int, int,
495 int));
496
497 /* Return a copy of TYPE, but safe to modify in any way. */
498 extern tree copy_type PARAMS ((tree));
499
500 /* Return an INTEGER_TYPE of SIZETYPE with range MIN to MAX and whose
501 TYPE_INDEX_TYPE is INDEX. */
502 extern tree create_index_type PARAMS ((tree, tree, tree));
503
504 /* Return a TYPE_DECL node. TYPE_NAME gives the name of the type (a character
505 string) and TYPE is a ..._TYPE node giving its data type.
506 ARTIFICIAL_P is nonzero if this is a declaration that was generated
507 by the compiler. DEBUG_INFO_P is nonzero if we need to write debugging
508 information about this type. */
509 extern tree create_type_decl PARAMS ((tree, tree, struct attrib *,
510 int, int));
511
512 /* Returns a GCC VAR_DECL node. VAR_NAME gives the name of the variable.
513 ASM_NAME is its assembler name (if provided). TYPE is
514 its data type (a GCC ..._TYPE node). VAR_INIT is the GCC tree for an
515 optional initial expression; NULL_TREE if none.
516
517 CONST_FLAG is nonzero if this variable is constant.
518
519 PUBLIC_FLAG is nonzero if this definition is to be made visible outside of
520 the current compilation unit. This flag should be set when processing the
521 variable definitions in a package specification. EXTERN_FLAG is nonzero
522 when processing an external variable declaration (as opposed to a
523 definition: no storage is to be allocated for the variable here).
524 STATIC_FLAG is only relevant when not at top level. In that case
525 it indicates whether to always allocate storage to the variable. */
526 extern tree create_var_decl PARAMS ((tree, tree, tree, tree, int,
527 int, int, int,
528 struct attrib *));
529
530 /* Given a DECL and ATTR_LIST, apply the listed attributes. */
531 extern void process_attributes PARAMS ((tree, struct attrib *));
532
533 /* Obtain any pending elaborations and clear the old list. */
534 extern tree get_pending_elaborations PARAMS ((void));
535
536 /* Return nonzero if there are pending elaborations. */
537 extern int pending_elaborations_p PARAMS ((void));
538
539 /* Save a copy of the current pending elaboration list and make a new
540 one. */
541 extern void push_pending_elaborations PARAMS ((void));
542
543 /* Pop the stack of pending elaborations. */
544 extern void pop_pending_elaborations PARAMS ((void));
545
546 /* Return the current position in pending_elaborations so we can insert
547 elaborations after that point. */
548 extern tree get_elaboration_location PARAMS ((void));
549
550 /* Insert the current elaborations after ELAB, which is in some elaboration
551 list. */
552 extern void insert_elaboration_list PARAMS ((tree));
553
554 /* Add some pending elaborations to the current list. */
555 extern void add_pending_elaborations PARAMS ((tree, tree));
556
557 /* Returns a FIELD_DECL node. FIELD_NAME the field name, FIELD_TYPE is its
558 type, and RECORD_TYPE is the type of the parent. PACKED is nonzero if
559 this field is in a record type with a "pragma pack". If SIZE is nonzero
560 it is the specified size for this field. If POS is nonzero, it is the bit
561 position. If ADDRESSABLE is nonzero, it means we are allowed to take
562 the address of this field for aliasing purposes. */
563 extern tree create_field_decl PARAMS ((tree, tree, tree, int,
564 tree, tree, int));
565
566 /* Returns a PARM_DECL node. PARAM_NAME is the name of the parameter,
567 PARAM_TYPE is its type. READONLY is nonzero if the parameter is
568 readonly (either an IN parameter or an address of a pass-by-ref
569 parameter). */
570 extern tree create_param_decl PARAMS ((tree, tree, int));
571
572 /* Returns a FUNCTION_DECL node. SUBPROG_NAME is the name of the subprogram,
573 ASM_NAME is its assembler name, SUBPROG_TYPE is its type (a FUNCTION_TYPE
574 node), PARAM_DECL_LIST is the list of the subprogram arguments (a list of
575 PARM_DECL nodes chained through the TREE_CHAIN field).
576
577 INLINE_FLAG, PUBLIC_FLAG, and EXTERN_FLAG are used to set the appropriate
578 fields in the FUNCTION_DECL. */
579 extern tree create_subprog_decl PARAMS ((tree, tree, tree, tree, int,
580 int, int, struct attrib *));
581
582 /* Returns a LABEL_DECL node for LABEL_NAME. */
583 extern tree create_label_decl PARAMS ((tree));
584
585 /* Set up the framework for generating code for SUBPROG_DECL, a subprogram
586 body. This routine needs to be invoked before processing the declarations
587 appearing in the subprogram. */
588 extern void begin_subprog_body PARAMS ((tree));
589
590 /* Finish the definition of the current subprogram and compile it all the way
591 to assembler language output. */
592 extern void end_subprog_body PARAMS ((void));
593
594 /* Build a template of type TEMPLATE_TYPE from the array bounds of ARRAY_TYPE.
595 EXPR is an expression that we can use to locate any PLACEHOLDER_EXPRs.
596 Return a constructor for the template. */
597 extern tree build_template PARAMS ((tree, tree, tree));
598
599 /* Build a VMS descriptor from a Mechanism_Type, which must specify
600 a descriptor type, and the GCC type of an object. Each FIELD_DECL
601 in the type contains in its DECL_INITIAL the expression to use when
602 a constructor is made for the type. GNAT_ENTITY is a gnat node used
603 to print out an error message if the mechanism cannot be applied to
604 an object of that type and also for the name. */
605
606 extern tree build_vms_descriptor PARAMS ((tree, Mechanism_Type,
607 Entity_Id));
608
609 /* Build a type to be used to represent an aliased object whose nominal
610 type is an unconstrained array. This consists of a RECORD_TYPE containing
611 a field of TEMPLATE_TYPE and a field of OBJECT_TYPE, which is an
612 ARRAY_TYPE. If ARRAY_TYPE is that of the unconstrained array, this
613 is used to represent an arbitrary unconstrained object. Use NAME
614 as the name of the record. */
615 extern tree build_unc_object_type PARAMS ((tree, tree, tree));
616
617 /* Update anything previously pointing to OLD_TYPE to point to NEW_TYPE. In
618 the normal case this is just two adjustments, but we have more to do
619 if NEW is an UNCONSTRAINED_ARRAY_TYPE. */
620 extern void update_pointer_to PARAMS ((tree, tree));
621
622 /* EXP is an expression for the size of an object. If this size contains
623 discriminant references, replace them with the maximum (if MAX_P) or
624 minimum (if ! MAX_P) possible value of the discriminant. */
625 extern tree max_size PARAMS ((tree, int));
626
627 /* Remove all conversions that are done in EXP. This includes converting
628 from a padded type or to a left-justified modular type. If TRUE_ADDRESS
629 is nonzero, always return the address of the containing object even if
630 the address is not bit-aligned. */
631 extern tree remove_conversions PARAMS ((tree, int));
632
633 /* If EXP's type is an UNCONSTRAINED_ARRAY_TYPE, return an expression that
634 refers to the underlying array. If its type has TYPE_CONTAINS_TEMPLATE_P,
635 likewise return an expression pointing to the underlying array. */
636 extern tree maybe_unconstrained_array PARAMS ((tree));
637
638 /* Return an expression that does an unchecked converstion of EXPR to TYPE. */
639 extern tree unchecked_convert PARAMS ((tree, tree));
640
641 /* Prepare expr to be an argument of a TRUTH_NOT_EXPR or other logical
642 operation.
643
644 This preparation consists of taking the ordinary
645 representation of an expression expr and producing a valid tree
646 boolean expression describing whether expr is nonzero. We could
647 simply always do build_binary_op (NE_EXPR, expr, integer_zero_node, 1),
648 but we optimize comparisons, &&, ||, and !.
649
650 The resulting type should always be the same as the input type.
651 This function is simpler than the corresponding C version since
652 the only possible operands will be things of Boolean type. */
653 extern tree gnat_truthvalue_conversion PARAMS((tree));
654
655 /* Return the base type of TYPE. */
656 extern tree get_base_type PARAMS((tree));
657
658 /* Likewise, but only return types known at Ada source. */
659 extern tree get_ada_base_type PARAMS((tree));
660
661 /* EXP is a GCC tree representing an address. See if we can find how
662 strictly the object at that address is aligned. Return that alignment
663 strictly the object at that address is aligned. Return that alignment
664 in bits. If we don't know anything about the alignment, return 0. */
665 extern unsigned int known_alignment PARAMS((tree));
666
667 /* Make a binary operation of kind OP_CODE. RESULT_TYPE is the type
668 desired for the result. Usually the operation is to be performed
669 in that type. For MODIFY_EXPR and ARRAY_REF, RESULT_TYPE may be 0
670 in which case the type to be used will be derived from the operands. */
671 extern tree build_binary_op PARAMS((enum tree_code, tree, tree, tree));
672
673 /* Similar, but make unary operation. */
674 extern tree build_unary_op PARAMS((enum tree_code, tree, tree));
675
676 /* Similar, but for COND_EXPR. */
677 extern tree build_cond_expr PARAMS((tree, tree, tree, tree));
678
679 /* Build a CALL_EXPR to call FUNDECL with one argument, ARG. Return
680 the CALL_EXPR. */
681 extern tree build_call_1_expr PARAMS((tree, tree));
682
683 /* Build a CALL_EXPR to call FUNDECL with two argument, ARG1 & ARG2. Return
684 the CALL_EXPR. */
685 extern tree build_call_2_expr PARAMS((tree, tree, tree));
686
687 /* Likewise to call FUNDECL with no arguments. */
688 extern tree build_call_0_expr PARAMS((tree));
689
690 /* Call a function that raises an exception and pass the line number and file
691 name, if requested. MSG says which exception function to call. */
692 extern tree build_call_raise PARAMS((int));
693
694 /* Return a CONSTRUCTOR of TYPE whose list is LIST. */
695 extern tree build_constructor PARAMS((tree, tree));
696
697 /* Return a COMPONENT_REF to access a field that is given by COMPONENT,
698 an IDENTIFIER_NODE giving the name of the field, FIELD, a FIELD_DECL,
699 for the field, or both. */
700 extern tree build_component_ref PARAMS((tree, tree, tree));
701
702 /* Build a GCC tree to call an allocation or deallocation function.
703 If GNU_OBJ is nonzero, it is an object to deallocate. Otherwise,
704 genrate an allocator.
705
706 GNU_SIZE is the size of the object and ALIGN is the alignment.
707 GNAT_PROC, if present is a procedure to call and GNAT_POOL is the
708 storage pool to use. If not preset, malloc and free will be used. */
709 extern tree build_call_alloc_dealloc PARAMS((tree, tree, int, Entity_Id,
710 Entity_Id));
711
712 /* Build a GCC tree to correspond to allocating an object of TYPE whose
713 initial value if INIT, if INIT is nonzero. Convert the expression to
714 RESULT_TYPE, which must be some type of pointer. Return the tree.
715 GNAT_PROC and GNAT_POOL optionally give the procedure to call and
716 the storage pool to use. */
717 extern tree build_allocator PARAMS((tree, tree, tree, Entity_Id,
718 Entity_Id));
719
720 /* Fill in a VMS descriptor for EXPR and return a constructor for it.
721 GNAT_FORMAL is how we find the descriptor record. */
722
723 extern tree fill_vms_descriptor PARAMS((tree, Entity_Id));
724
725 /* Indicate that we need to make the address of EXPR_NODE and it therefore
726 should not be allocated in a register. Return true if successful. */
727 extern bool gnat_mark_addressable PARAMS((tree));
728
729 /* These functions return the basic data type sizes and related parameters
730 about the target machine. */
731
732 extern Pos get_target_bits_per_unit PARAMS ((void));
733 extern Pos get_target_bits_per_word PARAMS ((void));
734 extern Pos get_target_char_size PARAMS ((void));
735 extern Pos get_target_wchar_t_size PARAMS ((void));
736 extern Pos get_target_short_size PARAMS ((void));
737 extern Pos get_target_int_size PARAMS ((void));
738 extern Pos get_target_long_size PARAMS ((void));
739 extern Pos get_target_long_long_size PARAMS ((void));
740 extern Pos get_target_float_size PARAMS ((void));
741 extern Pos get_target_double_size PARAMS ((void));
742 extern Pos get_target_long_double_size PARAMS ((void));
743 extern Pos get_target_pointer_size PARAMS ((void));
744 extern Pos get_target_maximum_alignment PARAMS ((void));
745 extern Boolean get_target_no_dollar_in_label PARAMS ((void));
746 extern Nat get_float_words_be PARAMS ((void));
747 extern Nat get_words_be PARAMS ((void));
748 extern Nat get_bytes_be PARAMS ((void));
749 extern Nat get_bits_be PARAMS ((void));
750 extern Nat get_strict_alignment PARAMS ((void));