* defaults.h (FRAME_GROWS_DOWNWARD): Define to 0 if not defined.
[official-gcc.git] / gcc / ada / gigi.h
blobfe2f1103aa0c3858fdd77da0b8f9f668ce935033
1 /****************************************************************************
2 * *
3 * GNAT COMPILER COMPONENTS *
4 * *
5 * G I G I *
6 * *
7 * C Header File *
8 * *
9 * Copyright (C) 1992-2005 Free Software Foundation, Inc. *
10 * *
11 * GNAT is free software; you can redistribute it and/or modify it under *
12 * terms of the GNU General Public License as published by the Free Soft- *
13 * ware Foundation; either version 2, or (at your option) any later ver- *
14 * sion. GNAT is distributed in the hope that it will be useful, but WITH- *
15 * OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
16 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
17 * for more details. You should have received a copy of the GNU General *
18 * Public License distributed with GNAT; see file COPYING. If not, write *
19 * to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, *
20 * MA 02111-1307, USA. *
21 * *
22 * As a special exception, if you link this file with other files to *
23 * produce an executable, this file does not by itself cause the resulting *
24 * executable to be covered by the GNU General Public License. This except- *
25 * ion does not however invalidate any other reasons why the executable *
26 * file might be covered by the GNU Public License. *
27 * *
28 * GNAT was originally developed by the GNAT team at New York University. *
29 * Extensive contributions were provided by Ada Core Technologies Inc. *
30 * *
31 ****************************************************************************/
33 /* Declare all functions and types used by gigi. */
35 /* The largest alignment, in bits, that is needed for using the widest
36 move instruction. */
37 extern unsigned int largest_move_alignment;
39 /* Compute the alignment of the largest mode that can be used for copying
40 objects. */
41 extern void gnat_compute_largest_alignment (void);
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);
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);
51 /* Initialize DUMMY_NODE_TABLE. */
52 extern void init_dummy_type (void);
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.
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.
63 DEFINITION is nonzero if this call is intended for a definition. This is
64 used for separate compilation where it necessary to know whether an
65 external declaration or a definition should be created if the GCC equivalent
66 was not created previously. The value of 1 is normally used for a non-zero
67 DEFINITION, but a value of 2 is used in special circumstances, defined in
68 the code. */
69 extern tree gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr,
70 int definition);
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);
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);
81 /* Add GNU_STMT to the current BLOCK_STMT node. */
82 extern void add_stmt (tree gnu_stmt);
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);
87 /* Set the BLOCK node corresponding to the current code group to GNU_BLOCK. */
88 extern void set_block_for_group (tree);
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);
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);
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);
102 /* Make a dummy type corresponding to GNAT_TYPE. */
103 extern tree make_dummy_type (Entity_Id gnat_type);
105 /* Get the unpadded version of a GNAT type. */
106 extern tree get_unpadded_type (Entity_Id gnat_entity);
108 /* Called when we need to protect a variable object using a save_expr. */
109 extern tree maybe_variable (tree gnu_operand);
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);
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.
118 GNAT_ENTITY and NAME_TRAILER are used to name the resulting record and
119 to issue a warning.
121 IS_USER_TYPE is true if we must be sure we complete the original type.
123 DEFINITION is true if this type is being defined.
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);
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);
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);
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);
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);
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);
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);
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;
166 /* Current file name without path */
167 extern const char *ref_filename;
169 /* This is the main program of the back-end. It sets up all the table
170 structures and then generates code.
172 ??? Needs parameter descriptions */
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);
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);
194 /* GNU_STMT is a statement. We generate code for that statement. */
195 extern void gnat_expand_stmt (tree gnu_stmt);
197 /* ??? missing documentation */
198 extern int gnat_gimplify_expr (tree *expr_p, tree *pre_p,
199 tree *post_p ATTRIBUTE_UNUSED);
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);
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);
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);
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);
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);
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);
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);
240 /* Protect EXP from multiple evaluation. This may make a SAVE_EXPR. */
241 extern tree protect_multiple_eval (tree exp);
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);
247 /* Current node being treated, in case gigi_abort or Check_Elaboration_Code
248 called. */
249 extern Node_Id error_gnat_node;
251 /* This is equivalent to stabilize_reference in GCC's tree.c, but we know
252 how to handle our new nodes and we take an extra argument that says
253 whether to force evaluation of everything. */
254 extern tree gnat_stabilize_reference (tree ref, bool force);
256 /* Highest number in the front-end node table. */
257 extern int max_gnat_nodes;
259 /* If nonzero, pretend we are allocating at global level. */
260 extern int force_global;
262 /* Standard data type sizes. Most of these are not used. */
264 #ifndef CHAR_TYPE_SIZE
265 #define CHAR_TYPE_SIZE BITS_PER_UNIT
266 #endif
268 #ifndef SHORT_TYPE_SIZE
269 #define SHORT_TYPE_SIZE (BITS_PER_UNIT * MIN ((UNITS_PER_WORD + 1) / 2, 2))
270 #endif
272 #ifndef INT_TYPE_SIZE
273 #define INT_TYPE_SIZE BITS_PER_WORD
274 #endif
276 #ifndef LONG_TYPE_SIZE
277 #define LONG_TYPE_SIZE BITS_PER_WORD
278 #endif
280 #ifndef LONG_LONG_TYPE_SIZE
281 #define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2)
282 #endif
284 #ifndef FLOAT_TYPE_SIZE
285 #define FLOAT_TYPE_SIZE BITS_PER_WORD
286 #endif
288 #ifndef DOUBLE_TYPE_SIZE
289 #define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
290 #endif
292 #ifndef LONG_DOUBLE_TYPE_SIZE
293 #define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
294 #endif
296 /* The choice of SIZE_TYPE here is very problematic. We need a signed
297 type whose bit width is Pmode. Assume "long" is such a type here. */
298 #undef SIZE_TYPE
299 #define SIZE_TYPE "long int"
302 /* Data structures used to represent attributes. */
304 enum attr_type {ATTR_MACHINE_ATTRIBUTE, ATTR_LINK_ALIAS,
305 ATTR_LINK_SECTION, ATTR_WEAK_EXTERNAL};
307 struct attrib
309 struct attrib *next;
310 enum attr_type type;
311 tree name;
312 tree args;
313 Node_Id error_point;
316 /* Define the entries in the standard data array. */
317 enum standard_datatypes
319 /* Various standard data types and nodes. */
320 ADT_longest_float_type,
321 ADT_void_type_decl,
323 /* The type of an exception. */
324 ADT_except_type,
326 /* Type declaration node <==> typedef void *T */
327 ADT_ptr_void_type,
329 /* Function type declaration -- void T() */
330 ADT_void_ftype,
332 /* Type declaration node <==> typedef void *T() */
333 ADT_ptr_void_ftype,
335 /* A function declaration node for a run-time function for allocating memory.
336 Ada allocators cause calls to this function to be generated. */
337 ADT_malloc_decl,
339 /* Likewise for freeing memory. */
340 ADT_free_decl,
342 /* Types and decls used by our temporary exception mechanism. See
343 init_gigi_decls for details. */
344 ADT_jmpbuf_type,
345 ADT_jmpbuf_ptr_type,
346 ADT_get_jmpbuf_decl,
347 ADT_set_jmpbuf_decl,
348 ADT_get_excptr_decl,
349 ADT_setjmp_decl,
350 ADT_longjmp_decl,
351 ADT_update_setjmp_buf_decl,
352 ADT_raise_nodefer_decl,
353 ADT_begin_handler_decl,
354 ADT_end_handler_decl,
355 ADT_others_decl,
356 ADT_all_others_decl,
357 ADT_LAST};
359 extern GTY(()) tree gnat_std_decls[(int) ADT_LAST];
360 extern GTY(()) tree gnat_raise_decls[(int) LAST_REASON_CODE + 1];
362 #define longest_float_type_node gnat_std_decls[(int) ADT_longest_float_type]
363 #define void_type_decl_node gnat_std_decls[(int) ADT_void_type_decl]
364 #define except_type_node gnat_std_decls[(int) ADT_except_type]
365 #define ptr_void_type_node gnat_std_decls[(int) ADT_ptr_void_type]
366 #define void_ftype gnat_std_decls[(int) ADT_void_ftype]
367 #define ptr_void_ftype gnat_std_decls[(int) ADT_ptr_void_ftype]
368 #define malloc_decl gnat_std_decls[(int) ADT_malloc_decl]
369 #define free_decl gnat_std_decls[(int) ADT_free_decl]
370 #define jmpbuf_type gnat_std_decls[(int) ADT_jmpbuf_type]
371 #define jmpbuf_ptr_type gnat_std_decls[(int) ADT_jmpbuf_ptr_type]
372 #define get_jmpbuf_decl gnat_std_decls[(int) ADT_get_jmpbuf_decl]
373 #define set_jmpbuf_decl gnat_std_decls[(int) ADT_set_jmpbuf_decl]
374 #define get_excptr_decl gnat_std_decls[(int) ADT_get_excptr_decl]
375 #define setjmp_decl gnat_std_decls[(int) ADT_setjmp_decl]
376 #define longjmp_decl gnat_std_decls[(int) ADT_longjmp_decl]
377 #define update_setjmp_buf_decl gnat_std_decls[(int) ADT_update_setjmp_buf_decl]
378 #define raise_nodefer_decl gnat_std_decls[(int) ADT_raise_nodefer_decl]
379 #define begin_handler_decl gnat_std_decls[(int) ADT_begin_handler_decl]
380 #define others_decl gnat_std_decls[(int) ADT_others_decl]
381 #define all_others_decl gnat_std_decls[(int) ADT_all_others_decl]
382 #define end_handler_decl gnat_std_decls[(int) ADT_end_handler_decl]
384 /* Routines expected by the gcc back-end. They must have exactly the same
385 prototype and names as below. */
387 /* Returns non-zero if we are currently in the global binding level */
388 extern int global_bindings_p (void);
390 /* Enter and exit a new binding level. */
391 extern void gnat_pushlevel (void);
392 extern void gnat_poplevel (void);
394 /* Set SUPERCONTEXT of the BLOCK for the current binding level to FNDECL
395 and point FNDECL to this BLOCK. */
396 extern void set_current_block_context (tree fndecl);
398 /* Set the jmpbuf_decl for the current binding level to DECL. */
399 extern void set_block_jmpbuf_decl (tree decl);
401 /* Get the setjmp_decl, if any, for the current binding level. */
402 extern tree get_block_jmpbuf_decl (void);
404 /* Insert BLOCK at the end of the list of subblocks of the
405 current binding level. This is used when a BIND_EXPR is expanded,
406 to handle the BLOCK node inside the BIND_EXPR. */
407 extern void insert_block (tree block);
409 /* Records a ..._DECL node DECL as belonging to the current lexical scope
410 and uses GNAT_NODE for location information. */
411 extern void gnat_pushdecl (tree decl, Node_Id gnat_node);
413 extern void gnat_init_stmt_group (void);
414 extern void gnat_init_decl_processing (void);
415 extern void init_gigi_decls (tree long_long_float_type, tree exception_type);
416 extern void gnat_init_gcc_eh (void);
418 /* Return an integer type with the number of bits of precision given by
419 PRECISION. UNSIGNEDP is nonzero if the type is unsigned; otherwise
420 it is a signed type. */
421 extern tree gnat_type_for_size (unsigned precision, int unsignedp);
423 /* Return a data type that has machine mode MODE. UNSIGNEDP selects
424 an unsigned type; otherwise a signed type is returned. */
425 extern tree gnat_type_for_mode (enum machine_mode mode, int unsignedp);
427 /* Return the unsigned version of a TYPE_NODE, a scalar type. */
428 extern tree gnat_unsigned_type (tree type_node);
430 /* Return the signed version of a TYPE_NODE, a scalar type. */
431 extern tree gnat_signed_type (tree type_node);
433 /* Return a type the same as TYPE except unsigned or signed according to
434 UNSIGNEDP. */
435 extern tree gnat_signed_or_unsigned_type (int unsignedp, tree type);
437 /* Create an expression whose value is that of EXPR,
438 converted to type TYPE. The TREE_TYPE of the value
439 is always TYPE. This function implements all reasonable
440 conversions; callers should filter out those that are
441 not permitted by the language being compiled. */
442 extern tree convert (tree type, tree expr);
444 /* Routines created solely for the tree translator's sake. Their prototypes
445 can be changed as desired. */
447 /* GNAT_ENTITY is a GNAT tree node for a defining identifier.
448 GNU_DECL is the GCC tree which is to be associated with
449 GNAT_ENTITY. Such gnu tree node is always an ..._DECL node.
450 If NO_CHECK is nonzero, the latter check is suppressed.
451 If GNU_DECL is zero, a previous association is to be reset. */
452 extern void save_gnu_tree (Entity_Id gnat_entity, tree gnu_decl,
453 bool no_check);
455 /* GNAT_ENTITY is a GNAT tree node for a defining identifier.
456 Return the ..._DECL node that was associated with it. If there is no tree
457 node associated with GNAT_ENTITY, abort. */
458 extern tree get_gnu_tree (Entity_Id gnat_entity);
460 /* Return nonzero if a GCC tree has been associated with GNAT_ENTITY. */
461 extern bool present_gnu_tree (Entity_Id gnat_entity);
463 /* Initialize tables for above routines. */
464 extern void init_gnat_to_gnu (void);
466 /* Given a record type (RECORD_TYPE) and a chain of FIELD_DECL
467 nodes (FIELDLIST), finish constructing the record or union type.
468 If HAS_REP is true, this record has a rep clause; don't call
469 layout_type but merely set the size and alignment ourselves.
470 If DEFER_DEBUG is true, do not call the debugging routines
471 on this type; it will be done later. */
472 extern void finish_record_type (tree record_type, tree fieldlist,
473 bool has_rep, bool defer_debug);
475 /* Output the debug information associated to a record type. */
476 extern void write_record_type_debug_info (tree);
478 /* Returns a FUNCTION_TYPE node. RETURN_TYPE is the type returned by the
479 subprogram. If it is void_type_node, then we are dealing with a procedure,
480 otherwise we are dealing with a function. PARAM_DECL_LIST is a list of
481 PARM_DECL nodes that are the subprogram arguments. CICO_LIST is the
482 copy-in/copy-out list to be stored into TYPE_CI_CO_LIST.
483 RETURNS_UNCONSTRAINED is true if the function returns an unconstrained
484 object. RETURNS_BY_REF is true if the function returns by reference.
485 RETURNS_WITH_DSP is true if the function is to return with a
486 depressed stack pointer. RETURNS_BY_TARGET_PTR is true if the function
487 is to be passed (as its first parameter) the address of the place to copy
488 its result. */
489 extern tree create_subprog_type (tree return_type, tree param_decl_list,
490 tree cico_list, bool returns_unconstrained,
491 bool returns_by_ref, bool returns_with_dsp,
492 bool returns_by_target_ptr);
494 /* Return a copy of TYPE, but safe to modify in any way. */
495 extern tree copy_type (tree type);
497 /* Return an INTEGER_TYPE of SIZETYPE with range MIN to MAX and whose
498 TYPE_INDEX_TYPE is INDEX. */
499 extern tree create_index_type (tree min, tree max, tree index);
501 /* Return a TYPE_DECL node. TYPE_NAME gives the name of the type (a character
502 string) and TYPE is a ..._TYPE node giving its data type.
503 ARTIFICIAL_P is true if this is a declaration that was generated
504 by the compiler. DEBUG_INFO_P is true if we need to write debugging
505 information about this type. GNAT_NODE is used for the position of
506 the decl. */
507 extern tree create_type_decl (tree type_name, tree type,
508 struct attrib *attr_list,
509 bool artificial_p, bool debug_info_p,
510 Node_Id gnat_node);
512 /* Returns a GCC VAR_DECL node. VAR_NAME gives the name of the variable.
513 ASM_NAME is its assembler name (if provided). TYPE is
514 its data type (a GCC ..._TYPE node). VAR_INIT is the GCC tree for an
515 optional initial expression; NULL_TREE if none.
517 CONST_FLAG is true if this variable is constant.
519 PUBLIC_FLAG is true if this definition is to be made visible outside of
520 the current compilation unit. This flag should be set when processing the
521 variable definitions in a package specification. EXTERN_FLAG is nonzero
522 when processing an external variable declaration (as opposed to a
523 definition: no storage is to be allocated for the variable here).
525 STATIC_FLAG is only relevant when not at top level. In that case
526 it indicates whether to always allocate storage to the variable.
528 GNAT_NODE is used for the position of the decl. */
529 extern tree create_var_decl (tree var_name, tree asm_name, tree type,
530 tree var_init, bool const_flag,
531 bool public_flag, bool extern_flag,
532 bool static_flag,
533 struct attrib *attr_list, Node_Id gnat_node);
535 /* Given a DECL and ATTR_LIST, apply the listed attributes. */
536 extern void process_attributes (tree decl, struct attrib *attr_list);
538 /* Returns a FIELD_DECL node. FIELD_NAME the field name, FIELD_TYPE is its
539 type, and RECORD_TYPE is the type of the parent. PACKED is nonzero if
540 this field is in a record type with a "pragma pack". If SIZE is nonzero
541 it is the specified size for this field. If POS is nonzero, it is the bit
542 position. If ADDRESSABLE is nonzero, it means we are allowed to take
543 the address of this field for aliasing purposes. */
544 extern tree create_field_decl (tree field_name, tree field_type,
545 tree record_type, int packed, tree size,
546 tree pos, int addressable);
548 /* Returns a PARM_DECL node. PARAM_NAME is the name of the parameter,
549 PARAM_TYPE is its type. READONLY is true if the parameter is
550 readonly (either an IN parameter or an address of a pass-by-ref
551 parameter). */
552 extern tree create_param_decl (tree param_name, tree param_type,
553 bool readonly);
555 /* Returns a FUNCTION_DECL node. SUBPROG_NAME is the name of the subprogram,
556 ASM_NAME is its assembler name, SUBPROG_TYPE is its type (a FUNCTION_TYPE
557 node), PARAM_DECL_LIST is the list of the subprogram arguments (a list of
558 PARM_DECL nodes chained through the TREE_CHAIN field).
560 INLINE_FLAG, PUBLIC_FLAG, EXTERN_FLAG, and ATTR_LIST are used to set the
561 appropriate fields in the FUNCTION_DECL. GNAT_NODE gives the location. */
562 extern tree create_subprog_decl (tree subprog_name, tree asm_name,
563 tree subprog_type, tree param_decl_list,
564 bool inlinee_flag, bool public_flag,
565 bool extern_flag,
566 struct attrib *attr_list, Node_Id gnat_node);
568 /* Returns a LABEL_DECL node for LABEL_NAME. */
569 extern tree create_label_decl (tree label_name);
571 /* Set up the framework for generating code for SUBPROG_DECL, a subprogram
572 body. This routine needs to be invoked before processing the declarations
573 appearing in the subprogram. */
574 extern void begin_subprog_body (tree subprog_decl);
576 /* Finish the definition of the current subprogram and compile it all the way
577 to assembler language output. BODY is the tree corresponding to
578 the subprogram. */
579 extern void end_subprog_body (tree body);
581 /* Build a template of type TEMPLATE_TYPE from the array bounds of ARRAY_TYPE.
582 EXPR is an expression that we can use to locate any PLACEHOLDER_EXPRs.
583 Return a constructor for the template. */
584 extern tree build_template (tree template_type, tree array_type, tree expr);
586 /* Build a VMS descriptor from a Mechanism_Type, which must specify
587 a descriptor type, and the GCC type of an object. Each FIELD_DECL
588 in the type contains in its DECL_INITIAL the expression to use when
589 a constructor is made for the type. GNAT_ENTITY is a gnat node used
590 to print out an error message if the mechanism cannot be applied to
591 an object of that type and also for the name. */
593 extern tree build_vms_descriptor (tree type, Mechanism_Type mech,
594 Entity_Id gnat_entity);
596 /* Build a type to be used to represent an aliased object whose nominal
597 type is an unconstrained array. This consists of a RECORD_TYPE containing
598 a field of TEMPLATE_TYPE and a field of OBJECT_TYPE, which is an
599 ARRAY_TYPE. If ARRAY_TYPE is that of the unconstrained array, this
600 is used to represent an arbitrary unconstrained object. Use NAME
601 as the name of the record. */
602 extern tree build_unc_object_type (tree template_type, tree object_type,
603 tree name);
605 /* Update anything previously pointing to OLD_TYPE to point to NEW_TYPE. In
606 the normal case this is just two adjustments, but we have more to do
607 if NEW is an UNCONSTRAINED_ARRAY_TYPE. */
608 extern void update_pointer_to (tree old_type, tree new_type);
610 /* EXP is an expression for the size of an object. If this size contains
611 discriminant references, replace them with the maximum (if MAX_P) or
612 minimum (if !MAX_P) possible value of the discriminant. */
613 extern tree max_size (tree exp, bool max_p);
615 /* Remove all conversions that are done in EXP. This includes converting
616 from a padded type or to a left-justified modular type. If TRUE_ADDRESS
617 is true, always return the address of the containing object even if
618 the address is not bit-aligned. */
619 extern tree remove_conversions (tree exp, bool true_address);
621 /* If EXP's type is an UNCONSTRAINED_ARRAY_TYPE, return an expression that
622 refers to the underlying array. If its type has TYPE_CONTAINS_TEMPLATE_P,
623 likewise return an expression pointing to the underlying array. */
624 extern tree maybe_unconstrained_array (tree exp);
626 /* Return an expression that does an unchecked conversion of EXPR to TYPE.
627 If NOTRUNC_P is true, truncation operations should be suppressed. */
628 extern tree unchecked_convert (tree type, tree expr, bool notrunc_p);
630 /* Prepare expr to be an argument of a TRUTH_NOT_EXPR or other logical
631 operation.
633 This preparation consists of taking the ordinary
634 representation of an expression EXPR and producing a valid tree
635 boolean expression describing whether EXPR is nonzero. We could
636 simply always do build_binary_op (NE_EXPR, expr, integer_zero_node, 1),
637 but we optimize comparisons, &&, ||, and !.
639 The resulting type should always be the same as the input type.
640 This function is simpler than the corresponding C version since
641 the only possible operands will be things of Boolean type. */
642 extern tree gnat_truthvalue_conversion (tree expr);
644 /* Return the base type of TYPE. */
645 extern tree get_base_type (tree type);
647 /* Likewise, but only return types known at Ada source. */
648 extern tree get_ada_base_type (tree type);
650 /* EXP is a GCC tree representing an address. See if we can find how
651 strictly the object at that address is aligned. Return that alignment
652 strictly the object at that address is aligned. Return that alignment
653 in bits. If we don't know anything about the alignment, return 0. */
654 extern unsigned int known_alignment (tree exp);
656 /* Make a binary operation of kind OP_CODE. RESULT_TYPE is the type
657 desired for the result. Usually the operation is to be performed
658 in that type. For MODIFY_EXPR and ARRAY_REF, RESULT_TYPE may be 0
659 in which case the type to be used will be derived from the operands. */
660 extern tree build_binary_op (enum tree_code op_code, tree retult_type,
661 tree left_operand, tree right_operand);
663 /* Similar, but make unary operation. */
664 extern tree build_unary_op (enum tree_code op_code, tree result_type,
665 tree operand);
667 /* Similar, but for COND_EXPR. */
668 extern tree build_cond_expr (tree result_type, tree condition_operand,
669 tree true_operand, tree false_operand);
671 /* Build a CALL_EXPR to call FUNDECL with one argument, ARG. Return
672 the CALL_EXPR. */
673 extern tree build_call_1_expr (tree fundecl, tree arg);
675 /* Build a CALL_EXPR to call FUNDECL with two argument, ARG1 & ARG2. Return
676 the CALL_EXPR. */
677 extern tree build_call_2_expr (tree fundecl, tree arg1, tree arg2);
679 /* Likewise to call FUNDECL with no arguments. */
680 extern tree build_call_0_expr (tree fundecl);
682 /* Call a function that raises an exception and pass the line number and file
683 name, if requested. MSG says which exception function to call. */
684 extern tree build_call_raise (int msg);
686 /* Return a CONSTRUCTOR of TYPE whose list is LIST. This is not the
687 same as build_constructor in the language-independent tree.c. */
688 extern tree gnat_build_constructor (tree type, tree list);
690 /* Return a COMPONENT_REF to access a field that is given by COMPONENT,
691 an IDENTIFIER_NODE giving the name of the field, FIELD, a FIELD_DECL,
692 for the field, or both. Don't fold the result if NO_FOLD_P. */
693 extern tree build_component_ref (tree record_variable, tree component,
694 tree field, bool no_fold_p);
696 /* Build a GCC tree to call an allocation or deallocation function.
697 If GNU_OBJ is nonzero, it is an object to deallocate. Otherwise,
698 genrate an allocator.
700 GNU_SIZE is the size of the object and ALIGN is the alignment.
701 GNAT_PROC, if present is a procedure to call and GNAT_POOL is the
702 storage pool to use. If not preset, malloc and free will be used. */
703 extern tree build_call_alloc_dealloc (tree gnu_obj, tree gnu_size,
704 unsigned align, Entity_Id gnat_proc,
705 Entity_Id gnat_pool, Node_Id gnat_node);
707 /* Build a GCC tree to correspond to allocating an object of TYPE whose
708 initial value if INIT, if INIT is nonzero. Convert the expression to
709 RESULT_TYPE, which must be some type of pointer. Return the tree.
710 GNAT_PROC and GNAT_POOL optionally give the procedure to call and
711 the storage pool to use. GNAT_NODE is used to provide an error
712 location for restriction violations messages. If IGNORE_INIT_TYPE is
713 true, ignore the type of INIT for the purpose of determining the size;
714 this will cause the maximum size to be allocated if TYPE is of
715 self-referential size. */
716 extern tree build_allocator (tree type, tree init, tree result_type,
717 Entity_Id gnat_proc, Entity_Id gnat_pool,
718 Node_Id gnat_node, bool);
720 /* Fill in a VMS descriptor for EXPR and return a constructor for it.
721 GNAT_FORMAL is how we find the descriptor record. */
723 extern tree fill_vms_descriptor (tree expr, Entity_Id gnat_formal);
725 /* Indicate that we need to make the address of EXPR_NODE and it therefore
726 should not be allocated in a register. Return true if successful. */
727 extern bool gnat_mark_addressable (tree expr_node);
729 /* Implementation of the builtin_function langhook. */
730 extern tree builtin_function (const char *name, tree type, int function_code,
731 enum built_in_class class,
732 const char *library_name, tree attrs);
734 /* Search the chain of currently reachable declarations for a builtin
735 FUNCTION_DECL node corresponding to function NAME (an IDENTIFIER_NODE).
736 Return the first node found, if any, or NULL_TREE otherwise. */
737 extern tree builtin_decl_for (tree name ATTRIBUTE_UNUSED);
739 /* This function is called by the front end to enumerate all the supported
740 modes for the machine. We pass a function which is called back with
741 the following integer parameters:
743 FLOAT_P nonzero if this represents a floating-point mode
744 COMPLEX_P nonzero is this represents a complex mode
745 COUNT count of number of items, nonzero for vector mode
746 PRECISION number of bits in data representation
747 MANTISSA number of bits in mantissa, if FP and known, else zero.
748 SIZE number of bits used to store data
749 ALIGN number of bits to which mode is aligned. */
750 extern void enumerate_modes (void (*f) (int, int, int, int, int, int,
751 unsigned int));
753 /* These are temporary function to deal with recent GCC changes related to
754 FP type sizes and precisions. */
755 extern int fp_prec_to_size (int prec);
756 extern int fp_size_to_prec (int size);
758 /* These functions return the basic data type sizes and related parameters
759 about the target machine. */
761 extern Pos get_target_bits_per_unit (void);
762 extern Pos get_target_bits_per_word (void);
763 extern Pos get_target_char_size (void);
764 extern Pos get_target_wchar_t_size (void);
765 extern Pos get_target_short_size (void);
766 extern Pos get_target_int_size (void);
767 extern Pos get_target_long_size (void);
768 extern Pos get_target_long_long_size (void);
769 extern Pos get_target_float_size (void);
770 extern Pos get_target_double_size (void);
771 extern Pos get_target_long_double_size (void);
772 extern Pos get_target_pointer_size (void);
773 extern Pos get_target_maximum_alignment (void);
774 extern Nat get_float_words_be (void);
775 extern Nat get_words_be (void);
776 extern Nat get_bytes_be (void);
777 extern Nat get_bits_be (void);
778 extern Nat get_strict_alignment (void);