OSDN Git Service

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