OSDN Git Service

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