OSDN Git Service

New file.
[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-2006, 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 nonzero
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 how
252    to handle our new nodes and we take extra arguments.
253
254    FORCE says whether to force evaluation of everything,
255
256    SUCCESS we set to true unless we walk through something we don't
257    know how to stabilize, or through something which is not an lvalue
258    and LVALUES_ONLY is true, in which cases we set to false.  */
259 extern tree maybe_stabilize_reference (tree ref, bool force, bool lvalues_only,
260                                        bool *success);
261
262 /* Wrapper around maybe_stabilize_reference, for common uses without
263    lvalue restrictions and without need to examine the success
264    indication.  */
265
266 extern tree gnat_stabilize_reference (tree ref, bool force);
267
268 /* Highest number in the front-end node table.  */
269 extern int max_gnat_nodes;
270
271 /* If nonzero, pretend we are allocating at global level.  */
272 extern int force_global;
273
274 /* Standard data type sizes.  Most of these are not used.  */
275
276 #ifndef CHAR_TYPE_SIZE
277 #define CHAR_TYPE_SIZE BITS_PER_UNIT
278 #endif
279
280 #ifndef SHORT_TYPE_SIZE
281 #define SHORT_TYPE_SIZE (BITS_PER_UNIT * MIN ((UNITS_PER_WORD + 1) / 2, 2))
282 #endif
283
284 #ifndef INT_TYPE_SIZE
285 #define INT_TYPE_SIZE BITS_PER_WORD
286 #endif
287
288 #ifndef LONG_TYPE_SIZE
289 #define LONG_TYPE_SIZE BITS_PER_WORD
290 #endif
291
292 #ifndef LONG_LONG_TYPE_SIZE
293 #define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2)
294 #endif
295
296 #ifndef FLOAT_TYPE_SIZE
297 #define FLOAT_TYPE_SIZE BITS_PER_WORD
298 #endif
299
300 #ifndef DOUBLE_TYPE_SIZE
301 #define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
302 #endif
303
304 #ifndef LONG_DOUBLE_TYPE_SIZE
305 #define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
306 #endif
307
308 /* The choice of SIZE_TYPE here is very problematic.  We need a signed
309    type whose bit width is Pmode.  Assume "long" is such a type here.  */
310 #undef SIZE_TYPE
311 #define SIZE_TYPE "long int"
312 \f
313 /* Data structures used to represent attributes.  */
314
315 enum attr_type
316 {
317   ATTR_MACHINE_ATTRIBUTE,
318   ATTR_LINK_ALIAS,
319   ATTR_LINK_SECTION,
320   ATTR_LINK_CONSTRUCTOR,
321   ATTR_LINK_DESTRUCTOR,
322   ATTR_WEAK_EXTERNAL
323 };
324
325 struct attrib
326 {
327   struct attrib *next;
328   enum attr_type type;
329   tree name;
330   tree args;
331   Node_Id error_point;
332 };
333
334 /* Table of machine-independent internal attributes.  */
335 extern const struct attribute_spec gnat_internal_attribute_table[];
336
337 /* Define the entries in the standard data array.  */
338 enum standard_datatypes
339 {
340 /* Various standard data types and nodes.  */
341   ADT_longest_float_type,
342   ADT_void_type_decl,
343
344   /* The type of an exception.  */
345   ADT_except_type,
346
347   /* Type declaration node  <==> typedef void *T */
348   ADT_ptr_void_type,
349
350   /* Function type declaration -- void T() */
351   ADT_void_ftype,
352
353   /* Type declaration node  <==> typedef void *T() */
354   ADT_ptr_void_ftype,
355
356   /* A function declaration node for a run-time function for allocating memory.
357      Ada allocators cause calls to this function to be generated.   */
358   ADT_malloc_decl,
359
360   /* Likewise for freeing memory.  */
361   ADT_free_decl,
362
363   /* Types and decls used by our temporary exception mechanism.  See
364      init_gigi_decls for details.  */
365   ADT_jmpbuf_type,
366   ADT_jmpbuf_ptr_type,
367   ADT_get_jmpbuf_decl,
368   ADT_set_jmpbuf_decl,
369   ADT_get_excptr_decl,
370   ADT_setjmp_decl,
371   ADT_longjmp_decl,
372   ADT_update_setjmp_buf_decl,
373   ADT_raise_nodefer_decl,
374   ADT_begin_handler_decl,
375   ADT_end_handler_decl,
376   ADT_others_decl,
377   ADT_all_others_decl,
378   ADT_LAST};
379
380 extern GTY(()) tree gnat_std_decls[(int) ADT_LAST];
381 extern GTY(()) tree gnat_raise_decls[(int) LAST_REASON_CODE + 1];
382
383 #define longest_float_type_node gnat_std_decls[(int) ADT_longest_float_type]
384 #define void_type_decl_node gnat_std_decls[(int) ADT_void_type_decl]
385 #define except_type_node gnat_std_decls[(int) ADT_except_type]
386 #define ptr_void_type_node gnat_std_decls[(int) ADT_ptr_void_type]
387 #define void_ftype gnat_std_decls[(int) ADT_void_ftype]
388 #define ptr_void_ftype gnat_std_decls[(int) ADT_ptr_void_ftype]
389 #define malloc_decl gnat_std_decls[(int) ADT_malloc_decl]
390 #define free_decl gnat_std_decls[(int) ADT_free_decl]
391 #define jmpbuf_type gnat_std_decls[(int) ADT_jmpbuf_type]
392 #define jmpbuf_ptr_type gnat_std_decls[(int) ADT_jmpbuf_ptr_type]
393 #define get_jmpbuf_decl gnat_std_decls[(int) ADT_get_jmpbuf_decl]
394 #define set_jmpbuf_decl gnat_std_decls[(int) ADT_set_jmpbuf_decl]
395 #define get_excptr_decl gnat_std_decls[(int) ADT_get_excptr_decl]
396 #define setjmp_decl gnat_std_decls[(int) ADT_setjmp_decl]
397 #define longjmp_decl gnat_std_decls[(int) ADT_longjmp_decl]
398 #define update_setjmp_buf_decl gnat_std_decls[(int) ADT_update_setjmp_buf_decl]
399 #define raise_nodefer_decl gnat_std_decls[(int) ADT_raise_nodefer_decl]
400 #define begin_handler_decl gnat_std_decls[(int) ADT_begin_handler_decl]
401 #define others_decl gnat_std_decls[(int) ADT_others_decl]
402 #define all_others_decl gnat_std_decls[(int) ADT_all_others_decl]
403 #define end_handler_decl gnat_std_decls[(int) ADT_end_handler_decl]
404
405 /* Routines expected by the gcc back-end. They must have exactly the same
406    prototype and names as below.  */
407
408 /* Returns nonzero if we are currently in the global binding level.  */
409 extern int global_bindings_p (void);
410
411 /* Enter and exit a new binding level. */
412 extern void gnat_pushlevel (void);
413 extern void gnat_poplevel (void);
414
415 /* Set SUPERCONTEXT of the BLOCK for the current binding level to FNDECL
416    and point FNDECL to this BLOCK.  */
417 extern void set_current_block_context (tree fndecl);
418
419 /* Set the jmpbuf_decl for the current binding level to DECL.  */
420 extern void set_block_jmpbuf_decl (tree decl);
421
422 /* Get the setjmp_decl, if any, for the current binding level.  */
423 extern tree get_block_jmpbuf_decl (void);
424
425 /* Insert BLOCK at the end of the list of subblocks of the
426    current binding level.  This is used when a BIND_EXPR is expanded,
427    to handle the BLOCK node inside the BIND_EXPR.  */
428 extern void insert_block (tree block);
429
430 /* Records a ..._DECL node DECL as belonging to the current lexical scope
431    and uses GNAT_NODE for location information.  */
432 extern void gnat_pushdecl (tree decl, Node_Id gnat_node);
433
434 extern void gnat_init_stmt_group (void);
435 extern void gnat_init_decl_processing (void);
436 extern void init_gigi_decls (tree long_long_float_type, tree exception_type);
437 extern void gnat_init_gcc_eh (void);
438
439 /* Return an integer type with the number of bits of precision given by
440    PRECISION.  UNSIGNEDP is nonzero if the type is unsigned; otherwise
441    it is a signed type.  */
442 extern tree gnat_type_for_size (unsigned precision, int unsignedp);
443
444 /* Return a data type that has machine mode MODE.  UNSIGNEDP selects
445    an unsigned type; otherwise a signed type is returned.  */
446 extern tree gnat_type_for_mode (enum machine_mode mode, int unsignedp);
447
448 /* Emit debug info for all global variable declarations.  */
449 extern void gnat_write_global_declarations (void);
450
451 /* Return the unsigned version of a TYPE_NODE, a scalar type.  */
452 extern tree gnat_unsigned_type (tree type_node);
453
454 /* Return the signed version of a TYPE_NODE, a scalar type.  */
455 extern tree gnat_signed_type (tree type_node);
456
457 /* Create an expression whose value is that of EXPR,
458    converted to type TYPE.  The TREE_TYPE of the value
459    is always TYPE.  This function implements all reasonable
460    conversions; callers should filter out those that are
461    not permitted by the language being compiled.  */
462 extern tree convert (tree type, tree expr);
463
464 /* Routines created solely for the tree translator's sake. Their prototypes
465    can be changed as desired.  */
466
467 /* GNAT_ENTITY is a GNAT tree node for a defining identifier.
468    GNU_DECL is the GCC tree which is to be associated with
469    GNAT_ENTITY. Such gnu tree node is always an ..._DECL node.
470    If NO_CHECK is nonzero, the latter check is suppressed.
471    If GNU_DECL is zero, a previous association is to be reset.  */
472 extern void save_gnu_tree (Entity_Id gnat_entity, tree gnu_decl,
473                            bool no_check);
474
475 /* GNAT_ENTITY is a GNAT tree node for a defining identifier.
476    Return the ..._DECL node that was associated with it.  If there is no tree
477    node associated with GNAT_ENTITY, abort.  */
478 extern tree get_gnu_tree (Entity_Id gnat_entity);
479
480 /* Return nonzero if a GCC tree has been associated with GNAT_ENTITY.  */
481 extern bool present_gnu_tree (Entity_Id gnat_entity);
482
483 /* Initialize tables for above routines.  */
484 extern void init_gnat_to_gnu (void);
485
486 /* Given a record type (RECORD_TYPE) and a chain of FIELD_DECL
487    nodes (FIELDLIST), finish constructing the record or union type.
488    If HAS_REP is true, this record has a rep clause; don't call
489    layout_type but merely set the size and alignment ourselves.
490    If DEFER_DEBUG is true, do not call the debugging routines
491    on this type; it will be done later. */
492 extern void finish_record_type (tree record_type, tree fieldlist,
493                                 bool has_rep, bool defer_debug);
494
495 /*  Output the debug information associated to a record type.  */
496 extern void write_record_type_debug_info (tree);
497
498 /* Returns a FUNCTION_TYPE node. RETURN_TYPE is the type returned by the
499    subprogram. If it is void_type_node, then we are dealing with a procedure,
500    otherwise we are dealing with a function. PARAM_DECL_LIST is a list of
501    PARM_DECL nodes that are the subprogram arguments.  CICO_LIST is the
502    copy-in/copy-out list to be stored into TYPE_CI_CO_LIST.
503    RETURNS_UNCONSTRAINED is true if the function returns an unconstrained
504    object.  RETURNS_BY_REF is true if the function returns by reference.
505    RETURNS_WITH_DSP is true if the function is to return with a
506    depressed stack pointer.  RETURNS_BY_TARGET_PTR is true if the function
507    is to be passed (as its first parameter) the address of the place to copy
508    its result.  */
509 extern tree create_subprog_type (tree return_type, tree param_decl_list,
510                                  tree cico_list, bool returns_unconstrained,
511                                  bool returns_by_ref, bool returns_with_dsp,
512                                  bool returns_by_target_ptr);
513
514 /* Return a copy of TYPE, but safe to modify in any way.  */
515 extern tree copy_type (tree type);
516
517 /* Return an INTEGER_TYPE of SIZETYPE with range MIN to MAX and whose
518    TYPE_INDEX_TYPE is INDEX.  */
519 extern tree create_index_type (tree min, tree max, tree index);
520
521 /* Return a TYPE_DECL node. TYPE_NAME gives the name of the type (a character
522    string) and TYPE is a ..._TYPE node giving its data type.
523    ARTIFICIAL_P is true if this is a declaration that was generated
524    by the compiler.  DEBUG_INFO_P is true if we need to write debugging
525    information about this type.  GNAT_NODE is used for the position of
526    the decl.  */
527 extern tree create_type_decl (tree type_name, tree type,
528                               struct attrib *attr_list,
529                               bool artificial_p, bool debug_info_p,
530                               Node_Id gnat_node);
531
532 /* Returns a GCC VAR_DECL or CONST_DECL node.
533
534    VAR_NAME gives the name of the variable.  ASM_NAME is its assembler name
535    (if provided).  TYPE is its data type (a GCC ..._TYPE node).  VAR_INIT is
536    the GCC tree for an optional initial expression; NULL_TREE if none.
537
538    CONST_FLAG is true if this variable is constant.
539
540    PUBLIC_FLAG is true if this definition is to be made visible outside of
541    the current compilation unit. This flag should be set when processing the
542    variable definitions in a package specification.  EXTERN_FLAG is nonzero
543    when processing an external variable declaration (as opposed to a
544    definition: no storage is to be allocated for the variable here).
545
546    STATIC_FLAG is only relevant when not at top level.  In that case
547    it indicates whether to always allocate storage to the variable.
548
549    GNAT_NODE is used for the position of the decl.  */
550 extern tree create_var_decl (tree var_name, tree asm_name, tree type,
551                              tree var_init, bool const_flag,
552                              bool public_flag, bool extern_flag,
553                              bool static_flag,
554                              struct attrib *attr_list, Node_Id gnat_node);
555
556 /* Similar to create_var_decl, forcing the creation of a VAR_DECL node.  */
557 extern tree create_true_var_decl (tree var_name, tree asm_name, tree type,
558                                   tree var_init, bool const_flag,
559                                   bool public_flag, bool extern_flag,
560                                   bool static_flag,
561                                   struct attrib *attr_list, Node_Id gnat_node);
562
563 /* Given a DECL and ATTR_LIST, apply the listed attributes.  */
564 extern void process_attributes (tree decl, struct attrib *attr_list);
565
566 /* Record a global renaming pointer.  */
567 void record_global_renaming_pointer (tree);
568
569 /* Invalidate the global renaming pointers.   */
570 void invalidate_global_renaming_pointers (void);
571
572 /* Returns a FIELD_DECL node. FIELD_NAME the field name, FIELD_TYPE is its
573    type, and RECORD_TYPE is the type of the parent.  PACKED is nonzero if
574    this field is in a record type with a "pragma pack".  If SIZE is nonzero
575    it is the specified size for this field.  If POS is nonzero, it is the bit
576    position.  If ADDRESSABLE is nonzero, it means we are allowed to take
577    the address of this field for aliasing purposes.  */
578 extern tree create_field_decl (tree field_name, tree field_type,
579                                tree record_type, int packed, tree size,
580                                tree pos, int addressable);
581
582 /* Returns a PARM_DECL node. PARAM_NAME is the name of the parameter,
583    PARAM_TYPE is its type.  READONLY is true if the parameter is
584    readonly (either an IN parameter or an address of a pass-by-ref
585    parameter). */
586 extern tree create_param_decl (tree param_name, tree param_type,
587                                bool readonly);
588
589 /* Returns a FUNCTION_DECL node.  SUBPROG_NAME is the name of the subprogram,
590    ASM_NAME is its assembler name, SUBPROG_TYPE is its type (a FUNCTION_TYPE
591    node), PARAM_DECL_LIST is the list of the subprogram arguments (a list of
592    PARM_DECL nodes chained through the TREE_CHAIN field).
593
594    INLINE_FLAG, PUBLIC_FLAG, EXTERN_FLAG, and ATTR_LIST are used to set the
595    appropriate fields in the FUNCTION_DECL.  GNAT_NODE gives the location.  */
596 extern tree create_subprog_decl (tree subprog_name, tree asm_name,
597                                  tree subprog_type, tree param_decl_list,
598                                  bool inlinee_flag, bool public_flag,
599                                  bool extern_flag,
600                                  struct attrib *attr_list, Node_Id gnat_node);
601
602 /* Returns a LABEL_DECL node for LABEL_NAME.  */
603 extern tree create_label_decl (tree label_name);
604
605 /* Set up the framework for generating code for SUBPROG_DECL, a subprogram
606    body. This routine needs to be invoked before processing the declarations
607    appearing in the subprogram.  */
608 extern void begin_subprog_body (tree subprog_decl);
609
610 /* Finish the definition of the current subprogram and compile it all the way
611    to assembler language output.  BODY is the tree corresponding to
612    the subprogram.  */
613 extern void end_subprog_body (tree body);
614
615 /* Build a template of type TEMPLATE_TYPE from the array bounds of ARRAY_TYPE.
616    EXPR is an expression that we can use to locate any PLACEHOLDER_EXPRs.
617    Return a constructor for the template.  */
618 extern tree build_template (tree template_type, tree array_type, tree expr);
619
620 /* Build a VMS descriptor from a Mechanism_Type, which must specify
621    a descriptor type, and the GCC type of an object.  Each FIELD_DECL
622    in the type contains in its DECL_INITIAL the expression to use when
623    a constructor is made for the type.  GNAT_ENTITY is a gnat node used
624    to print out an error message if the mechanism cannot be applied to
625    an object of that type and also for the name.  */
626
627 extern tree build_vms_descriptor (tree type, Mechanism_Type mech,
628                                   Entity_Id gnat_entity);
629
630 /* Build a type to be used to represent an aliased object whose nominal
631    type is an unconstrained array.  This consists of a RECORD_TYPE containing
632    a field of TEMPLATE_TYPE and a field of OBJECT_TYPE, which is an
633    ARRAY_TYPE.  If ARRAY_TYPE is that of the unconstrained array, this
634    is used to represent an arbitrary unconstrained object.  Use NAME
635    as the name of the record.  */
636 extern tree build_unc_object_type (tree template_type, tree object_type,
637                                    tree name);
638
639 /* Same as build_unc_object_type, but taking a thin or fat pointer type
640    instead of the template type. */
641 extern tree build_unc_object_type_from_ptr (tree thin_fat_ptr_type,
642                                             tree object_type, tree name);
643
644 /* Update anything previously pointing to OLD_TYPE to point to NEW_TYPE.  In
645    the normal case this is just two adjustments, but we have more to do
646    if NEW is an UNCONSTRAINED_ARRAY_TYPE.  */
647 extern void update_pointer_to (tree old_type, tree new_type);
648
649 /* EXP is an expression for the size of an object.  If this size contains
650    discriminant references, replace them with the maximum (if MAX_P) or
651    minimum (if !MAX_P) possible value of the discriminant.  */
652 extern tree max_size (tree exp, bool max_p);
653
654 /* Remove all conversions that are done in EXP.  This includes converting
655    from a padded type or to a left-justified modular type.  If TRUE_ADDRESS
656    is true, always return the address of the containing object even if
657    the address is not bit-aligned.  */
658 extern tree remove_conversions (tree exp, bool true_address);
659
660 /* If EXP's type is an UNCONSTRAINED_ARRAY_TYPE, return an expression that
661    refers to the underlying array.  If its type has TYPE_CONTAINS_TEMPLATE_P,
662    likewise return an expression pointing to the underlying array.  */
663 extern tree maybe_unconstrained_array (tree exp);
664
665 /* Return an expression that does an unchecked conversion of EXPR to TYPE.
666    If NOTRUNC_P is true, truncation operations should be suppressed.  */
667 extern tree unchecked_convert (tree type, tree expr, bool notrunc_p);
668
669 /* Return the appropriate GCC tree code for the specified GNAT type,
670    the latter being a record type as predicated by Is_Record_Type.  */
671 extern enum tree_code tree_code_for_record_type (Entity_Id);
672
673 /* Prepare expr to be an argument of a TRUTH_NOT_EXPR or other logical
674    operation.
675
676    This preparation consists of taking the ordinary
677    representation of an expression EXPR and producing a valid tree
678    boolean expression describing whether EXPR is nonzero.  We could
679    simply always do build_binary_op (NE_EXPR, expr, integer_zero_node, 1),
680    but we optimize comparisons, &&, ||, and !.
681
682    The resulting type should always be the same as the input type.
683    This function is simpler than the corresponding C version since
684    the only possible operands will be things of Boolean type.  */
685 extern tree gnat_truthvalue_conversion (tree expr);
686
687 /* Return the base type of TYPE.  */
688 extern tree get_base_type (tree type);
689
690 /* EXP is a GCC tree representing an address.  See if we can find how
691    strictly the object at that address is aligned.   Return that alignment
692    strictly the object at that address is aligned.   Return that alignment
693    in bits.  If we don't know anything about the alignment, return 0.  */
694 extern unsigned int known_alignment (tree exp);
695
696 /* Return true if VALUE is a multiple of FACTOR. FACTOR must be a power
697    of 2. */
698 extern bool value_factor_p (tree value, HOST_WIDE_INT factor);
699
700 /* Make a binary operation of kind OP_CODE.  RESULT_TYPE is the type
701    desired for the result.  Usually the operation is to be performed
702    in that type.  For MODIFY_EXPR and ARRAY_REF, RESULT_TYPE may be 0
703    in which case the type to be used will be derived from the operands.  */
704 extern tree build_binary_op (enum tree_code op_code, tree retult_type,
705                              tree left_operand, tree right_operand);
706
707 /* Similar, but make unary operation.   */
708 extern tree build_unary_op (enum tree_code op_code, tree result_type,
709                             tree operand);
710
711 /* Similar, but for COND_EXPR.  */
712 extern tree build_cond_expr (tree result_type, tree condition_operand,
713                              tree true_operand, tree false_operand);
714
715 /* Similar, but for RETURN_EXPR.  */
716 extern tree build_return_expr (tree result_decl, tree ret_val);
717
718 /* Build a CALL_EXPR to call FUNDECL with one argument, ARG.  Return
719    the CALL_EXPR.  */
720 extern tree build_call_1_expr (tree fundecl, tree arg);
721
722 /* Build a CALL_EXPR to call FUNDECL with two argument, ARG1 & ARG2.  Return
723    the CALL_EXPR.  */
724 extern tree build_call_2_expr (tree fundecl, tree arg1, tree arg2);
725
726 /* Likewise to call FUNDECL with no arguments.  */
727 extern tree build_call_0_expr (tree fundecl);
728
729 /* Call a function that raises an exception and pass the line number and file
730    name, if requested.  MSG says which exception function to call.
731
732    GNAT_NODE is the gnat node conveying the source location for which the
733    error should be signaled, or Empty in which case the error is signaled on
734    the current ref_file_name/input_line.  */
735 extern tree build_call_raise (int msg, Node_Id gnat_node);
736
737 /* Return a CONSTRUCTOR of TYPE whose list is LIST.  This is not the
738    same as build_constructor in the language-independent tree.c.  */
739 extern tree gnat_build_constructor (tree type, tree list);
740
741 /* Return a COMPONENT_REF to access a field that is given by COMPONENT,
742    an IDENTIFIER_NODE giving the name of the field, FIELD, a FIELD_DECL,
743    for the field, or both.  Don't fold the result if NO_FOLD_P.  */
744 extern tree build_component_ref (tree record_variable, tree component,
745                                  tree field, bool no_fold_p);
746
747 /* Build a GCC tree to call an allocation or deallocation function.
748    If GNU_OBJ is nonzero, it is an object to deallocate.  Otherwise,
749    genrate an allocator.
750
751    GNU_SIZE is the size of the object and ALIGN is the alignment.
752    GNAT_PROC, if present is a procedure to call and GNAT_POOL is the
753    storage pool to use.  If not preset, malloc and free will be used.  */
754 extern tree build_call_alloc_dealloc (tree gnu_obj, tree gnu_size,
755                                       unsigned align, Entity_Id gnat_proc,
756                                       Entity_Id gnat_pool, Node_Id gnat_node);
757
758 /* Build a GCC tree to correspond to allocating an object of TYPE whose
759    initial value if INIT, if INIT is nonzero.  Convert the expression to
760    RESULT_TYPE, which must be some type of pointer.  Return the tree.
761    GNAT_PROC and GNAT_POOL optionally give the procedure to call and
762    the storage pool to use.  GNAT_NODE is used to provide an error
763    location for restriction violations messages.  If IGNORE_INIT_TYPE is
764    true, ignore the type of INIT for the purpose of determining the size;
765    this will cause the maximum size to be allocated if TYPE is of
766    self-referential size.  */
767 extern tree build_allocator (tree type, tree init, tree result_type,
768                              Entity_Id gnat_proc, Entity_Id gnat_pool,
769                              Node_Id gnat_node, bool);
770
771 /* Fill in a VMS descriptor for EXPR and return a constructor for it.
772    GNAT_FORMAL is how we find the descriptor record.  */
773
774 extern tree fill_vms_descriptor (tree expr, Entity_Id gnat_formal);
775
776 /* Indicate that we need to make the address of EXPR_NODE and it therefore
777    should not be allocated in a register.  Return true if successful.  */
778 extern bool gnat_mark_addressable (tree expr_node);
779
780 /* Implementation of the builtin_function langhook.  */
781 extern tree gnat_builtin_function (tree decl);
782
783 /* Search the chain of currently reachable declarations for a builtin
784    FUNCTION_DECL node corresponding to function NAME (an IDENTIFIER_NODE).
785    Return the first node found, if any, or NULL_TREE otherwise.  */
786 extern tree builtin_decl_for (tree name ATTRIBUTE_UNUSED);
787
788 /* This function is called by the front end to enumerate all the supported
789    modes for the machine.  We pass a function which is called back with
790    the following integer parameters:
791
792    FLOAT_P      nonzero if this represents a floating-point mode
793    COMPLEX_P    nonzero is this represents a complex mode
794    COUNT        count of number of items, nonzero for vector mode
795    PRECISION    number of bits in data representation
796    MANTISSA     number of bits in mantissa, if FP and known, else zero.
797    SIZE         number of bits used to store data
798    ALIGN        number of bits to which mode is aligned.  */
799 extern void enumerate_modes (void (*f) (int, int, int, int, int, int,
800                                         unsigned int));
801
802 /* These are temporary function to deal with recent GCC changes related to
803    FP type sizes and precisions.  */
804 extern int fp_prec_to_size (int prec);
805 extern int fp_size_to_prec (int size);
806
807 /* These functions return the basic data type sizes and related parameters
808    about the target machine.  */
809
810 extern Pos get_target_bits_per_unit (void);
811 extern Pos get_target_bits_per_word (void);
812 extern Pos get_target_char_size (void);
813 extern Pos get_target_wchar_t_size (void);
814 extern Pos get_target_short_size (void);
815 extern Pos get_target_int_size (void);
816 extern Pos get_target_long_size (void);
817 extern Pos get_target_long_long_size (void);
818 extern Pos get_target_float_size (void);
819 extern Pos get_target_double_size (void);
820 extern Pos get_target_long_double_size (void);
821 extern Pos get_target_pointer_size (void);
822 extern Pos get_target_maximum_alignment (void);
823 extern Nat get_float_words_be (void);
824 extern Nat get_words_be (void);
825 extern Nat get_bytes_be (void);
826 extern Nat get_bits_be (void);
827 extern Nat get_strict_alignment (void);