OSDN Git Service

2007-03-01 Paul Brook <paul@codesourcery.com>
[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 /* Return a type the same as TYPE except unsigned or signed according to
458    UNSIGNEDP.  */
459 extern tree gnat_signed_or_unsigned_type (int unsignedp, tree type);
460
461 /* Create an expression whose value is that of EXPR,
462    converted to type TYPE.  The TREE_TYPE of the value
463    is always TYPE.  This function implements all reasonable
464    conversions; callers should filter out those that are
465    not permitted by the language being compiled.  */
466 extern tree convert (tree type, tree expr);
467
468 /* Routines created solely for the tree translator's sake. Their prototypes
469    can be changed as desired.  */
470
471 /* GNAT_ENTITY is a GNAT tree node for a defining identifier.
472    GNU_DECL is the GCC tree which is to be associated with
473    GNAT_ENTITY. Such gnu tree node is always an ..._DECL node.
474    If NO_CHECK is nonzero, the latter check is suppressed.
475    If GNU_DECL is zero, a previous association is to be reset.  */
476 extern void save_gnu_tree (Entity_Id gnat_entity, tree gnu_decl,
477                            bool no_check);
478
479 /* GNAT_ENTITY is a GNAT tree node for a defining identifier.
480    Return the ..._DECL node that was associated with it.  If there is no tree
481    node associated with GNAT_ENTITY, abort.  */
482 extern tree get_gnu_tree (Entity_Id gnat_entity);
483
484 /* Return nonzero if a GCC tree has been associated with GNAT_ENTITY.  */
485 extern bool present_gnu_tree (Entity_Id gnat_entity);
486
487 /* Initialize tables for above routines.  */
488 extern void init_gnat_to_gnu (void);
489
490 /* Given a record type (RECORD_TYPE) and a chain of FIELD_DECL
491    nodes (FIELDLIST), finish constructing the record or union type.
492    If HAS_REP is true, this record has a rep clause; don't call
493    layout_type but merely set the size and alignment ourselves.
494    If DEFER_DEBUG is true, do not call the debugging routines
495    on this type; it will be done later. */
496 extern void finish_record_type (tree record_type, tree fieldlist,
497                                 bool has_rep, bool defer_debug);
498
499 /*  Output the debug information associated to a record type.  */
500 extern void write_record_type_debug_info (tree);
501
502 /* Returns a FUNCTION_TYPE node. RETURN_TYPE is the type returned by the
503    subprogram. If it is void_type_node, then we are dealing with a procedure,
504    otherwise we are dealing with a function. PARAM_DECL_LIST is a list of
505    PARM_DECL nodes that are the subprogram arguments.  CICO_LIST is the
506    copy-in/copy-out list to be stored into TYPE_CI_CO_LIST.
507    RETURNS_UNCONSTRAINED is true if the function returns an unconstrained
508    object.  RETURNS_BY_REF is true if the function returns by reference.
509    RETURNS_WITH_DSP is true if the function is to return with a
510    depressed stack pointer.  RETURNS_BY_TARGET_PTR is true if the function
511    is to be passed (as its first parameter) the address of the place to copy
512    its result.  */
513 extern tree create_subprog_type (tree return_type, tree param_decl_list,
514                                  tree cico_list, bool returns_unconstrained,
515                                  bool returns_by_ref, bool returns_with_dsp,
516                                  bool returns_by_target_ptr);
517
518 /* Return a copy of TYPE, but safe to modify in any way.  */
519 extern tree copy_type (tree type);
520
521 /* Return an INTEGER_TYPE of SIZETYPE with range MIN to MAX and whose
522    TYPE_INDEX_TYPE is INDEX.  */
523 extern tree create_index_type (tree min, tree max, tree index);
524
525 /* Return a TYPE_DECL node. TYPE_NAME gives the name of the type (a character
526    string) and TYPE is a ..._TYPE node giving its data type.
527    ARTIFICIAL_P is true if this is a declaration that was generated
528    by the compiler.  DEBUG_INFO_P is true if we need to write debugging
529    information about this type.  GNAT_NODE is used for the position of
530    the decl.  */
531 extern tree create_type_decl (tree type_name, tree type,
532                               struct attrib *attr_list,
533                               bool artificial_p, bool debug_info_p,
534                               Node_Id gnat_node);
535
536 /* Returns a GCC VAR_DECL or CONST_DECL node.
537
538    VAR_NAME gives the name of the variable.  ASM_NAME is its assembler name
539    (if provided).  TYPE is its data type (a GCC ..._TYPE node).  VAR_INIT is
540    the GCC tree for an optional initial expression; NULL_TREE if none.
541
542    CONST_FLAG is true if this variable is constant.
543
544    PUBLIC_FLAG is true if this definition is to be made visible outside of
545    the current compilation unit. This flag should be set when processing the
546    variable definitions in a package specification.  EXTERN_FLAG is nonzero
547    when processing an external variable declaration (as opposed to a
548    definition: no storage is to be allocated for the variable here).
549
550    STATIC_FLAG is only relevant when not at top level.  In that case
551    it indicates whether to always allocate storage to the variable.
552
553    GNAT_NODE is used for the position of the decl.  */
554 extern tree create_var_decl (tree var_name, tree asm_name, tree type,
555                              tree var_init, bool const_flag,
556                              bool public_flag, bool extern_flag,
557                              bool static_flag,
558                              struct attrib *attr_list, Node_Id gnat_node);
559
560 /* Similar to create_var_decl, forcing the creation of a VAR_DECL node.  */
561 extern tree create_true_var_decl (tree var_name, tree asm_name, tree type,
562                                   tree var_init, bool const_flag,
563                                   bool public_flag, bool extern_flag,
564                                   bool static_flag,
565                                   struct attrib *attr_list, Node_Id gnat_node);
566
567 /* Given a DECL and ATTR_LIST, apply the listed attributes.  */
568 extern void process_attributes (tree decl, struct attrib *attr_list);
569
570 /* Record a global renaming pointer.  */
571 void record_global_renaming_pointer (tree);
572
573 /* Invalidate the global renaming pointers.   */
574 void invalidate_global_renaming_pointers (void);
575
576 /* Returns a FIELD_DECL node. FIELD_NAME the field name, FIELD_TYPE is its
577    type, and RECORD_TYPE is the type of the parent.  PACKED is nonzero if
578    this field is in a record type with a "pragma pack".  If SIZE is nonzero
579    it is the specified size for this field.  If POS is nonzero, it is the bit
580    position.  If ADDRESSABLE is nonzero, it means we are allowed to take
581    the address of this field for aliasing purposes.  */
582 extern tree create_field_decl (tree field_name, tree field_type,
583                                tree record_type, int packed, tree size,
584                                tree pos, int addressable);
585
586 /* Returns a PARM_DECL node. PARAM_NAME is the name of the parameter,
587    PARAM_TYPE is its type.  READONLY is true if the parameter is
588    readonly (either an IN parameter or an address of a pass-by-ref
589    parameter). */
590 extern tree create_param_decl (tree param_name, tree param_type,
591                                bool readonly);
592
593 /* Returns a FUNCTION_DECL node.  SUBPROG_NAME is the name of the subprogram,
594    ASM_NAME is its assembler name, SUBPROG_TYPE is its type (a FUNCTION_TYPE
595    node), PARAM_DECL_LIST is the list of the subprogram arguments (a list of
596    PARM_DECL nodes chained through the TREE_CHAIN field).
597
598    INLINE_FLAG, PUBLIC_FLAG, EXTERN_FLAG, and ATTR_LIST are used to set the
599    appropriate fields in the FUNCTION_DECL.  GNAT_NODE gives the location.  */
600 extern tree create_subprog_decl (tree subprog_name, tree asm_name,
601                                  tree subprog_type, tree param_decl_list,
602                                  bool inlinee_flag, bool public_flag,
603                                  bool extern_flag,
604                                  struct attrib *attr_list, Node_Id gnat_node);
605
606 /* Returns a LABEL_DECL node for LABEL_NAME.  */
607 extern tree create_label_decl (tree label_name);
608
609 /* Set up the framework for generating code for SUBPROG_DECL, a subprogram
610    body. This routine needs to be invoked before processing the declarations
611    appearing in the subprogram.  */
612 extern void begin_subprog_body (tree subprog_decl);
613
614 /* Finish the definition of the current subprogram and compile it all the way
615    to assembler language output.  BODY is the tree corresponding to
616    the subprogram.  */
617 extern void end_subprog_body (tree body);
618
619 /* Build a template of type TEMPLATE_TYPE from the array bounds of ARRAY_TYPE.
620    EXPR is an expression that we can use to locate any PLACEHOLDER_EXPRs.
621    Return a constructor for the template.  */
622 extern tree build_template (tree template_type, tree array_type, tree expr);
623
624 /* Build a VMS descriptor from a Mechanism_Type, which must specify
625    a descriptor type, and the GCC type of an object.  Each FIELD_DECL
626    in the type contains in its DECL_INITIAL the expression to use when
627    a constructor is made for the type.  GNAT_ENTITY is a gnat node used
628    to print out an error message if the mechanism cannot be applied to
629    an object of that type and also for the name.  */
630
631 extern tree build_vms_descriptor (tree type, Mechanism_Type mech,
632                                   Entity_Id gnat_entity);
633
634 /* Build a type to be used to represent an aliased object whose nominal
635    type is an unconstrained array.  This consists of a RECORD_TYPE containing
636    a field of TEMPLATE_TYPE and a field of OBJECT_TYPE, which is an
637    ARRAY_TYPE.  If ARRAY_TYPE is that of the unconstrained array, this
638    is used to represent an arbitrary unconstrained object.  Use NAME
639    as the name of the record.  */
640 extern tree build_unc_object_type (tree template_type, tree object_type,
641                                    tree name);
642
643 /* Same as build_unc_object_type, but taking a thin or fat pointer type
644    instead of the template type. */
645 extern tree build_unc_object_type_from_ptr (tree thin_fat_ptr_type,
646                                             tree object_type, tree name);
647
648 /* Update anything previously pointing to OLD_TYPE to point to NEW_TYPE.  In
649    the normal case this is just two adjustments, but we have more to do
650    if NEW is an UNCONSTRAINED_ARRAY_TYPE.  */
651 extern void update_pointer_to (tree old_type, tree new_type);
652
653 /* EXP is an expression for the size of an object.  If this size contains
654    discriminant references, replace them with the maximum (if MAX_P) or
655    minimum (if !MAX_P) possible value of the discriminant.  */
656 extern tree max_size (tree exp, bool max_p);
657
658 /* Remove all conversions that are done in EXP.  This includes converting
659    from a padded type or to a left-justified modular type.  If TRUE_ADDRESS
660    is true, always return the address of the containing object even if
661    the address is not bit-aligned.  */
662 extern tree remove_conversions (tree exp, bool true_address);
663
664 /* If EXP's type is an UNCONSTRAINED_ARRAY_TYPE, return an expression that
665    refers to the underlying array.  If its type has TYPE_CONTAINS_TEMPLATE_P,
666    likewise return an expression pointing to the underlying array.  */
667 extern tree maybe_unconstrained_array (tree exp);
668
669 /* Return an expression that does an unchecked conversion of EXPR to TYPE.
670    If NOTRUNC_P is true, truncation operations should be suppressed.  */
671 extern tree unchecked_convert (tree type, tree expr, bool notrunc_p);
672
673 /* Return the appropriate GCC tree code for the specified GNAT type,
674    the latter being a record type as predicated by Is_Record_Type.  */
675 extern enum tree_code tree_code_for_record_type (Entity_Id);
676
677 /* Prepare expr to be an argument of a TRUTH_NOT_EXPR or other logical
678    operation.
679
680    This preparation consists of taking the ordinary
681    representation of an expression EXPR and producing a valid tree
682    boolean expression describing whether EXPR is nonzero.  We could
683    simply always do build_binary_op (NE_EXPR, expr, integer_zero_node, 1),
684    but we optimize comparisons, &&, ||, and !.
685
686    The resulting type should always be the same as the input type.
687    This function is simpler than the corresponding C version since
688    the only possible operands will be things of Boolean type.  */
689 extern tree gnat_truthvalue_conversion (tree expr);
690
691 /* Return the base type of TYPE.  */
692 extern tree get_base_type (tree type);
693
694 /* EXP is a GCC tree representing an address.  See if we can find how
695    strictly the object at that address is aligned.   Return that alignment
696    strictly the object at that address is aligned.   Return that alignment
697    in bits.  If we don't know anything about the alignment, return 0.  */
698 extern unsigned int known_alignment (tree exp);
699
700 /* Return true if VALUE is a multiple of FACTOR. FACTOR must be a power
701    of 2. */
702 extern bool value_factor_p (tree value, HOST_WIDE_INT factor);
703
704 /* Make a binary operation of kind OP_CODE.  RESULT_TYPE is the type
705    desired for the result.  Usually the operation is to be performed
706    in that type.  For MODIFY_EXPR and ARRAY_REF, RESULT_TYPE may be 0
707    in which case the type to be used will be derived from the operands.  */
708 extern tree build_binary_op (enum tree_code op_code, tree retult_type,
709                              tree left_operand, tree right_operand);
710
711 /* Similar, but make unary operation.   */
712 extern tree build_unary_op (enum tree_code op_code, tree result_type,
713                             tree operand);
714
715 /* Similar, but for COND_EXPR.  */
716 extern tree build_cond_expr (tree result_type, tree condition_operand,
717                              tree true_operand, tree false_operand);
718
719 /* Similar, but for RETURN_EXPR.  */
720 extern tree build_return_expr (tree result_decl, tree ret_val);
721
722 /* Build a CALL_EXPR to call FUNDECL with one argument, ARG.  Return
723    the CALL_EXPR.  */
724 extern tree build_call_1_expr (tree fundecl, tree arg);
725
726 /* Build a CALL_EXPR to call FUNDECL with two argument, ARG1 & ARG2.  Return
727    the CALL_EXPR.  */
728 extern tree build_call_2_expr (tree fundecl, tree arg1, tree arg2);
729
730 /* Likewise to call FUNDECL with no arguments.  */
731 extern tree build_call_0_expr (tree fundecl);
732
733 /* Call a function that raises an exception and pass the line number and file
734    name, if requested.  MSG says which exception function to call.
735
736    GNAT_NODE is the gnat node conveying the source location for which the
737    error should be signaled, or Empty in which case the error is signaled on
738    the current ref_file_name/input_line.  */
739 extern tree build_call_raise (int msg, Node_Id gnat_node);
740
741 /* Return a CONSTRUCTOR of TYPE whose list is LIST.  This is not the
742    same as build_constructor in the language-independent tree.c.  */
743 extern tree gnat_build_constructor (tree type, tree list);
744
745 /* Return a COMPONENT_REF to access a field that is given by COMPONENT,
746    an IDENTIFIER_NODE giving the name of the field, FIELD, a FIELD_DECL,
747    for the field, or both.  Don't fold the result if NO_FOLD_P.  */
748 extern tree build_component_ref (tree record_variable, tree component,
749                                  tree field, bool no_fold_p);
750
751 /* Build a GCC tree to call an allocation or deallocation function.
752    If GNU_OBJ is nonzero, it is an object to deallocate.  Otherwise,
753    genrate an allocator.
754
755    GNU_SIZE is the size of the object and ALIGN is the alignment.
756    GNAT_PROC, if present is a procedure to call and GNAT_POOL is the
757    storage pool to use.  If not preset, malloc and free will be used.  */
758 extern tree build_call_alloc_dealloc (tree gnu_obj, tree gnu_size,
759                                       unsigned align, Entity_Id gnat_proc,
760                                       Entity_Id gnat_pool, Node_Id gnat_node);
761
762 /* Build a GCC tree to correspond to allocating an object of TYPE whose
763    initial value if INIT, if INIT is nonzero.  Convert the expression to
764    RESULT_TYPE, which must be some type of pointer.  Return the tree.
765    GNAT_PROC and GNAT_POOL optionally give the procedure to call and
766    the storage pool to use.  GNAT_NODE is used to provide an error
767    location for restriction violations messages.  If IGNORE_INIT_TYPE is
768    true, ignore the type of INIT for the purpose of determining the size;
769    this will cause the maximum size to be allocated if TYPE is of
770    self-referential size.  */
771 extern tree build_allocator (tree type, tree init, tree result_type,
772                              Entity_Id gnat_proc, Entity_Id gnat_pool,
773                              Node_Id gnat_node, bool);
774
775 /* Fill in a VMS descriptor for EXPR and return a constructor for it.
776    GNAT_FORMAL is how we find the descriptor record.  */
777
778 extern tree fill_vms_descriptor (tree expr, Entity_Id gnat_formal);
779
780 /* Indicate that we need to make the address of EXPR_NODE and it therefore
781    should not be allocated in a register.  Return true if successful.  */
782 extern bool gnat_mark_addressable (tree expr_node);
783
784 /* Implementation of the builtin_function langhook.  */
785 extern tree gnat_builtin_function (tree decl);
786
787 /* Search the chain of currently reachable declarations for a builtin
788    FUNCTION_DECL node corresponding to function NAME (an IDENTIFIER_NODE).
789    Return the first node found, if any, or NULL_TREE otherwise.  */
790 extern tree builtin_decl_for (tree name ATTRIBUTE_UNUSED);
791
792 /* This function is called by the front end to enumerate all the supported
793    modes for the machine.  We pass a function which is called back with
794    the following integer parameters:
795
796    FLOAT_P      nonzero if this represents a floating-point mode
797    COMPLEX_P    nonzero is this represents a complex mode
798    COUNT        count of number of items, nonzero for vector mode
799    PRECISION    number of bits in data representation
800    MANTISSA     number of bits in mantissa, if FP and known, else zero.
801    SIZE         number of bits used to store data
802    ALIGN        number of bits to which mode is aligned.  */
803 extern void enumerate_modes (void (*f) (int, int, int, int, int, int,
804                                         unsigned int));
805
806 /* These are temporary function to deal with recent GCC changes related to
807    FP type sizes and precisions.  */
808 extern int fp_prec_to_size (int prec);
809 extern int fp_size_to_prec (int size);
810
811 /* These functions return the basic data type sizes and related parameters
812    about the target machine.  */
813
814 extern Pos get_target_bits_per_unit (void);
815 extern Pos get_target_bits_per_word (void);
816 extern Pos get_target_char_size (void);
817 extern Pos get_target_wchar_t_size (void);
818 extern Pos get_target_short_size (void);
819 extern Pos get_target_int_size (void);
820 extern Pos get_target_long_size (void);
821 extern Pos get_target_long_long_size (void);
822 extern Pos get_target_float_size (void);
823 extern Pos get_target_double_size (void);
824 extern Pos get_target_long_double_size (void);
825 extern Pos get_target_pointer_size (void);
826 extern Pos get_target_maximum_alignment (void);
827 extern Nat get_float_words_be (void);
828 extern Nat get_words_be (void);
829 extern Nat get_bytes_be (void);
830 extern Nat get_bits_be (void);
831 extern Nat get_strict_alignment (void);