OSDN Git Service

PR preprocessor/20348
[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-2005 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,  51  Franklin  Street,  Fifth  Floor, *
20  * Boston, MA 02110-1301, 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 /* Declare all functions and types used by gigi.  */
34
35 /* The largest alignment, in bits, that is needed for using the widest
36    move instruction.  */
37 extern unsigned int largest_move_alignment;
38
39 /* Compute the alignment of the largest mode that can be used for copying
40    objects.  */
41 extern void gnat_compute_largest_alignment (void);
42
43 /* GNU_TYPE is a type. Determine if it should be passed by reference by
44    default.  */
45 extern bool default_pass_by_ref (tree gnu_type);
46
47 /* GNU_TYPE is the type of a subprogram parameter.  Determine from the type
48    if it should be passed by reference.  */
49 extern bool must_pass_by_ref (tree gnu_type);
50
51 /* Initialize DUMMY_NODE_TABLE.  */
52 extern void init_dummy_type (void);
53
54 /* Given GNAT_ENTITY, a GNAT defining identifier node, which denotes some Ada
55    entity, this routine returns the equivalent GCC tree for that entity
56    (an ..._DECL node) and associates the ..._DECL node with the input GNAT
57    defining identifier.
58
59    If GNAT_ENTITY is a variable or a constant declaration, GNU_EXPR gives its
60    initial value (in GCC tree form). This is optional for variables.
61    For renamed entities, GNU_EXPR gives the object being renamed.
62
63    DEFINITION is nonzero if this call is intended for a definition.  This is
64    used for separate compilation where it necessary to know whether an
65    external declaration or a definition should be created if the GCC equivalent
66    was not created previously.  The value of 1 is normally used for a non-zero
67    DEFINITION, but a value of 2 is used in special circumstances, defined in
68    the code.  */
69 extern tree gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr,
70                                 int definition);
71
72 /* Similar, but if the returned value is a COMPONENT_REF, return the
73    FIELD_DECL.  */
74 extern tree gnat_to_gnu_field_decl (Entity_Id gnat_entity);
75
76 /* Given GNAT_ENTITY, an entity in the incoming GNAT tree, return a
77    GCC type corresponding to that entity.  GNAT_ENTITY is assumed to
78    refer to an Ada type.  */
79 extern tree gnat_to_gnu_type (Entity_Id gnat_entity);
80
81 /* Add GNU_STMT to the current BLOCK_STMT node.  */
82 extern void add_stmt (tree gnu_stmt);
83
84 /* Similar, but set the location of GNU_STMT to that of GNAT_NODE.  */
85 extern void add_stmt_with_node (tree gnu_stmt, Node_Id gnat_node);
86
87 /* Set the BLOCK node corresponding to the current code group to GNU_BLOCK.  */
88 extern void set_block_for_group (tree);
89
90 /* Add a declaration statement for GNU_DECL to the current BLOCK_STMT node.
91    Get SLOC from GNAT_ENTITY.  */
92 extern void add_decl_expr (tree gnu_decl, Entity_Id gnat_entity);
93
94 /* Given GNAT_ENTITY, elaborate all expressions that are required to
95    be elaborated at the point of its definition, but do nothing else.  */
96 extern void elaborate_entity (Entity_Id gnat_entity);
97
98 /* Mark GNAT_ENTITY as going out of scope at this point.  Recursively mark
99    any entities on its entity chain similarly.  */
100 extern void mark_out_of_scope (Entity_Id gnat_entity);
101
102 /* Make a dummy type corresponding to GNAT_TYPE.  */
103 extern tree make_dummy_type (Entity_Id gnat_type);
104
105 /* Get the unpadded version of a GNAT type.  */
106 extern tree get_unpadded_type (Entity_Id gnat_entity);
107
108 /* Called when we need to protect a variable object using a save_expr.  */
109 extern tree maybe_variable (tree gnu_operand);
110
111 /* Create a record type that contains a field of TYPE with a starting bit
112    position so that it is aligned to ALIGN bits and is SIZE bytes long.  */
113 extern tree make_aligning_type (tree type, int align, tree size);
114
115 /* Ensure that TYPE has SIZE and ALIGN.  Make and return a new padded type
116    if needed.  We have already verified that SIZE and TYPE are large enough.
117
118    GNAT_ENTITY and NAME_TRAILER are used to name the resulting record and
119    to issue a warning.
120
121    IS_USER_TYPE is true if we must be sure we complete the original type.
122
123    DEFINITION is true if this type is being defined.
124
125    SAME_RM_SIZE is true if the RM_Size of the resulting type is to be
126    set to its TYPE_SIZE; otherwise, it's set to the RM_Size of the original
127    type.  */
128 extern tree maybe_pad_type (tree type, tree size, unsigned int align,
129                             Entity_Id gnat_entity, const char *name_trailer,
130                             bool is_user_type, bool definition,
131                             bool same_rm_size);
132
133 /* Given a GNU tree and a GNAT list of choices, generate an expression to test
134    the value passed against the list of choices.  */
135 extern tree choices_to_gnu (tree operand, Node_Id choices);
136
137 /* Given a type T, a FIELD_DECL F, and a replacement value R,
138    return a new type with all size expressions that contain F
139    updated by replacing F with R.  This is identical to GCC's
140    substitute_in_type except that it knows about TYPE_INDEX_TYPE.  */
141 extern tree gnat_substitute_in_type (tree t, tree f, tree r);
142
143 /* Return the "RM size" of GNU_TYPE.  This is the actual number of bits
144    needed to represent the object.  */
145 extern tree rm_size (tree gnu_type);
146
147 /* Given GNU_ID, an IDENTIFIER_NODE containing a name, and SUFFIX, a
148    string, return a new IDENTIFIER_NODE that is the concatenation of
149    the name in GNU_ID and SUFFIX.  */
150 extern tree concat_id_with_name (tree gnu_id, const char *suffix);
151
152 /* Return the name to be used for GNAT_ENTITY.  If a type, create a
153    fully-qualified name, possibly with type information encoding.
154    Otherwise, return the name.  */
155 extern tree get_entity_name (Entity_Id gnat_entity);
156
157 /* Return a name for GNAT_ENTITY concatenated with two underscores and
158    SUFFIX.  */
159 extern tree create_concat_name (Entity_Id gnat_entity, const char *suffix);
160
161 /* If true, then gigi is being called on an analyzed but unexpanded tree, and
162    the only purpose of the call is to properly annotate types with
163    representation information.  */
164 extern bool type_annotate_only;
165
166 /* Current file name without path */
167 extern const char *ref_filename;
168
169 /* This is the main program of the back-end.  It sets up all the table
170    structures and then generates code.
171
172    ??? Needs parameter descriptions  */
173
174 extern void gigi (Node_Id gnat_root, int max_gnat_node, int number_name,
175                   struct Node *nodes_ptr, Node_Id *next_node_ptr,
176                   Node_Id *prev_node_ptr, struct Elist_Header *elists_ptr,
177                   struct Elmt_Item *elmts_ptr,
178                   struct String_Entry *strings_ptr,
179                   Char_Code *strings_chars_ptr,
180                   struct List_Header *list_headers_ptr,
181                   Int number_units ATTRIBUTE_UNUSED,
182                   char *file_info_ptr ATTRIBUTE_UNUSED,
183                   Entity_Id standard_integer,
184                   Entity_Id standard_long_long_float,
185                   Entity_Id standard_exception_type,
186                   Int gigi_operating_mode);
187
188 /* GNAT_NODE is the root of some GNAT tree.  Return the root of the
189    GCC tree corresponding to that GNAT tree.  Normally, no code is generated;
190    we just return an equivalent tree which is used elsewhere to generate
191    code.  */
192 extern tree gnat_to_gnu (Node_Id gnat_node);
193
194 /* GNU_STMT is a statement.  We generate code for that statement.  */
195 extern void gnat_expand_stmt (tree gnu_stmt);
196
197 /* ??? missing documentation */
198 extern int gnat_gimplify_expr (tree *expr_p, tree *pre_p,
199                                tree *post_p ATTRIBUTE_UNUSED);
200
201 /* Do the processing for the declaration of a GNAT_ENTITY, a type.  If
202    a separate Freeze node exists, delay the bulk of the processing.  Otherwise
203    make a GCC type for GNAT_ENTITY and set up the correspondence.  */
204 extern void process_type (Entity_Id gnat_entity);
205
206 /* Convert Sloc into *LOCUS (a location_t).  Return true if this Sloc
207    corresponds to a source code location and false if it doesn't.  In the
208    latter case, we don't update *LOCUS.  We also set the Gigi global variable
209    REF_FILENAME to the reference file name as given by sinput (i.e no
210    directory).  */
211 extern bool Sloc_to_locus (Source_Ptr Sloc, location_t *locus);
212
213 /* Post an error message.  MSG is the error message, properly annotated.
214    NODE is the node at which to post the error and the node to use for the
215    "&" substitution.  */
216 extern void post_error (const char *, Node_Id);
217
218 /* Similar, but NODE is the node at which to post the error and ENT
219    is the node to use for the "&" substitution.  */
220 extern void post_error_ne (const char *msg, Node_Id node, Entity_Id ent);
221
222 /* Similar, but NODE is the node at which to post the error, ENT is the node
223    to use for the "&" substitution, and N is the number to use for the ^.  */
224 extern void post_error_ne_num (const char *msg, Node_Id node, Entity_Id ent,
225                                int n);
226
227 /* Similar to post_error_ne_num, but T is a GCC tree representing the number
228    to write.  If the tree represents a constant that fits within a
229    host integer, the text inside curly brackets in MSG will be output
230    (presumably including a '^').  Otherwise that text will not be output
231    and the text inside square brackets will be output instead.  */
232 extern void post_error_ne_tree (const char *msg, Node_Id node, Entity_Id ent,
233                                 tree t);
234
235 /* Similar to post_error_ne_tree, except that NUM is a second
236    integer to write in the message.  */
237 extern void post_error_ne_tree_2 (const char *msg, Node_Id node, Entity_Id ent,
238                                   tree t, int num);
239
240 /* Protect EXP from multiple evaluation.  This may make a SAVE_EXPR.  */
241 extern tree protect_multiple_eval (tree exp);
242
243 /* Initialize the table that maps GNAT codes to GCC codes for simple
244    binary and unary operations.  */
245 extern void init_code_table (void);
246
247 /* Current node being treated, in case gigi_abort or Check_Elaboration_Code
248    called.  */
249 extern Node_Id error_gnat_node;
250
251 /* This is equivalent to stabilize_reference in GCC's tree.c, but we know
252    how to handle our new nodes and we take an extra argument that says
253    whether to force evaluation of everything.  */
254 extern tree gnat_stabilize_reference (tree ref, bool force);
255
256 /* Highest number in the front-end node table.  */
257 extern int max_gnat_nodes;
258
259 /* If nonzero, pretend we are allocating at global level.  */
260 extern int force_global;
261
262 /* Standard data type sizes.  Most of these are not used.  */
263
264 #ifndef CHAR_TYPE_SIZE
265 #define CHAR_TYPE_SIZE BITS_PER_UNIT
266 #endif
267
268 #ifndef SHORT_TYPE_SIZE
269 #define SHORT_TYPE_SIZE (BITS_PER_UNIT * MIN ((UNITS_PER_WORD + 1) / 2, 2))
270 #endif
271
272 #ifndef INT_TYPE_SIZE
273 #define INT_TYPE_SIZE BITS_PER_WORD
274 #endif
275
276 #ifndef LONG_TYPE_SIZE
277 #define LONG_TYPE_SIZE BITS_PER_WORD
278 #endif
279
280 #ifndef LONG_LONG_TYPE_SIZE
281 #define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2)
282 #endif
283
284 #ifndef FLOAT_TYPE_SIZE
285 #define FLOAT_TYPE_SIZE BITS_PER_WORD
286 #endif
287
288 #ifndef DOUBLE_TYPE_SIZE
289 #define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
290 #endif
291
292 #ifndef LONG_DOUBLE_TYPE_SIZE
293 #define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
294 #endif
295
296 /* The choice of SIZE_TYPE here is very problematic.  We need a signed
297    type whose bit width is Pmode.  Assume "long" is such a type here.  */
298 #undef SIZE_TYPE
299 #define SIZE_TYPE "long int"
300
301 \f
302 /* Data structures used to represent attributes.  */
303
304 enum attr_type
305 {
306   ATTR_MACHINE_ATTRIBUTE,
307   ATTR_LINK_ALIAS,
308   ATTR_LINK_SECTION,
309   ATTR_LINK_CONSTRUCTOR,
310   ATTR_LINK_DESTRUCTOR,
311   ATTR_WEAK_EXTERNAL
312 };
313
314 struct attrib
315 {
316   struct attrib *next;
317   enum attr_type type;
318   tree name;
319   tree args;
320   Node_Id error_point;
321 };
322
323 /* Define the entries in the standard data array.  */
324 enum standard_datatypes
325 {
326 /* Various standard data types and nodes.  */
327   ADT_longest_float_type,
328   ADT_void_type_decl,
329
330   /* The type of an exception.  */
331   ADT_except_type,
332
333   /* Type declaration node  <==> typedef void *T */
334   ADT_ptr_void_type,
335
336   /* Function type declaration -- void T() */
337   ADT_void_ftype,
338
339   /* Type declaration node  <==> typedef void *T() */
340   ADT_ptr_void_ftype,
341
342   /* A function declaration node for a run-time function for allocating memory.
343      Ada allocators cause calls to this function to be generated.   */
344   ADT_malloc_decl,
345
346   /* Likewise for freeing memory.  */
347   ADT_free_decl,
348
349   /* Types and decls used by our temporary exception mechanism.  See
350      init_gigi_decls for details.  */
351   ADT_jmpbuf_type,
352   ADT_jmpbuf_ptr_type,
353   ADT_get_jmpbuf_decl,
354   ADT_set_jmpbuf_decl,
355   ADT_get_excptr_decl,
356   ADT_setjmp_decl,
357   ADT_longjmp_decl,
358   ADT_update_setjmp_buf_decl,
359   ADT_raise_nodefer_decl,
360   ADT_begin_handler_decl,
361   ADT_end_handler_decl,
362   ADT_others_decl,
363   ADT_all_others_decl,
364   ADT_LAST};
365
366 extern GTY(()) tree gnat_std_decls[(int) ADT_LAST];
367 extern GTY(()) tree gnat_raise_decls[(int) LAST_REASON_CODE + 1];
368
369 extern GTY(()) tree static_ctors;
370 extern GTY(()) tree static_dtors;
371
372 #define longest_float_type_node gnat_std_decls[(int) ADT_longest_float_type]
373 #define void_type_decl_node gnat_std_decls[(int) ADT_void_type_decl]
374 #define except_type_node gnat_std_decls[(int) ADT_except_type]
375 #define ptr_void_type_node gnat_std_decls[(int) ADT_ptr_void_type]
376 #define void_ftype gnat_std_decls[(int) ADT_void_ftype]
377 #define ptr_void_ftype gnat_std_decls[(int) ADT_ptr_void_ftype]
378 #define malloc_decl gnat_std_decls[(int) ADT_malloc_decl]
379 #define free_decl gnat_std_decls[(int) ADT_free_decl]
380 #define jmpbuf_type gnat_std_decls[(int) ADT_jmpbuf_type]
381 #define jmpbuf_ptr_type gnat_std_decls[(int) ADT_jmpbuf_ptr_type]
382 #define get_jmpbuf_decl gnat_std_decls[(int) ADT_get_jmpbuf_decl]
383 #define set_jmpbuf_decl gnat_std_decls[(int) ADT_set_jmpbuf_decl]
384 #define get_excptr_decl gnat_std_decls[(int) ADT_get_excptr_decl]
385 #define setjmp_decl gnat_std_decls[(int) ADT_setjmp_decl]
386 #define longjmp_decl gnat_std_decls[(int) ADT_longjmp_decl]
387 #define update_setjmp_buf_decl gnat_std_decls[(int) ADT_update_setjmp_buf_decl]
388 #define raise_nodefer_decl gnat_std_decls[(int) ADT_raise_nodefer_decl]
389 #define begin_handler_decl gnat_std_decls[(int) ADT_begin_handler_decl]
390 #define others_decl gnat_std_decls[(int) ADT_others_decl]
391 #define all_others_decl gnat_std_decls[(int) ADT_all_others_decl]
392 #define end_handler_decl gnat_std_decls[(int) ADT_end_handler_decl]
393
394 /* Routines expected by the gcc back-end. They must have exactly the same
395    prototype and names as below.  */
396
397 /* Returns non-zero if we are currently in the global binding level       */
398 extern int global_bindings_p (void);
399
400 /* Enter and exit a new binding level. */
401 extern void gnat_pushlevel (void);
402 extern void gnat_poplevel (void);
403
404 /* Set SUPERCONTEXT of the BLOCK for the current binding level to FNDECL
405    and point FNDECL to this BLOCK.  */
406 extern void set_current_block_context (tree fndecl);
407
408 /* Set the jmpbuf_decl for the current binding level to DECL.  */
409 extern void set_block_jmpbuf_decl (tree decl);
410
411 /* Get the setjmp_decl, if any, for the current binding level.  */
412 extern tree get_block_jmpbuf_decl (void);
413
414 /* Insert BLOCK at the end of the list of subblocks of the
415    current binding level.  This is used when a BIND_EXPR is expanded,
416    to handle the BLOCK node inside the BIND_EXPR.  */
417 extern void insert_block (tree block);
418
419 /* Records a ..._DECL node DECL as belonging to the current lexical scope
420    and uses GNAT_NODE for location information.  */
421 extern void gnat_pushdecl (tree decl, Node_Id gnat_node);
422
423 extern void gnat_init_stmt_group (void);
424 extern void gnat_init_decl_processing (void);
425 extern void init_gigi_decls (tree long_long_float_type, tree exception_type);
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 precision, int unsignedp);
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 mode, int unsignedp);
436
437 /* Return the unsigned version of a TYPE_NODE, a scalar type.  */
438 extern tree gnat_unsigned_type (tree type_node);
439
440 /* Return the signed version of a TYPE_NODE, a scalar type.  */
441 extern tree gnat_signed_type (tree type_node);
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 unsignedp, tree type);
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 type, tree expr);
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 gnat_entity, tree gnu_decl,
463                            bool no_check);
464
465 /* GNAT_ENTITY is a GNAT tree node for a defining identifier.
466    Return the ..._DECL node that was associated with it.  If there is no tree
467    node associated with GNAT_ENTITY, abort.  */
468 extern tree get_gnu_tree (Entity_Id gnat_entity);
469
470 /* Return nonzero if a GCC tree has been associated with GNAT_ENTITY.  */
471 extern bool present_gnu_tree (Entity_Id gnat_entity);
472
473 /* Initialize tables for above routines.  */
474 extern void init_gnat_to_gnu (void);
475
476 /* Given a record type (RECORD_TYPE) and a chain of FIELD_DECL
477    nodes (FIELDLIST), finish constructing the record or union type.
478    If HAS_REP is true, this record has a rep clause; don't call
479    layout_type but merely set the size and alignment ourselves.
480    If DEFER_DEBUG is true, do not call the debugging routines
481    on this type; it will be done later. */
482 extern void finish_record_type (tree record_type, tree fieldlist,
483                                 bool has_rep, bool defer_debug);
484
485 /*  Output the debug information associated to a record type.  */
486 extern void write_record_type_debug_info (tree);
487
488 /* Returns a FUNCTION_TYPE node. RETURN_TYPE is the type returned by the
489    subprogram. If it is void_type_node, then we are dealing with a procedure,
490    otherwise we are dealing with a function. PARAM_DECL_LIST is a list of
491    PARM_DECL nodes that are the subprogram arguments.  CICO_LIST is the
492    copy-in/copy-out list to be stored into TYPE_CI_CO_LIST.
493    RETURNS_UNCONSTRAINED is true if the function returns an unconstrained
494    object.  RETURNS_BY_REF is true if the function returns by reference.
495    RETURNS_WITH_DSP is true if the function is to return with a
496    depressed stack pointer.  RETURNS_BY_TARGET_PTR is true if the function
497    is to be passed (as its first parameter) the address of the place to copy
498    its result.  */
499 extern tree create_subprog_type (tree return_type, tree param_decl_list,
500                                  tree cico_list, bool returns_unconstrained,
501                                  bool returns_by_ref, bool returns_with_dsp,
502                                  bool returns_by_target_ptr);
503
504 /* Return a copy of TYPE, but safe to modify in any way.  */
505 extern tree copy_type (tree type);
506
507 /* Return an INTEGER_TYPE of SIZETYPE with range MIN to MAX and whose
508    TYPE_INDEX_TYPE is INDEX.  */
509 extern tree create_index_type (tree min, tree max, tree index);
510
511 /* Return a TYPE_DECL node. TYPE_NAME gives the name of the type (a character
512    string) and TYPE is a ..._TYPE node giving its data type.
513    ARTIFICIAL_P is true if this is a declaration that was generated
514    by the compiler.  DEBUG_INFO_P is true if we need to write debugging
515    information about this type.  GNAT_NODE is used for the position of
516    the decl.  */
517 extern tree create_type_decl (tree type_name, tree type,
518                               struct attrib *attr_list,
519                               bool artificial_p, bool debug_info_p,
520                               Node_Id gnat_node);
521
522 /* Returns a GCC VAR_DECL node. VAR_NAME gives the name of the variable.
523    ASM_NAME is its assembler name (if provided).  TYPE is
524    its data type (a GCC ..._TYPE node).  VAR_INIT is the GCC tree for an
525    optional initial expression; NULL_TREE if none.
526
527    CONST_FLAG is true if this variable is constant.
528
529    PUBLIC_FLAG is true if this definition is to be made visible outside of
530    the current compilation unit. This flag should be set when processing the
531    variable definitions in a package specification.  EXTERN_FLAG is nonzero
532    when processing an external variable declaration (as opposed to a
533    definition: no storage is to be allocated for the variable here).
534
535    STATIC_FLAG is only relevant when not at top level.  In that case
536    it indicates whether to always allocate storage to the variable.
537
538    GNAT_NODE is used for the position of the decl.  */
539 extern tree create_var_decl (tree var_name, tree asm_name, tree type,
540                              tree var_init, bool const_flag,
541                              bool public_flag, bool extern_flag,
542                              bool static_flag,
543                              struct attrib *attr_list, Node_Id gnat_node);
544
545 /* Given a DECL and ATTR_LIST, apply the listed attributes.  */
546 extern void process_attributes (tree decl, struct attrib *attr_list);
547
548 /* Returns a FIELD_DECL node. FIELD_NAME the field name, FIELD_TYPE is its
549    type, and RECORD_TYPE is the type of the parent.  PACKED is nonzero if
550    this field is in a record type with a "pragma pack".  If SIZE is nonzero
551    it is the specified size for this field.  If POS is nonzero, it is the bit
552    position.  If ADDRESSABLE is nonzero, it means we are allowed to take
553    the address of this field for aliasing purposes.  */
554 extern tree create_field_decl (tree field_name, tree field_type,
555                                tree record_type, int packed, tree size,
556                                tree pos, int addressable);
557
558 /* Returns a PARM_DECL node. PARAM_NAME is the name of the parameter,
559    PARAM_TYPE is its type.  READONLY is true if the parameter is
560    readonly (either an IN parameter or an address of a pass-by-ref
561    parameter). */
562 extern tree create_param_decl (tree param_name, tree param_type,
563                                bool readonly);
564
565 /* Returns a FUNCTION_DECL node.  SUBPROG_NAME is the name of the subprogram,
566    ASM_NAME is its assembler name, SUBPROG_TYPE is its type (a FUNCTION_TYPE
567    node), PARAM_DECL_LIST is the list of the subprogram arguments (a list of
568    PARM_DECL nodes chained through the TREE_CHAIN field).
569
570    INLINE_FLAG, PUBLIC_FLAG, EXTERN_FLAG, and ATTR_LIST are used to set the
571    appropriate fields in the FUNCTION_DECL.  GNAT_NODE gives the location.  */
572 extern tree create_subprog_decl (tree subprog_name, tree asm_name,
573                                  tree subprog_type, tree param_decl_list,
574                                  bool inlinee_flag, bool public_flag,
575                                  bool extern_flag,
576                                  struct attrib *attr_list, Node_Id gnat_node);
577
578 /* Returns a LABEL_DECL node for LABEL_NAME.  */
579 extern tree create_label_decl (tree label_name);
580
581 /* Set up the framework for generating code for SUBPROG_DECL, a subprogram
582    body. This routine needs to be invoked before processing the declarations
583    appearing in the subprogram.  */
584 extern void begin_subprog_body (tree subprog_decl);
585
586 /* Finish the definition of the current subprogram and compile it all the way
587    to assembler language output.  BODY is the tree corresponding to
588    the subprogram.  */
589 extern void end_subprog_body (tree body);
590
591 /* Build a template of type TEMPLATE_TYPE from the array bounds of ARRAY_TYPE.
592    EXPR is an expression that we can use to locate any PLACEHOLDER_EXPRs.
593    Return a constructor for the template.  */
594 extern tree build_template (tree template_type, tree array_type, tree expr);
595
596 /* Build a VMS descriptor from a Mechanism_Type, which must specify
597    a descriptor type, and the GCC type of an object.  Each FIELD_DECL
598    in the type contains in its DECL_INITIAL the expression to use when
599    a constructor is made for the type.  GNAT_ENTITY is a gnat node used
600    to print out an error message if the mechanism cannot be applied to
601    an object of that type and also for the name.  */
602
603 extern tree build_vms_descriptor (tree type, Mechanism_Type mech,
604                                   Entity_Id gnat_entity);
605
606 /* Build a type to be used to represent an aliased object whose nominal
607    type is an unconstrained array.  This consists of a RECORD_TYPE containing
608    a field of TEMPLATE_TYPE and a field of OBJECT_TYPE, which is an
609    ARRAY_TYPE.  If ARRAY_TYPE is that of the unconstrained array, this
610    is used to represent an arbitrary unconstrained object.  Use NAME
611    as the name of the record.  */
612 extern tree build_unc_object_type (tree template_type, tree object_type,
613                                    tree name);
614
615 /* Update anything previously pointing to OLD_TYPE to point to NEW_TYPE.  In
616    the normal case this is just two adjustments, but we have more to do
617    if NEW is an UNCONSTRAINED_ARRAY_TYPE.  */
618 extern void update_pointer_to (tree old_type, tree new_type);
619
620 /* EXP is an expression for the size of an object.  If this size contains
621    discriminant references, replace them with the maximum (if MAX_P) or
622    minimum (if !MAX_P) possible value of the discriminant.  */
623 extern tree max_size (tree exp, bool max_p);
624
625 /* Remove all conversions that are done in EXP.  This includes converting
626    from a padded type or to a left-justified modular type.  If TRUE_ADDRESS
627    is true, always return the address of the containing object even if
628    the address is not bit-aligned.  */
629 extern tree remove_conversions (tree exp, bool true_address);
630
631 /* If EXP's type is an UNCONSTRAINED_ARRAY_TYPE, return an expression that
632    refers to the underlying array.  If its type has TYPE_CONTAINS_TEMPLATE_P,
633    likewise return an expression pointing to the underlying array.  */
634 extern tree maybe_unconstrained_array (tree exp);
635
636 /* Return an expression that does an unchecked conversion of EXPR to TYPE.
637    If NOTRUNC_P is true, truncation operations should be suppressed.  */
638 extern tree unchecked_convert (tree type, tree expr, bool notrunc_p);
639
640 /* Prepare expr to be an argument of a TRUTH_NOT_EXPR or other logical
641    operation.
642
643    This preparation consists of taking the ordinary
644    representation of an expression EXPR and producing a valid tree
645    boolean expression describing whether EXPR is nonzero.  We could
646    simply always do build_binary_op (NE_EXPR, expr, integer_zero_node, 1),
647    but we optimize comparisons, &&, ||, and !.
648
649    The resulting type should always be the same as the input type.
650    This function is simpler than the corresponding C version since
651    the only possible operands will be things of Boolean type.  */
652 extern tree gnat_truthvalue_conversion (tree expr);
653
654 /* Return the base type of TYPE.  */
655 extern tree get_base_type (tree type);
656
657 /* Likewise, but only return types known at Ada source.  */
658 extern tree get_ada_base_type (tree type);
659
660 /* EXP is a GCC tree representing an address.  See if we can find how
661    strictly the object at that address is aligned.   Return that alignment
662    strictly the object at that address is aligned.   Return that alignment
663    in bits.  If we don't know anything about the alignment, return 0.  */
664 extern unsigned int known_alignment (tree exp);
665
666 /* Make a binary operation of kind OP_CODE.  RESULT_TYPE is the type
667    desired for the result.  Usually the operation is to be performed
668    in that type.  For MODIFY_EXPR and ARRAY_REF, RESULT_TYPE may be 0
669    in which case the type to be used will be derived from the operands.  */
670 extern tree build_binary_op (enum tree_code op_code, tree retult_type,
671                              tree left_operand, tree right_operand);
672
673 /* Similar, but make unary operation.   */
674 extern tree build_unary_op (enum tree_code op_code, tree result_type,
675                             tree operand);
676
677 /* Similar, but for COND_EXPR.  */
678 extern tree build_cond_expr (tree result_type, tree condition_operand,
679                              tree true_operand, tree false_operand);
680
681 /* Build a CALL_EXPR to call FUNDECL with one argument, ARG.  Return
682    the CALL_EXPR.  */
683 extern tree build_call_1_expr (tree fundecl, tree arg);
684
685 /* Build a CALL_EXPR to call FUNDECL with two argument, ARG1 & ARG2.  Return
686    the CALL_EXPR.  */
687 extern tree build_call_2_expr (tree fundecl, tree arg1, tree arg2);
688
689 /* Likewise to call FUNDECL with no arguments.  */
690 extern tree build_call_0_expr (tree fundecl);
691
692 /* Call a function that raises an exception and pass the line number and file
693    name, if requested.  MSG says which exception function to call.  */
694 extern tree build_call_raise (int msg);
695
696 /* Return a CONSTRUCTOR of TYPE whose list is LIST.  This is not the
697    same as build_constructor in the language-independent tree.c.  */
698 extern tree gnat_build_constructor (tree type, tree list);
699
700 /* Return a COMPONENT_REF to access a field that is given by COMPONENT,
701    an IDENTIFIER_NODE giving the name of the field, FIELD, a FIELD_DECL,
702    for the field, or both.  Don't fold the result if NO_FOLD_P.  */
703 extern tree build_component_ref (tree record_variable, tree component,
704                                  tree field, bool no_fold_p);
705
706 /* Build a GCC tree to call an allocation or deallocation function.
707    If GNU_OBJ is nonzero, it is an object to deallocate.  Otherwise,
708    genrate an allocator.
709
710    GNU_SIZE is the size of the object and ALIGN is the alignment.
711    GNAT_PROC, if present is a procedure to call and GNAT_POOL is the
712    storage pool to use.  If not preset, malloc and free will be used.  */
713 extern tree build_call_alloc_dealloc (tree gnu_obj, tree gnu_size,
714                                       unsigned align, Entity_Id gnat_proc,
715                                       Entity_Id gnat_pool, Node_Id gnat_node);
716
717 /* Build a GCC tree to correspond to allocating an object of TYPE whose
718    initial value if INIT, if INIT is nonzero.  Convert the expression to
719    RESULT_TYPE, which must be some type of pointer.  Return the tree.
720    GNAT_PROC and GNAT_POOL optionally give the procedure to call and
721    the storage pool to use.  GNAT_NODE is used to provide an error
722    location for restriction violations messages.  If IGNORE_INIT_TYPE is
723    true, ignore the type of INIT for the purpose of determining the size;
724    this will cause the maximum size to be allocated if TYPE is of
725    self-referential size.  */
726 extern tree build_allocator (tree type, tree init, tree result_type,
727                              Entity_Id gnat_proc, Entity_Id gnat_pool,
728                              Node_Id gnat_node, bool);
729
730 /* Fill in a VMS descriptor for EXPR and return a constructor for it.
731    GNAT_FORMAL is how we find the descriptor record.  */
732
733 extern tree fill_vms_descriptor (tree expr, Entity_Id gnat_formal);
734
735 /* Indicate that we need to make the address of EXPR_NODE and it therefore
736    should not be allocated in a register.  Return true if successful.  */
737 extern bool gnat_mark_addressable (tree expr_node);
738
739 /* Implementation of the builtin_function langhook.  */
740 extern tree builtin_function (const char *name, tree type, int function_code,
741                               enum built_in_class class,
742                               const char *library_name, tree attrs);
743
744 /* Search the chain of currently reachable declarations for a builtin
745    FUNCTION_DECL node corresponding to function NAME (an IDENTIFIER_NODE).
746    Return the first node found, if any, or NULL_TREE otherwise.  */
747 extern tree builtin_decl_for (tree name ATTRIBUTE_UNUSED);
748
749 /* This function is called by the front end to enumerate all the supported
750    modes for the machine.  We pass a function which is called back with
751    the following integer parameters:
752
753    FLOAT_P      nonzero if this represents a floating-point mode
754    COMPLEX_P    nonzero is this represents a complex mode
755    COUNT        count of number of items, nonzero for vector mode
756    PRECISION    number of bits in data representation
757    MANTISSA     number of bits in mantissa, if FP and known, else zero.
758    SIZE         number of bits used to store data
759    ALIGN        number of bits to which mode is aligned.  */
760 extern void enumerate_modes (void (*f) (int, int, int, int, int, int,
761                                         unsigned int));
762
763 /* These are temporary function to deal with recent GCC changes related to
764    FP type sizes and precisions.  */
765 extern int fp_prec_to_size (int prec);
766 extern int fp_size_to_prec (int size);
767
768 /* These functions return the basic data type sizes and related parameters
769    about the target machine.  */
770
771 extern Pos get_target_bits_per_unit (void);
772 extern Pos get_target_bits_per_word (void);
773 extern Pos get_target_char_size (void);
774 extern Pos get_target_wchar_t_size (void);
775 extern Pos get_target_short_size (void);
776 extern Pos get_target_int_size (void);
777 extern Pos get_target_long_size (void);
778 extern Pos get_target_long_long_size (void);
779 extern Pos get_target_float_size (void);
780 extern Pos get_target_double_size (void);
781 extern Pos get_target_long_double_size (void);
782 extern Pos get_target_pointer_size (void);
783 extern Pos get_target_maximum_alignment (void);
784 extern Nat get_float_words_be (void);
785 extern Nat get_words_be (void);
786 extern Nat get_bytes_be (void);
787 extern Nat get_bits_be (void);
788 extern Nat get_strict_alignment (void);