diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-08-14 08:40:11 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-08-14 08:40:11 +0000 |
commit | b8d0503fc28984d30fe773b54c5b825ceb496fb7 (patch) | |
tree | e79464f26ada57355226bd2875fdb9b7d91b2633 /gcc/ada/utils.c | |
parent | fbc67f84889a4d53b9c17f6a33368ee1f6f7a0e5 (diff) | |
download | gcc-b8d0503fc28984d30fe773b54c5b825ceb496fb7.tar.gz |
2007-08-14 Olivier Hainque <hainque@adacore.com>
Eric Botcazou <ebotcazou@adacore.com>
* targtyps.c (get_target_maximum_default_alignment): New function.
Maximum alignment
that the compiler might choose by default for a type or object.
(get_target_default_allocator_alignment): New function. Alignment known
to be honored by the target default allocator.
(get_target_maximum_allowed_alignment): New function. Maximum alignment
we might accept for any type or object on the target.
(get_target_maximum_alignment): Now synonym of maximum_default_alignment
* gigi.h (get_target_maximum_default_alignment): Declare new function.
(get_target_default_allocator_alignment): Likewise.
(get_target_maximum_allowed_alignment): Likewise.
PR ada/19037
* decl.c (gnat_to_gnu_entity) <object>: Except for the renaming of the
result of a function call, first try to use a stabilized reference for
a constant renaming too.
(validate_alignment): Use target_maximum_allowed_alignment instead of
MAX_OFILE_ALIGNMENT as the upper bound to what we accept.
(gnat_to_gnu_entity): Use common nodes directly.
(gnat_to_gnu_entity) <object>: Pick the values of the type to annotate
alignment and size for the object.
(lvalue_required_p): Handle N_Parameter_Association like N_Function_Call
and N_Procedure_Call_Statement.
(takes_address): Rename to lvalue_required_p, add third parameter
'aliased' and adjust recursive calls.
<N_Indexed_Component>: Update 'aliased' from the array type.
<N_Selected_Component>: New case.
<N_Object_Renaming_Declaration>: New Likewise.
(Identifier_to_gnu): Adjust for above changes.
(maybe_stabilize_reference) <CONST_DECL>: New case.
* utils2.c (build_binary_op) <ARRAY_RANGE_REF>: Look through conversion
between type variants.
(build_simple_component_ref): Likewise.
(build_call_alloc_dealloc): Use target_default_allocator_alignment
instead of BIGGEST_ALIGNMENT as the threshold to trigger the super
aligning type circuitry for allocations from the default storage pool.
(build_allocator): Likewise.
(build_simple_component_ref): Manually fold the reference for a
constructor if the record type contains a template.
* utils.c (value_zerop): Delete.
(gnat_init_decl_processing): Emit debug info for common types.
(rest_of_record_type_compilation): If a union contains a field
with a non-constant qualifier, treat it as variable-sized.
(finish_record_type): Give the stub TYPE_DECL a name.
(rest_of_record_type_compilation): Likewise.
(convert) <CONSTRUCTOR>: New case. Build a new constructor if
types are equivalent array types.
(create_field_decl): Claim fields of any ARRAY_TYPE are addressable,
even if the type is not passed by reference.
(static_ctors, static_dtors): Delete.
(end_subprog_body): Do not record constructors and destructors.
(build_global_cdtor): Delete.
(gnat_write_global_declarations): Do not call build_global_cdtor.
* lang-specs.h: If TARGET_VXWORKS_RTP is defined, append -mrtp when
-fRTS=rtp is specified.
If CONFIG_DUAL_EXCEPTIONS is 1, append -fsjlj when -fRTS=sjlj is
specified.
* misc.c (gnat_init_gcc_eh): Use __gnat_eh_personality_sj for the name
of the personality function with SJLJ exceptions.
* raise-gcc.c (PERSONALITY_FUNCTION): Use __gnat_eh_personality_sj for
the name of the personality function with SJLJ exceptions.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@127422 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/utils.c')
-rw-r--r-- | gcc/ada/utils.c | 131 |
1 files changed, 48 insertions, 83 deletions
diff --git a/gcc/ada/utils.c b/gcc/ada/utils.c index 8a8ee7f96e0..d26395fc0f6 100644 --- a/gcc/ada/utils.c +++ b/gcc/ada/utils.c @@ -156,11 +156,6 @@ static GTY(()) VEC(tree,gc) *builtin_decls; /* An array of global renaming pointers. */ static GTY(()) VEC(tree,gc) *global_renaming_pointers; -/* Arrays of functions called automatically at the beginning and - end of execution, on targets without .ctors/.dtors sections. */ -static GTY(()) VEC(tree,gc) *static_ctors; -static GTY(()) VEC(tree,gc) *static_dtors; - /* A chain of unused BLOCK nodes. */ static GTY((deletable)) tree free_block_chain; @@ -168,7 +163,6 @@ static void gnat_install_builtins (void); static tree merge_sizes (tree, tree, tree, bool, bool); static tree compute_related_constant (tree, tree); static tree split_plus (tree, tree *); -static bool value_zerop (tree); static void gnat_gimplify_function (tree); static tree float_type_for_precision (int, enum machine_mode); static tree convert_to_fat_pointer (tree, tree); @@ -505,17 +499,14 @@ gnat_init_decl_processing (void) build_common_tree_nodes_2 (0); /* Give names and make TYPE_DECLs for common types. */ - gnat_pushdecl (build_decl (TYPE_DECL, get_identifier (SIZE_TYPE), sizetype), - Empty); - gnat_pushdecl (build_decl (TYPE_DECL, get_identifier ("integer"), - integer_type_node), - Empty); - gnat_pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned char"), - char_type_node), - Empty); - gnat_pushdecl (build_decl (TYPE_DECL, get_identifier ("long integer"), - long_integer_type_node), - Empty); + create_type_decl (get_identifier (SIZE_TYPE), sizetype, + NULL, false, true, Empty); + create_type_decl (get_identifier ("integer"), integer_type_node, + NULL, false, true, Empty); + create_type_decl (get_identifier ("unsigned char"), char_type_node, + NULL, false, true, Empty); + create_type_decl (get_identifier ("long integer"), long_integer_type_node, + NULL, false, true, Empty); ptr_void_type_node = build_pointer_type (void_type_node); @@ -778,7 +769,7 @@ finish_record_type (tree record_type, tree fieldlist, int rep_level, TYPE_FIELDS (record_type) = fieldlist; TYPE_STUB_DECL (record_type) - = build_decl (TYPE_DECL, NULL_TREE, record_type); + = build_decl (TYPE_DECL, TYPE_NAME (record_type), record_type); /* We don't need both the typedef name and the record name output in the debugging information, since they are the same. */ @@ -947,6 +938,7 @@ rest_of_record_type_compilation (tree record_type) { tree fieldlist = TYPE_FIELDS (record_type); tree field; + enum tree_code code = TREE_CODE (record_type); bool var_size = false; for (field = fieldlist; field; field = TREE_CHAIN (field)) @@ -957,7 +949,11 @@ rest_of_record_type_compilation (tree record_type) same size, in which case we'll use that size. But the debug output routines (except Dwarf2) won't be able to output the fields, so we need to make the special record. */ - if (TREE_CODE (DECL_SIZE (field)) != INTEGER_CST) + if (TREE_CODE (DECL_SIZE (field)) != INTEGER_CST + /* If a field has a non-constant qualifier, the record will have + variable size too. */ + || (code == QUAL_UNION_TYPE + && TREE_CODE (DECL_QUALIFIER (field)) != INTEGER_CST)) { var_size = true; break; @@ -991,7 +987,7 @@ rest_of_record_type_compilation (tree record_type) TYPE_NAME (new_record_type) = new_id; TYPE_ALIGN (new_record_type) = BIGGEST_ALIGNMENT; TYPE_STUB_DECL (new_record_type) - = build_decl (TYPE_DECL, NULL_TREE, new_record_type); + = build_decl (TYPE_DECL, new_id, new_record_type); DECL_ARTIFICIAL (TYPE_STUB_DECL (new_record_type)) = 1; DECL_IGNORED_P (TYPE_STUB_DECL (new_record_type)) = DECL_IGNORED_P (TYPE_STUB_DECL (record_type)); @@ -1483,8 +1479,6 @@ create_var_decl_1 (tree var_name, tree asm_name, tree type, tree var_init, if (TREE_CODE (var_decl) != CONST_DECL) rest_of_decl_compilation (var_decl, global_bindings_p (), 0); else - /* expand CONST_DECLs to set their MODE, ALIGN, SIZE and SIZE_UNIT, - which we need for later back-annotations. */ expand_decl (var_decl); return var_decl; @@ -1631,35 +1625,28 @@ create_field_decl (tree field_name, tree field_type, tree record_type, DECL_HAS_REP_P (field_decl) = 1; } - /* If the field type is passed by reference, we will have pointers to the - field, so it is addressable. */ - if (must_pass_by_ref (field_type) || default_pass_by_ref (field_type)) + /* In addition to what our caller says, claim the field is addressable if we + know we might ever attempt to take its address, then mark the decl as + nonaddressable accordingly. + + The field may also be "technically" nonaddressable, meaning that even if + we attempt to take the field's address we will actually get the address + of a copy. This is the case for true bitfields, but the DECL_BIT_FIELD + value we have at this point is not accurate enough, so we don't account + for this here and let finish_record_type decide. */ + + /* We will take the address in any argument passing sequence if the field + type is passed by reference, and we might need the address for any array + type, even if normally passed by-copy, to construct a fat pointer if the + field is used as an actual for an unconstrained formal. */ + if (TREE_CODE (field_type) == ARRAY_TYPE + || must_pass_by_ref (field_type) || default_pass_by_ref (field_type)) addressable = 1; - /* Mark the decl as nonaddressable if it is indicated so semantically, - meaning we won't ever attempt to take the address of the field. - - It may also be "technically" nonaddressable, meaning that even if we - attempt to take the field's address we will actually get the address of a - copy. This is the case for true bitfields, but the DECL_BIT_FIELD value - we have at this point is not accurate enough, so we don't account for - this here and let finish_record_type decide. */ DECL_NONADDRESSABLE_P (field_decl) = !addressable; return field_decl; } - -/* Subroutine of previous function: return nonzero if EXP, ignoring any side - effects, has the value of zero. */ - -static bool -value_zerop (tree exp) -{ - if (TREE_CODE (exp) == COMPOUND_EXPR) - return value_zerop (TREE_OPERAND (exp, 1)); - - return integer_zerop (exp); -} /* Returns a PARM_DECL node. PARAM_NAME is the name of the parameter, PARAM_TYPE is its type. READONLY is true if the parameter is @@ -2142,14 +2129,6 @@ end_subprog_body (tree body) if (type_annotate_only) return; - /* If we don't have .ctors/.dtors sections, and this is a static - constructor or destructor, it must be recorded now. */ - if (DECL_STATIC_CONSTRUCTOR (fndecl) && !targetm.have_ctors_dtors) - VEC_safe_push (tree, gc, static_ctors, fndecl); - - if (DECL_STATIC_DESTRUCTOR (fndecl) && !targetm.have_ctors_dtors) - VEC_safe_push (tree, gc, static_dtors, fndecl); - /* Perform the required pre-gimplfication transformations on the tree. */ gnat_genericize (fndecl); @@ -3474,6 +3453,22 @@ convert (tree type, tree expr) } break; + case CONSTRUCTOR: + /* If we are converting a CONSTRUCTOR to another constrained array type + with the same domain, just make a new one in the proper type. */ + if (code == ecode && code == ARRAY_TYPE + && TREE_TYPE (type) == TREE_TYPE (etype) + && tree_int_cst_equal (TYPE_MIN_VALUE (TYPE_DOMAIN (type)), + TYPE_MIN_VALUE (TYPE_DOMAIN (etype))) + && tree_int_cst_equal (TYPE_MAX_VALUE (TYPE_DOMAIN (type)), + TYPE_MAX_VALUE (TYPE_DOMAIN (etype)))) + { + expr = copy_node (expr); + TREE_TYPE (expr) = type; + return expr; + } + break; + case UNCONSTRAINED_ARRAY_REF: /* Convert this to the type of the inner array by getting the address of the array from the template. */ @@ -4010,41 +4005,11 @@ tree_code_for_record_type (Entity_Id gnat_type) return UNION_TYPE; } -/* Build a global constructor or destructor function. METHOD_TYPE gives - the type of the function and VEC points to the vector of constructor - or destructor functions to be invoked. FIXME: Migrate into cgraph. */ - -static void -build_global_cdtor (int method_type, tree *vec, int len) -{ - tree body = NULL_TREE; - int i; - - for (i = 0; i < len; i++) - { - tree fntype = TREE_TYPE (vec[i]); - tree fnaddr = build1 (ADDR_EXPR, build_pointer_type (fntype), vec[i]); - tree fncall = build_call_nary (TREE_TYPE (fntype), fnaddr, 0); - append_to_statement_list (fncall, &body); - } - - if (body) - cgraph_build_static_cdtor (method_type, body, DEFAULT_INIT_PRIORITY); -} - /* Perform final processing on global variables. */ void gnat_write_global_declarations (void) { - /* Generate functions to call static constructors and destructors - for targets that do not support .ctors/.dtors sections. These - functions have magic names which are detected by collect2. */ - build_global_cdtor ('I', VEC_address (tree, static_ctors), - VEC_length (tree, static_ctors)); - build_global_cdtor ('D', VEC_address (tree, static_dtors), - VEC_length (tree, static_dtors)); - /* Proceed to optimize and emit assembly. FIXME: shouldn't be the front end's responsibility to call this. */ cgraph_optimize (); |