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