From 4189e6771feda58eeb5859eb78adaeb1ce9729e1 Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Tue, 30 Jun 2009 17:26:32 +0000 Subject: * cgraphunit.c (cgraph_finalize_compilation_unit): Call finalize_size_functions before further processing. * stor-layout.c: Include cgraph.h, tree-inline.h and tree-dump.h. (variable_size): Call self_referential_size on size expressions that contain a PLACEHOLDER_EXPR. (size_functions): New static variable. (copy_self_referential_tree_r): New static function. (self_referential_size): Likewise. (finalize_size_functions): New global function. * tree.c: Include tree-inline.h. (push_without_duplicates): New static function. (find_placeholder_in_expr): New global function. (substitute_in_expr) : Return the replacement object on equality. : Likewise. : If the replacement object is a constant, try to inline the call in the expression. * tree.h (finalize_size_functions): Declare. (find_placeholder_in_expr): Likewise. (FIND_PLACEHOLDER_IN_EXPR): New macro. (substitute_placeholder_in_expr): Update comment. * tree-inline.c (remap_decl): Do not unshare trees if do_not_unshare is true. (copy_tree_body_r): Likewise. (copy_tree_body): New static function. (maybe_inline_call_in_expr): New global function. * tree-inline.h (struct copy_body_data): Add do_not_unshare field. (maybe_inline_call_in_expr): Declare. * Makefile.in (tree.o): Depend on TREE_INLINE_H. (stor-layout.o): Depend on CGRAPH_H, TREE_INLINE_H, TREE_DUMP_H and GIMPLE_H. ada/ * gcc-interface/decl.c: Include tree-inline.h. (annotate_value) : Try to inline the call in the expression. * gcc-interface/utils.c (max_size) : Likewise. * gcc-interface/utils2.c: Include tree-inline. (known_alignment) : Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149112 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/gcc-interface/utils2.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gcc/ada/gcc-interface/utils2.c') diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index aab01f9b5d7..8ee9d4db918 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -31,6 +31,7 @@ #include "ggc.h" #include "flags.h" #include "output.h" +#include "tree-inline.h" #include "ada.h" #include "types.h" @@ -215,6 +216,15 @@ known_alignment (tree exp) this_alignment = expr_align (TREE_OPERAND (exp, 0)); break; + case CALL_EXPR: + { + tree t = maybe_inline_call_in_expr (exp); + if (t) + return known_alignment (t); + } + + /* Fall through... */ + default: /* For other pointer expressions, we assume that the pointed-to object is at least as aligned as the pointed-to type. Beware that we can -- cgit v1.2.1 From 7a0a2f40b640f70c985df1cf905f11424e9f68c6 Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Tue, 30 Jun 2009 19:20:24 +0000 Subject: * gcc-interface/utils2.c (build_binary_op) : Do not use the type of the left operand if it pads a self-referential type when the right operand is a constructor. * gcc-interface/lang-specs.h: Fix copyright date. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149115 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/gcc-interface/utils2.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'gcc/ada/gcc-interface/utils2.c') diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index 8ee9d4db918..e60e5a093ae 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -707,9 +707,10 @@ build_binary_op (enum tree_code op_code, tree result_type, /* If we are copying between padded objects with compatible types, use the padded view of the objects, this is very likely more efficient. - Likewise for a padded that is assigned a constructor, in order to - avoid putting a VIEW_CONVERT_EXPR on the LHS. But don't do this if - we wouldn't have actually copied anything. */ + Likewise for a padded object that is assigned a constructor, if we + can convert the constructor to the inner type, to avoid putting a + VIEW_CONVERT_EXPR on the LHS. But don't do so if we wouldn't have + actually copied anything. */ else if (TREE_CODE (left_type) == RECORD_TYPE && TYPE_IS_PADDING_P (left_type) && TREE_CONSTANT (TYPE_SIZE (left_type)) @@ -719,9 +720,11 @@ build_binary_op (enum tree_code op_code, tree result_type, && TYPE_IS_PADDING_P (TREE_TYPE (TREE_OPERAND (right_operand, 0))) && gnat_types_compatible_p - (left_type, - TREE_TYPE (TREE_OPERAND (right_operand, 0)))) - || TREE_CODE (right_operand) == CONSTRUCTOR) + (left_type, + TREE_TYPE (TREE_OPERAND (right_operand, 0)))) + || (TREE_CODE (right_operand) == CONSTRUCTOR + && !CONTAINS_PLACEHOLDER_P + (DECL_SIZE (TYPE_FIELDS (left_type))))) && !integer_zerop (TYPE_SIZE (right_type))) operation_type = left_type; -- cgit v1.2.1 From 092a498dbc2650cf1b84a659e6c1bceaf50e8985 Mon Sep 17 00:00:00 2001 From: jakub Date: Tue, 1 Sep 2009 10:18:34 +0000 Subject: * boehm.c (mark_reference_fields): Compute % in HOST_WIDE_INT type. * gcc-interface/utils2.c (maybe_wrap_malloc, maybe_wrap_free): Cast POINTER_SIZE to HOST_WIDE_INT. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151263 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/gcc-interface/utils2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gcc/ada/gcc-interface/utils2.c') diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index e60e5a093ae..b8ca814b6aa 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -1972,7 +1972,8 @@ maybe_wrap_malloc (tree data_size, tree data_type, Node_Id gnat_node) tree storage_ptr_slot_addr = build_binary_op (POINTER_PLUS_EXPR, ptr_void_type_node, convert (ptr_void_type_node, aligning_field_addr), - size_int (-POINTER_SIZE/BITS_PER_UNIT)); + size_int (-(HOST_WIDE_INT) POINTER_SIZE + / BITS_PER_UNIT)); tree storage_ptr_slot = build_unary_op (INDIRECT_REF, NULL_TREE, @@ -2013,7 +2014,7 @@ maybe_wrap_free (tree data_ptr, tree data_type) = build_binary_op (POINTER_PLUS_EXPR, ptr_void_type_node, convert (ptr_void_type_node, data_ptr), - size_int (-POINTER_SIZE/BITS_PER_UNIT)); + size_int (-(HOST_WIDE_INT) POINTER_SIZE / BITS_PER_UNIT)); /* FREE_PTR (void *) = *(void **)DATA_FRONT_PTR */ free_ptr -- cgit v1.2.1 From 354af4246fbe650a00173133354185900bfaaf86 Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Thu, 24 Sep 2009 13:36:24 +0000 Subject: * gcc-interface/ada.h: Fix outdated comment. * gcc-interface/ada-tree.h (SET_TYPE_RM_VALUE): Use MARK_VISITED in lieu of mark_visited. * gcc-interface/gigi.h (mark_visited): Change type of parameter. (MARK_VISITED): New macro. (gnat_truthvalue_conversion): Delete. * gcc-interface/decl.c (gnat_to_gnu_entity): Use MARK_VISITED in lieu of mark_visited. (annotate_rep): Fix formatting and tidy. (compute_field_positions): Get rid of useless variable. * gcc-interface/trans.c (gnat_to_gnu): Retrieve the Nkind of the GNAT node only once. Use IN operator for the Nkind in more cases. Remove calls to gnat_truthvalue_conversion. (mark_visited): Change type of parameter and adjust. (mark_visited_r): Dereference TP only once. (add_decl_expr): Use MARK_VISITED in lieu of mark_visited. * gcc-interface/utils2.c (gnat_truthvalue_conversion): Delete. (build_binary_op): Remove calls to gnat_truthvalue_conversion. (build_unary_op): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@152121 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/gcc-interface/utils2.c | 68 +----------------------------------------- 1 file changed, 1 insertion(+), 67 deletions(-) (limited to 'gcc/ada/gcc-interface/utils2.c') diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index b8ca814b6aa..f8a3dfbd525 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -55,63 +55,6 @@ static tree compare_arrays (tree, tree, tree); static tree nonbinary_modular_operation (enum tree_code, tree, tree, tree); static tree build_simple_component_ref (tree, tree, tree, bool); -/* Prepare expr to be an argument of a TRUTH_NOT_EXPR or other logical - operation. - - This preparation consists of taking the ordinary representation of - an expression expr and producing a valid tree boolean expression - describing whether expr is nonzero. We could simply always do - - build_binary_op (NE_EXPR, expr, integer_zero_node, 1), - - but we optimize comparisons, &&, ||, and !. - - The resulting type should always be the same as the input type. - This function is simpler than the corresponding C version since - the only possible operands will be things of Boolean type. */ - -tree -gnat_truthvalue_conversion (tree expr) -{ - tree type = TREE_TYPE (expr); - - switch (TREE_CODE (expr)) - { - case EQ_EXPR: case NE_EXPR: case LE_EXPR: case GE_EXPR: - case LT_EXPR: case GT_EXPR: - case TRUTH_ANDIF_EXPR: - case TRUTH_ORIF_EXPR: - case TRUTH_AND_EXPR: - case TRUTH_OR_EXPR: - case TRUTH_XOR_EXPR: - case ERROR_MARK: - return expr; - - case INTEGER_CST: - return (integer_zerop (expr) - ? build_int_cst (type, 0) - : build_int_cst (type, 1)); - - case REAL_CST: - return (real_zerop (expr) - ? fold_convert (type, integer_zero_node) - : fold_convert (type, integer_one_node)); - - case COND_EXPR: - /* Distribute the conversion into the arms of a COND_EXPR. */ - { - tree arg1 = gnat_truthvalue_conversion (TREE_OPERAND (expr, 1)); - tree arg2 = gnat_truthvalue_conversion (TREE_OPERAND (expr, 2)); - return fold_build3 (COND_EXPR, type, TREE_OPERAND (expr, 0), - arg1, arg2); - } - - default: - return build_binary_op (NE_EXPR, type, expr, - fold_convert (type, integer_zero_node)); - } -} - /* Return the base type of TYPE. */ tree @@ -970,15 +913,6 @@ build_binary_op (enum tree_code op_code, tree result_type, left_operand = convert (operation_type, left_operand); break; - case TRUTH_ANDIF_EXPR: - case TRUTH_ORIF_EXPR: - case TRUTH_AND_EXPR: - case TRUTH_OR_EXPR: - case TRUTH_XOR_EXPR: - left_operand = gnat_truthvalue_conversion (left_operand); - right_operand = gnat_truthvalue_conversion (right_operand); - goto common; - case BIT_AND_EXPR: case BIT_IOR_EXPR: case BIT_XOR_EXPR: @@ -1120,7 +1054,7 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) case TRUTH_NOT_EXPR: gcc_assert (result_type == base_type); - result = invert_truthvalue (gnat_truthvalue_conversion (operand)); + result = invert_truthvalue (operand); break; case ATTR_ADDR_EXPR: -- cgit v1.2.1 From a98f6becc1a2d108e170f816c1a9aebb3cb618df Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Fri, 16 Oct 2009 20:07:52 +0000 Subject: * gcc-interface/ada-tree.h (TYPE_FAT_POINTER_P): Swap with... (TYPE_IS_FAT_POINTER_P): ...this. (TYPE_THIN_POINTER_P): Rename into... (TYPE_IS_THIN_POINTER_P): ...this. (TYPE_FAT_OR_THIN_POINTER_P): Rename into... (TYPE_IS_FAT_OR_THIN_POINTER_P): ...this. (TYPE_IS_PADDING_P): Change definition, move old one to... (TYPE_PADDING_P): ...this. * gcc-interface/decl.c (gnat_to_gnu_entity): Adjust for above changes. (get_unpadded_type): Likewise. (gnat_to_gnu_component_type): Likewise. (gnat_to_gnu_param): Likewise. (relate_alias_sets): Likewise. (make_packable_type): Likewise. (maybe_pad_type): Likewise. (gnat_to_gnu_field): Likewise. (is_variable_size): Likewise. (annotate_object): Likewise. (validate_size): Likewise. (set_rm_size): Likewise. (make_type_from_size): Likewise. (rm_size): Likewise. * gcc-interface/misc.c (gnat_print_type): Likewise. (gnat_get_alias_set): Likewise. * gcc-interface/trans.c (Identifier_to_gnu): Likewise. (Attribute_to_gnu): Likewise. (call_to_gnu): Likewise. (gnat_to_gnu): Likewise. (add_decl_expr): Likewise. (convert_with_check): Likewise. (addressable_p): Likewise. (maybe_implicit_deref): Likewise. (protect_multiple_eval): Likewise. (gnat_stabilize_reference_1): Likewise. * gcc-interface/utils.c (gnat_pushdecl): Likewise. (finish_record_type): Likewise. (rest_of_record_type_compilation): Likewise. (create_type_decl): Likewise. (gnat_types_compatible_p): Likewise. (build_template): Likewise. (convert_vms_descriptor64): Likewise. (convert_vms_descriptor32): Likewise. (build_unc_object_type_from_ptr): Likewise. (update_pointer_to): Likewise. (convert_to_fat_pointer): Likewise. (convert_to_fat_pointer): Likewise. (convert): Likewise. (remove_conversions): Likewise. (maybe_unconstrained_array): Likewise. (unchecked_convert): Likewise. (handle_vector_type_attribute): Likewise. * gcc-interface/utils2.c (build_binary_op): Likewise. (build_unary_op): Likewise. (build_allocator): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@152917 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/gcc-interface/utils2.c | 44 +++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 26 deletions(-) (limited to 'gcc/ada/gcc-interface/utils2.c') diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index f8a3dfbd525..fcd9ecd1253 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -654,12 +654,9 @@ build_binary_op (enum tree_code op_code, tree result_type, can convert the constructor to the inner type, to avoid putting a VIEW_CONVERT_EXPR on the LHS. But don't do so if we wouldn't have actually copied anything. */ - else if (TREE_CODE (left_type) == RECORD_TYPE - && TYPE_IS_PADDING_P (left_type) + else if (TYPE_IS_PADDING_P (left_type) && TREE_CONSTANT (TYPE_SIZE (left_type)) && ((TREE_CODE (right_operand) == COMPONENT_REF - && TREE_CODE (TREE_TYPE (TREE_OPERAND (right_operand, 0))) - == RECORD_TYPE && TYPE_IS_PADDING_P (TREE_TYPE (TREE_OPERAND (right_operand, 0))) && gnat_types_compatible_p @@ -836,8 +833,8 @@ build_binary_op (enum tree_code op_code, tree result_type, convert both operands to that type. */ if (left_base_type != right_base_type) { - if (TYPE_FAT_POINTER_P (left_base_type) - && TYPE_FAT_POINTER_P (right_base_type) + if (TYPE_IS_FAT_POINTER_P (left_base_type) + && TYPE_IS_FAT_POINTER_P (right_base_type) && TYPE_MAIN_VARIANT (left_base_type) == TYPE_MAIN_VARIANT (right_base_type)) best_type = left_base_type; @@ -872,7 +869,7 @@ build_binary_op (enum tree_code op_code, tree result_type, /* If we are comparing a fat pointer against zero, we need to just compare the data pointer. */ - else if (TYPE_FAT_POINTER_P (left_base_type) + else if (TYPE_IS_FAT_POINTER_P (left_base_type) && TREE_CODE (right_operand) == CONSTRUCTOR && integer_zerop (VEC_index (constructor_elt, CONSTRUCTOR_ELTS (right_operand), @@ -1117,11 +1114,10 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) /* If INNER is a padding type whose field has a self-referential size, convert to that inner type. We know the offset is zero and we need to have that type visible. */ - if (TREE_CODE (TREE_TYPE (inner)) == RECORD_TYPE - && TYPE_IS_PADDING_P (TREE_TYPE (inner)) - && (CONTAINS_PLACEHOLDER_P - (TYPE_SIZE (TREE_TYPE (TYPE_FIELDS - (TREE_TYPE (inner))))))) + if (TYPE_IS_PADDING_P (TREE_TYPE (inner)) + && CONTAINS_PLACEHOLDER_P + (TYPE_SIZE (TREE_TYPE (TYPE_FIELDS + (TREE_TYPE (inner)))))) inner = convert (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (inner))), inner); @@ -1154,13 +1150,11 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) /* If this is just a constructor for a padded record, we can just take the address of the single field and convert it to a pointer to our type. */ - if (TREE_CODE (type) == RECORD_TYPE && TYPE_IS_PADDING_P (type)) + if (TYPE_IS_PADDING_P (type)) { - result = (VEC_index (constructor_elt, - CONSTRUCTOR_ELTS (operand), - 0) - ->value); - + result = VEC_index (constructor_elt, + CONSTRUCTOR_ELTS (operand), + 0)->value; result = convert (build_pointer_type (TREE_TYPE (operand)), build_unary_op (ADDR_EXPR, NULL_TREE, result)); break; @@ -1202,8 +1196,7 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) /* If we are taking the address of a padded record whose field is contains a template, take the address of the template. */ - if (TREE_CODE (type) == RECORD_TYPE - && TYPE_IS_PADDING_P (type) + if (TYPE_IS_PADDING_P (type) && TREE_CODE (TREE_TYPE (TYPE_FIELDS (type))) == RECORD_TYPE && TYPE_CONTAINS_TEMPLATE_P (TREE_TYPE (TYPE_FIELDS (type)))) { @@ -1226,7 +1219,7 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) make up an expression to do so. This will never survive to the backend. If TYPE is a thin pointer, first convert the operand to a fat pointer. */ - if (TYPE_THIN_POINTER_P (type) + if (TYPE_IS_THIN_POINTER_P (type) && TYPE_UNCONSTRAINED_ARRAY (TREE_TYPE (type))) { operand @@ -1235,7 +1228,7 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) type = TREE_TYPE (operand); } - if (TYPE_FAT_POINTER_P (type)) + if (TYPE_IS_FAT_POINTER_P (type)) { result = build1 (UNCONSTRAINED_ARRAY_REF, TYPE_UNCONSTRAINED_ARRAY (type), operand); @@ -1252,7 +1245,7 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) } side_effects - = (!TYPE_FAT_POINTER_P (type) && TYPE_VOLATILE (TREE_TYPE (type))); + = (!TYPE_IS_FAT_POINTER_P (type) && TYPE_VOLATILE (TREE_TYPE (type))); break; case NEGATE_EXPR: @@ -2027,7 +2020,7 @@ build_allocator (tree type, tree init, tree result_type, Entity_Id gnat_proc, /* If RESULT_TYPE is a fat or thin pointer, set SIZE to be the sum of the sizes of the object and its template. Allocate the whole thing and fill in the parts that are known. */ - else if (TYPE_FAT_OR_THIN_POINTER_P (result_type)) + else if (TYPE_IS_FAT_OR_THIN_POINTER_P (result_type)) { tree storage_type = build_unc_object_type_from_ptr (result_type, type, @@ -2049,10 +2042,9 @@ build_allocator (tree type, tree init, tree result_type, Entity_Id gnat_proc, gnat_proc, gnat_pool, gnat_node); storage = convert (storage_ptr_type, protect_multiple_eval (storage)); - if (TREE_CODE (type) == RECORD_TYPE && TYPE_IS_PADDING_P (type)) + if (TYPE_IS_PADDING_P (type)) { type = TREE_TYPE (TYPE_FIELDS (type)); - if (init) init = convert (type, init); } -- cgit v1.2.1 From 4b791c0d89a4a9539746d55d72e3f8cb9cc8dd27 Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Sat, 17 Oct 2009 11:05:35 +0000 Subject: * gcc-interface/utils2.c (build_binary_op) : Make sure the element type is consistent. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@152934 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/gcc-interface/utils2.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/ada/gcc-interface/utils2.c') diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index fcd9ecd1253..7176740f453 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -755,6 +755,12 @@ build_binary_op (enum tree_code op_code, tree result_type, left_type = TREE_TYPE (left_operand); } + /* For a range, make sure the element type is consistent. */ + if (op_code == ARRAY_RANGE_REF + && TREE_TYPE (operation_type) != TREE_TYPE (left_type)) + operation_type = build_array_type (TREE_TYPE (left_type), + TYPE_DOMAIN (operation_type)); + /* Then convert the right operand to its base type. This will prevent unneeded sign conversions when sizetype is wider than integer. */ right_operand = convert (right_base_type, right_operand); -- cgit v1.2.1 From e428f28fdb449d7515777c97442ab897710758be Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Sat, 27 Feb 2010 14:27:27 +0000 Subject: PR ada/42253 * gcc-interface/utils2.c (build_binary_op) : Assert that fat pointer base types are variant of each other. Apply special treatment for null to fat pointer types in all cases. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157107 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/gcc-interface/utils2.c | 60 ++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 29 deletions(-) (limited to 'gcc/ada/gcc-interface/utils2.c') diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index 7176740f453..3d6ac201107 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -834,26 +834,28 @@ build_binary_op (enum tree_code op_code, tree result_type, return result; } - /* Otherwise, the base types must be the same unless the objects are - fat pointers or records. If we have records, use the best type and - convert both operands to that type. */ + /* Otherwise, the base types must be the same, unless they are both fat + pointer types or record types. In the latter case, use the best type + and convert both operands to that type. */ if (left_base_type != right_base_type) { if (TYPE_IS_FAT_POINTER_P (left_base_type) - && TYPE_IS_FAT_POINTER_P (right_base_type) - && TYPE_MAIN_VARIANT (left_base_type) - == TYPE_MAIN_VARIANT (right_base_type)) - best_type = left_base_type; + && TYPE_IS_FAT_POINTER_P (right_base_type)) + { + gcc_assert (TYPE_MAIN_VARIANT (left_base_type) + == TYPE_MAIN_VARIANT (right_base_type)); + best_type = left_base_type; + } + else if (TREE_CODE (left_base_type) == RECORD_TYPE && TREE_CODE (right_base_type) == RECORD_TYPE) { - /* The only way these are permitted to be the same is if both - types have the same name. In that case, one of them must - not be self-referential. Use that one as the best type. - Even better is if one is of fixed size. */ + /* The only way this is permitted is if both types have the same + name. In that case, one of them must not be self-referential. + Use it as the best type. Even better with a fixed size. */ gcc_assert (TYPE_NAME (left_base_type) - && (TYPE_NAME (left_base_type) - == TYPE_NAME (right_base_type))); + && TYPE_NAME (left_base_type) + == TYPE_NAME (right_base_type)); if (TREE_CONSTANT (TYPE_SIZE (left_base_type))) best_type = left_base_type; @@ -866,34 +868,34 @@ build_binary_op (enum tree_code op_code, tree result_type, else gcc_unreachable (); } + else gcc_unreachable (); left_operand = convert (best_type, left_operand); right_operand = convert (best_type, right_operand); } - - /* If we are comparing a fat pointer against zero, we need to - just compare the data pointer. */ - else if (TYPE_IS_FAT_POINTER_P (left_base_type) - && TREE_CODE (right_operand) == CONSTRUCTOR - && integer_zerop (VEC_index (constructor_elt, - CONSTRUCTOR_ELTS (right_operand), - 0) - ->value)) - { - right_operand = build_component_ref (left_operand, NULL_TREE, - TYPE_FIELDS (left_base_type), - false); - left_operand = convert (TREE_TYPE (right_operand), - integer_zero_node); - } else { left_operand = convert (left_base_type, left_operand); right_operand = convert (right_base_type, right_operand); } + /* If we are comparing a fat pointer against zero, we just need to + compare the data pointer. */ + if (TYPE_IS_FAT_POINTER_P (left_base_type) + && TREE_CODE (right_operand) == CONSTRUCTOR + && integer_zerop (VEC_index (constructor_elt, + CONSTRUCTOR_ELTS (right_operand), + 0)->value)) + { + left_operand + = build_component_ref (left_operand, NULL_TREE, + TYPE_FIELDS (left_base_type), false); + right_operand + = convert (TREE_TYPE (left_operand), integer_zero_node); + } + modulus = NULL_TREE; break; -- cgit v1.2.1 From 4cd5bb613c816cf996ca11a356cff1c7870806b0 Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Thu, 8 Apr 2010 20:16:36 +0000 Subject: * tree.h (TREE_ADDRESSABLE): Document its effect for function types. * calls.c (expand_call): Pass the function type to aggregate_value_p. * function.c (aggregate_value_p): Do not honor DECL_BY_REFERENCE on the target function of a CALL_EXPR. Honor TREE_ADDRESSABLE on the function type instead. Reorder and simplify checks. * gimplify.c (gimplify_modify_expr_rhs) : New case. ada/ * gcc-interface/ada-tree.h (TYPE_RETURNS_UNCONSTRAINED_P): Rename into. (TYPE_RETURN_UNCONSTRAINED_P): ...this. (TYPE_RETURNS_BY_REF_P): Rename into. (TYPE_RETURN_BY_DIRECT_REF_P): ...this. (TYPE_RETURNS_BY_TARGET_PTR_P): Delete. * gcc-interface/gigi.h (create_subprog_type): Adjust parameter names. (build_return_expr): Likewise. * gcc-interface/decl.c (gnat_to_gnu_entity) : Rename local variables. If the return Mechanism is By_Reference, pass return_by_invisible_ref_p to create_subprog_type instead of toggling TREE_ADDRESSABLE. Test return_by_invisible_ref_p in order to annotate the mechanism. Use regular return for contrained types with non-static size and return by invisible reference for unconstrained return types with default discriminants. Update comment. * gcc-interface/trans.c (Subprogram_Body_to_gnu): If the function returns by invisible reference, turn the RESULT_DECL into a pointer. Do not handle DECL_BY_REF_P in the CICO case here. (call_to_gnu): Remove code handling return by target pointer. For a function call, if the return type has non-constant size, generate the assignment with an INIT_EXPR. (gnat_to_gnu) : Remove dead code in the CICO case. If the function returns by invisible reference, build the copy return operation manually. (add_decl_expr): Initialize the variable with an INIT_EXPR. * gcc-interface/utils.c (create_subprog_type): Adjust parameter names. Adjust for renaming of macros. Copy the node only when necessary. (create_subprog_decl): Do not toggle TREE_ADDRESSABLE on the return type, only change DECL_BY_REFERENCE on the RETURN_DECL. (convert_from_reference): Delete. (is_byref_result): Likewise. (gnat_genericize_r): Likewise. (gnat_genericize): Likewise. (end_subprog_body): Do not call gnat_genericize. * gcc-interface/utils2.c (build_binary_op) : New case. (build_return_expr): Adjust parameter names, logic and comment. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158139 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/gcc-interface/utils2.c | 46 +++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 25 deletions(-) (limited to 'gcc/ada/gcc-interface/utils2.c') diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index 3d6ac201107..e3b3ec9d18b 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -6,7 +6,7 @@ * * * C Implementation File * * * - * Copyright (C) 1992-2009, Free Software Foundation, Inc. * + * Copyright (C) 1992-2010, Free Software Foundation, Inc. * * * * GNAT is free software; you can redistribute it and/or modify it under * * terms of the GNU General Public License as published by the Free Soft- * @@ -609,6 +609,7 @@ build_binary_op (enum tree_code op_code, tree result_type, switch (op_code) { + case INIT_EXPR: case MODIFY_EXPR: /* If there were integral or pointer conversions on the LHS, remove them; we'll be putting them back below if needed. Likewise for @@ -1397,45 +1398,40 @@ build_cond_expr (tree result_type, tree condition_operand, return result; } -/* Similar, but for RETURN_EXPR. If RESULT_DECL is non-zero, build - a RETURN_EXPR around the assignment of RET_VAL to RESULT_DECL. - If RESULT_DECL is zero, build a bare RETURN_EXPR. */ +/* Similar, but for RETURN_EXPR. If RET_VAL is non-null, build a RETURN_EXPR + around the assignment of RET_VAL to RET_OBJ. Otherwise just build a bare + RETURN_EXPR around RESULT_OBJ, which may be null in this case. */ tree -build_return_expr (tree result_decl, tree ret_val) +build_return_expr (tree ret_obj, tree ret_val) { tree result_expr; - if (result_decl) + if (ret_val) { /* The gimplifier explicitly enforces the following invariant: - RETURN_EXPR - | - MODIFY_EXPR - / \ - / \ - RESULT_DECL ... + RETURN_EXPR + | + MODIFY_EXPR + / \ + / \ + RET_OBJ ... - As a consequence, type-homogeneity dictates that we use the type - of the RESULT_DECL as the operation type. */ - - tree operation_type = TREE_TYPE (result_decl); - - /* Convert the right operand to the operation type. Note that - it's the same transformation as in the MODIFY_EXPR case of - build_binary_op with the additional guarantee that the type - cannot involve a placeholder, since otherwise the function - would use the "target pointer" return mechanism. */ + As a consequence, type consistency dictates that we use the type + of the RET_OBJ as the operation type. */ + tree operation_type = TREE_TYPE (ret_obj); + /* Convert the right operand to the operation type. Note that it's the + same transformation as in the MODIFY_EXPR case of build_binary_op, + with the assumption that the type cannot involve a placeholder. */ if (operation_type != TREE_TYPE (ret_val)) ret_val = convert (operation_type, ret_val); - result_expr - = build2 (MODIFY_EXPR, operation_type, result_decl, ret_val); + result_expr = build2 (MODIFY_EXPR, operation_type, ret_obj, ret_val); } else - result_expr = NULL_TREE; + result_expr = ret_obj; return build1 (RETURN_EXPR, void_type_node, result_expr); } -- cgit v1.2.1 From 9bfb1138c84dbe7e60bba2be8d82f30f2bc2da8b Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Fri, 9 Apr 2010 10:10:25 +0000 Subject: * gcc-interface/gigi.h (gnat_mark_addressable): Rename parameter. * gcc-interface/decl.c (maybe_variable): Do not set TREE_STATIC on _REF node. Use the type of the operand to set TREE_READONLY. * gcc-interface/trans.c (Identifier_to_gnu): Do not set TREE_STATIC on _REF node. Do not overwrite TREE_READONLY. (call_to_gnu): Rename local variable and fix various nits. In the copy-in/copy-out case, build the SAVE_EXPR manually. (convert_with_check): Call protect_multiple_eval in lieu of save_expr and fold the computations. (protect_multiple_eval): Always save entire fat pointers. (maybe_stabilize_reference): Minor tweaks. (gnat_stabilize_reference_1): Likewise. Do not deal with tcc_constant, tcc_type and tcc_statement. * gcc-interface/utils.c (convert_to_fat_pointer): Call protect_multiple_eval in lieu of save_expr. (convert): Minor tweaks. (maybe_unconstrained_array): Do not set TREE_STATIC on _REF node. (builtin_type_for_size): Call gnat_type_for_size directly. * gcc-interface/utils2.c (contains_save_expr_p): Delete. (contains_null_expr): Likewise (gnat_build_constructor): Do not call it. (compare_arrays): Deal with all side-effects, use protect_multiple_eval instead of gnat_stabilize_reference to protect the operands. (nonbinary_modular_operation): Call protect_multiple_eval in lieu of save_expr. (maybe_wrap_malloc): Likewise. (build_allocator): Likewise. (build_unary_op) : Do not set TREE_STATIC on _REF node. (gnat_mark_addressable): Rename parameter. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158156 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/gcc-interface/utils2.c | 178 +++++++++++------------------------------ 1 file changed, 47 insertions(+), 131 deletions(-) (limited to 'gcc/ada/gcc-interface/utils2.c') diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index e3b3ec9d18b..5db38c531b0 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -49,8 +49,6 @@ #include "gigi.h" static tree find_common_type (tree, tree); -static bool contains_save_expr_p (tree); -static tree contains_null_expr (tree); static tree compare_arrays (tree, tree, tree); static tree nonbinary_modular_operation (enum tree_code, tree, tree, tree); static tree build_simple_component_ref (tree, tree, tree, bool); @@ -233,100 +231,13 @@ find_common_type (tree t1, tree t2) return NULL_TREE; } -/* See if EXP contains a SAVE_EXPR in a position where we would - normally put it. +/* Return an expression tree representing an equality comparison of A1 and A2, + two objects of type ARRAY_TYPE. The result should be of type RESULT_TYPE. - ??? This is a real kludge, but is probably the best approach short - of some very general solution. */ - -static bool -contains_save_expr_p (tree exp) -{ - switch (TREE_CODE (exp)) - { - case SAVE_EXPR: - return true; - - case ADDR_EXPR: case INDIRECT_REF: - case COMPONENT_REF: - CASE_CONVERT: case VIEW_CONVERT_EXPR: - return contains_save_expr_p (TREE_OPERAND (exp, 0)); - - case CONSTRUCTOR: - { - tree value; - unsigned HOST_WIDE_INT ix; - - FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (exp), ix, value) - if (contains_save_expr_p (value)) - return true; - return false; - } - - default: - return false; - } -} - -/* See if EXP contains a NULL_EXPR in an expression we use for sizes. Return - it if so. This is used to detect types whose sizes involve computations - that are known to raise Constraint_Error. */ - -static tree -contains_null_expr (tree exp) -{ - tree tem; - - if (TREE_CODE (exp) == NULL_EXPR) - return exp; - - switch (TREE_CODE_CLASS (TREE_CODE (exp))) - { - case tcc_unary: - return contains_null_expr (TREE_OPERAND (exp, 0)); - - case tcc_comparison: - case tcc_binary: - tem = contains_null_expr (TREE_OPERAND (exp, 0)); - if (tem) - return tem; - - return contains_null_expr (TREE_OPERAND (exp, 1)); - - case tcc_expression: - switch (TREE_CODE (exp)) - { - case SAVE_EXPR: - return contains_null_expr (TREE_OPERAND (exp, 0)); - - case COND_EXPR: - tem = contains_null_expr (TREE_OPERAND (exp, 0)); - if (tem) - return tem; - - tem = contains_null_expr (TREE_OPERAND (exp, 1)); - if (tem) - return tem; - - return contains_null_expr (TREE_OPERAND (exp, 2)); - - default: - return 0; - } - - default: - return 0; - } -} - -/* Return an expression tree representing an equality comparison of - A1 and A2, two objects of ARRAY_TYPE. The returned expression should - be of type RESULT_TYPE - - Two arrays are equal in one of two ways: (1) if both have zero length - in some dimension (not necessarily the same dimension) or (2) if the - lengths in each dimension are equal and the data is equal. We perform the - length tests in as efficient a manner as possible. */ + Two arrays are equal in one of two ways: (1) if both have zero length in + some dimension (not necessarily the same dimension) or (2) if the lengths + in each dimension are equal and the data is equal. We perform the length + tests in as efficient a manner as possible. */ static tree compare_arrays (tree result_type, tree a1, tree a2) @@ -336,8 +247,18 @@ compare_arrays (tree result_type, tree a1, tree a2) tree result = convert (result_type, integer_one_node); tree a1_is_null = convert (result_type, integer_zero_node); tree a2_is_null = convert (result_type, integer_zero_node); + bool a1_side_effects_p = TREE_SIDE_EFFECTS (a1); + bool a2_side_effects_p = TREE_SIDE_EFFECTS (a2); bool length_zero_p = false; + /* If either operand has side-effects, they have to be evaluated only once + in spite of the multiple references to the operand in the comparison. */ + if (a1_side_effects_p) + a1 = protect_multiple_eval (a1); + + if (a2_side_effects_p) + a2 = protect_multiple_eval (a2); + /* Process each dimension separately and compare the lengths. If any dimension has a size known to be zero, set SIZE_ZERO_P to 1 to suppress the comparison of the data. */ @@ -350,9 +271,9 @@ compare_arrays (tree result_type, tree a1, tree a2) tree bt = get_base_type (TREE_TYPE (lb1)); tree length1 = fold_build2 (MINUS_EXPR, bt, ub1, lb1); tree length2 = fold_build2 (MINUS_EXPR, bt, ub2, lb2); - tree nbt; - tree tem; tree comparison, this_a1_is_null, this_a2_is_null; + tree nbt, tem; + bool btem; /* If the length of the first array is a constant, swap our operands unless the length of the second array is the constant zero. @@ -367,6 +288,8 @@ compare_arrays (tree result_type, tree a1, tree a2) tem = ub1, ub1 = ub2, ub2 = tem; tem = length1, length1 = length2, length2 = tem; tem = a1_is_null, a1_is_null = a2_is_null, a2_is_null = tem; + btem = a1_side_effects_p, a1_side_effects_p = a2_side_effects_p, + a2_side_effects_p = btem; } /* If the length of this dimension in the second array is the constant @@ -449,11 +372,13 @@ compare_arrays (tree result_type, tree a1, tree a2) tree type = find_common_type (TREE_TYPE (a1), TREE_TYPE (a2)); if (type) - a1 = convert (type, a1), a2 = convert (type, a2); + { + a1 = convert (type, a1), + a2 = convert (type, a2); + } result = build_binary_op (TRUTH_ANDIF_EXPR, result_type, result, fold_build2 (EQ_EXPR, result_type, a1, a2)); - } /* The result is also true if both sizes are zero. */ @@ -462,14 +387,13 @@ compare_arrays (tree result_type, tree a1, tree a2) a1_is_null, a2_is_null), result); - /* If either operand contains SAVE_EXPRs, they have to be evaluated before - starting the comparison above since the place it would be otherwise - evaluated would be wrong. */ - - if (contains_save_expr_p (a1)) + /* If either operand has side-effects, they have to be evaluated before + starting the comparison above since the place they would be otherwise + evaluated could be wrong. */ + if (a1_side_effects_p) result = build2 (COMPOUND_EXPR, result_type, a1, result); - if (contains_save_expr_p (a2)) + if (a2_side_effects_p) result = build2 (COMPOUND_EXPR, result_type, a2, result); return result; @@ -547,7 +471,7 @@ nonbinary_modular_operation (enum tree_code op_code, tree type, tree lhs, /* For subtraction, add the modulus back if we are negative. */ else if (op_code == MINUS_EXPR) { - result = save_expr (result); + result = protect_multiple_eval (result); result = fold_build3 (COND_EXPR, op_type, fold_build2 (LT_EXPR, integer_type_node, result, convert (op_type, integer_zero_node)), @@ -558,7 +482,7 @@ nonbinary_modular_operation (enum tree_code op_code, tree type, tree lhs, /* For the other operations, subtract the modulus if we are >= it. */ else { - result = save_expr (result); + result = protect_multiple_eval (result); result = fold_build3 (COND_EXPR, op_type, fold_build2 (GE_EXPR, integer_type_node, result, modulus), @@ -1241,7 +1165,7 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) { result = build1 (UNCONSTRAINED_ARRAY_REF, TYPE_UNCONSTRAINED_ARRAY (type), operand); - TREE_READONLY (result) = TREE_STATIC (result) + TREE_READONLY (result) = TYPE_READONLY (TYPE_UNCONSTRAINED_ARRAY (type)); } else if (TREE_CODE (operand) == ADDR_EXPR) @@ -1590,13 +1514,6 @@ gnat_build_constructor (tree type, tree list) if (TREE_SIDE_EFFECTS (val)) side_effects = true; - - /* Propagate an NULL_EXPR from the size of the type. We won't ever - be executing the code we generate here in that case, but handle it - specially to avoid the compiler blowing up. */ - if (TREE_CODE (type) == RECORD_TYPE - && (result = contains_null_expr (DECL_SIZE (obj))) != NULL_TREE) - return build1 (NULL_EXPR, type, TREE_OPERAND (result, 0)); } /* For record types with constant components only, sort field list @@ -1883,7 +1800,7 @@ maybe_wrap_malloc (tree data_size, tree data_type, Node_Id gnat_node) { /* Latch malloc's return value and get a pointer to the aligning field first. */ - tree storage_ptr = save_expr (malloc_ptr); + tree storage_ptr = protect_multiple_eval (malloc_ptr); tree aligning_record_addr = convert (build_pointer_type (aligning_type), storage_ptr); @@ -2118,12 +2035,11 @@ build_allocator (tree type, tree init, tree result_type, Entity_Id gnat_proc, gnat_proc, gnat_pool, gnat_node)); - /* If we have an initial value, put the new address into a SAVE_EXPR, assign - the value, and return the address. Do this with a COMPOUND_EXPR. */ - + /* If we have an initial value, protect the new address, assign the value + and return the address with a COMPOUND_EXPR. */ if (init) { - result = save_expr (result); + result = protect_multiple_eval (result); result = build2 (COMPOUND_EXPR, TREE_TYPE (result), build_binary_op @@ -2188,14 +2104,14 @@ fill_vms_descriptor (tree expr, Entity_Id gnat_formal, Node_Id gnat_actual) return gnat_build_constructor (record_type, nreverse (const_list)); } -/* Indicate that we need to make the address of EXPR_NODE and it therefore +/* Indicate that we need to take the address of T and that it therefore should not be allocated in a register. Returns true if successful. */ bool -gnat_mark_addressable (tree expr_node) +gnat_mark_addressable (tree t) { - while (1) - switch (TREE_CODE (expr_node)) + while (true) + switch (TREE_CODE (t)) { case ADDR_EXPR: case COMPONENT_REF: @@ -2206,27 +2122,27 @@ gnat_mark_addressable (tree expr_node) case VIEW_CONVERT_EXPR: case NON_LVALUE_EXPR: CASE_CONVERT: - expr_node = TREE_OPERAND (expr_node, 0); + t = TREE_OPERAND (t, 0); break; case CONSTRUCTOR: - TREE_ADDRESSABLE (expr_node) = 1; + TREE_ADDRESSABLE (t) = 1; return true; case VAR_DECL: case PARM_DECL: case RESULT_DECL: - TREE_ADDRESSABLE (expr_node) = 1; + TREE_ADDRESSABLE (t) = 1; return true; case FUNCTION_DECL: - TREE_ADDRESSABLE (expr_node) = 1; + TREE_ADDRESSABLE (t) = 1; return true; case CONST_DECL: - return (DECL_CONST_CORRESPONDING_VAR (expr_node) - && (gnat_mark_addressable - (DECL_CONST_CORRESPONDING_VAR (expr_node)))); + return DECL_CONST_CORRESPONDING_VAR (t) + && gnat_mark_addressable (DECL_CONST_CORRESPONDING_VAR (t)); + default: return true; } -- cgit v1.2.1 From df8a2682f432b414383c112949c751302823e5c7 Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Fri, 9 Apr 2010 10:49:46 +0000 Subject: * gcc-interface/gigi.h (maybe_variable): Delete. (protect_multiple_eval): Likewise. (maybe_stabilize_reference): Likewise. (gnat_save_expr): Declare. (gnat_protect_expr): Likewise. (gnat_stabilize_reference): Likewise. * gcc-interface/decl.c (gnat_to_gnu_entity) : Use gnat_stabilize_reference. (maybe_variable): Delete. (elaborate_expression_1): Use gnat_save_expr. * gcc-interface/trans.c (Attribute_to_gnu): Use gnat_protect_expr. (call_to_gnu): Pass NULL to gnat_stabilize_reference. (gnat_to_gnu) : Use gnat_save_expr. : Use gnat_protect_exp. : Pass NULL to gnat_stabilize_reference. : Use gnat_protect_expr. Pass NULL to gnat_stabilize_reference. (build_unary_op_trapv): Use gnat_protect_expr. (build_binary_op_trapv): Likewise. (emit_range_check): Likewise. (emit_index_check): Likewise. (convert_with_check): Likewise. (protect_multiple_eval): Move to utils2.c file. (maybe_stabilize_reference): Merge into... (gnat_stabilize_reference): ...this. Move to utils2.c file. (gnat_stabilize_reference_1): Likewise. * gcc-interface/utils.c (convert_to_fat_pointer): Use gnat_protect_expr instead of protect_multiple_eval. * gcc-interface/utils2.c (compare_arrays): Likewise. (nonbinary_modular_operation): Likewise. (maybe_wrap_malloc): Likewise. (build_allocator): Likewise. (gnat_save_expr): New function. (gnat_protect_expr): Rename from protect_multiple_eval. Early return in common cases. Propagate TREE_READONLY onto dereferences. (gnat_stabilize_reference_1): Move from trans.c file. (gnat_stabilize_reference): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158159 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/gcc-interface/utils2.c | 304 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 297 insertions(+), 7 deletions(-) (limited to 'gcc/ada/gcc-interface/utils2.c') diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index 5db38c531b0..a6ec65fd54d 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -254,10 +254,10 @@ compare_arrays (tree result_type, tree a1, tree a2) /* If either operand has side-effects, they have to be evaluated only once in spite of the multiple references to the operand in the comparison. */ if (a1_side_effects_p) - a1 = protect_multiple_eval (a1); + a1 = gnat_protect_expr (a1); if (a2_side_effects_p) - a2 = protect_multiple_eval (a2); + a2 = gnat_protect_expr (a2); /* Process each dimension separately and compare the lengths. If any dimension has a size known to be zero, set SIZE_ZERO_P to 1 to @@ -471,7 +471,7 @@ nonbinary_modular_operation (enum tree_code op_code, tree type, tree lhs, /* For subtraction, add the modulus back if we are negative. */ else if (op_code == MINUS_EXPR) { - result = protect_multiple_eval (result); + result = gnat_protect_expr (result); result = fold_build3 (COND_EXPR, op_type, fold_build2 (LT_EXPR, integer_type_node, result, convert (op_type, integer_zero_node)), @@ -482,7 +482,7 @@ nonbinary_modular_operation (enum tree_code op_code, tree type, tree lhs, /* For the other operations, subtract the modulus if we are >= it. */ else { - result = protect_multiple_eval (result); + result = gnat_protect_expr (result); result = fold_build3 (COND_EXPR, op_type, fold_build2 (GE_EXPR, integer_type_node, result, modulus), @@ -1800,7 +1800,7 @@ maybe_wrap_malloc (tree data_size, tree data_type, Node_Id gnat_node) { /* Latch malloc's return value and get a pointer to the aligning field first. */ - tree storage_ptr = protect_multiple_eval (malloc_ptr); + tree storage_ptr = gnat_protect_expr (malloc_ptr); tree aligning_record_addr = convert (build_pointer_type (aligning_type), storage_ptr); @@ -1961,7 +1961,7 @@ build_allocator (tree type, tree init, tree result_type, Entity_Id gnat_proc, storage = build_call_alloc_dealloc (NULL_TREE, size, storage_type, gnat_proc, gnat_pool, gnat_node); - storage = convert (storage_ptr_type, protect_multiple_eval (storage)); + storage = convert (storage_ptr_type, gnat_protect_expr (storage)); if (TYPE_IS_PADDING_P (type)) { @@ -2039,7 +2039,7 @@ build_allocator (tree type, tree init, tree result_type, Entity_Id gnat_proc, and return the address with a COMPOUND_EXPR. */ if (init) { - result = protect_multiple_eval (result); + result = gnat_protect_expr (result); result = build2 (COMPOUND_EXPR, TREE_TYPE (result), build_binary_op @@ -2147,3 +2147,293 @@ gnat_mark_addressable (tree t) return true; } } + +/* Save EXP for later use or reuse. This is equivalent to save_expr in tree.c + but we know how to handle our own nodes. */ + +tree +gnat_save_expr (tree exp) +{ + tree type = TREE_TYPE (exp); + enum tree_code code = TREE_CODE (exp); + + if (TREE_CONSTANT (exp) || code == SAVE_EXPR || code == NULL_EXPR) + return exp; + + if (code == UNCONSTRAINED_ARRAY_REF) + { + tree t = build1 (code, type, gnat_save_expr (TREE_OPERAND (exp, 0))); + TREE_READONLY (t) = TYPE_READONLY (type); + return t; + } + + /* If this is a COMPONENT_REF of a fat pointer, save the entire fat pointer. + This may be more efficient, but will also allow us to more easily find + the match for the PLACEHOLDER_EXPR. */ + if (code == COMPONENT_REF + && TYPE_IS_FAT_POINTER_P (TREE_TYPE (TREE_OPERAND (exp, 0)))) + return build3 (code, type, gnat_save_expr (TREE_OPERAND (exp, 0)), + TREE_OPERAND (exp, 1), TREE_OPERAND (exp, 2)); + + return save_expr (exp); +} + +/* Protect EXP for immediate reuse. This is a variant of gnat_save_expr that + is optimized under the assumption that EXP's value doesn't change before + its subsequent reuse(s) except through its potential reevaluation. */ + +tree +gnat_protect_expr (tree exp) +{ + tree type = TREE_TYPE (exp); + enum tree_code code = TREE_CODE (exp); + + if (TREE_CONSTANT (exp) || code == SAVE_EXPR || code == NULL_EXPR) + return exp; + + /* If EXP has no side effects, we theoritically don't need to do anything. + However, we may be recursively passed more and more complex expressions + involving checks which will be reused multiple times and eventually be + unshared for gimplification; in order to avoid a complexity explosion + at that point, we protect any expressions more complex than a simple + arithmetic expression. */ + if (!TREE_SIDE_EFFECTS (exp) + && !EXPRESSION_CLASS_P (skip_simple_arithmetic (exp))) + return exp; + + /* If this is a conversion, protect what's inside the conversion. */ + if (code == NON_LVALUE_EXPR + || CONVERT_EXPR_CODE_P (code) + || code == VIEW_CONVERT_EXPR) + return build1 (code, type, gnat_protect_expr (TREE_OPERAND (exp, 0))); + + /* If we're indirectly referencing something, we only need to protect the + address since the data itself can't change in these situations. */ + if (code == INDIRECT_REF || code == UNCONSTRAINED_ARRAY_REF) + { + tree t = build1 (code, type, gnat_protect_expr (TREE_OPERAND (exp, 0))); + TREE_READONLY (t) = TYPE_READONLY (type); + return t; + } + + /* If this is a COMPONENT_REF of a fat pointer, save the entire fat pointer. + This may be more efficient, but will also allow us to more easily find + the match for the PLACEHOLDER_EXPR. */ + if (code == COMPONENT_REF + && TYPE_IS_FAT_POINTER_P (TREE_TYPE (TREE_OPERAND (exp, 0)))) + return build3 (code, type, gnat_protect_expr (TREE_OPERAND (exp, 0)), + TREE_OPERAND (exp, 1), TREE_OPERAND (exp, 2)); + + /* If this is a fat pointer or something that can be placed in a register, + just make a SAVE_EXPR. Likewise for a CALL_EXPR as large objects are + returned via invisible reference in most ABIs so the temporary will + directly be filled by the callee. */ + if (TYPE_IS_FAT_POINTER_P (type) + || TYPE_MODE (type) != BLKmode + || code == CALL_EXPR) + return save_expr (exp); + + /* Otherwise reference, protect the address and dereference. */ + return + build_unary_op (INDIRECT_REF, type, + save_expr (build_unary_op (ADDR_EXPR, + build_reference_type (type), + exp))); +} + +/* This is equivalent to stabilize_reference_1 in tree.c but we take an extra + argument to force evaluation of everything. */ + +static tree +gnat_stabilize_reference_1 (tree e, bool force) +{ + enum tree_code code = TREE_CODE (e); + tree type = TREE_TYPE (e); + tree result; + + /* We cannot ignore const expressions because it might be a reference + to a const array but whose index contains side-effects. But we can + ignore things that are actual constant or that already have been + handled by this function. */ + if (TREE_CONSTANT (e) || code == SAVE_EXPR) + return e; + + switch (TREE_CODE_CLASS (code)) + { + case tcc_exceptional: + case tcc_declaration: + case tcc_comparison: + case tcc_expression: + case tcc_reference: + case tcc_vl_exp: + /* If this is a COMPONENT_REF of a fat pointer, save the entire + fat pointer. This may be more efficient, but will also allow + us to more easily find the match for the PLACEHOLDER_EXPR. */ + if (code == COMPONENT_REF + && TYPE_IS_FAT_POINTER_P (TREE_TYPE (TREE_OPERAND (e, 0)))) + result + = build3 (code, type, + gnat_stabilize_reference_1 (TREE_OPERAND (e, 0), force), + TREE_OPERAND (e, 1), TREE_OPERAND (e, 2)); + /* If the expression has side-effects, then encase it in a SAVE_EXPR + so that it will only be evaluated once. */ + /* The tcc_reference and tcc_comparison classes could be handled as + below, but it is generally faster to only evaluate them once. */ + else if (TREE_SIDE_EFFECTS (e) || force) + return save_expr (e); + else + return e; + break; + + case tcc_binary: + /* Recursively stabilize each operand. */ + result + = build2 (code, type, + gnat_stabilize_reference_1 (TREE_OPERAND (e, 0), force), + gnat_stabilize_reference_1 (TREE_OPERAND (e, 1), force)); + break; + + case tcc_unary: + /* Recursively stabilize each operand. */ + result + = build1 (code, type, + gnat_stabilize_reference_1 (TREE_OPERAND (e, 0), force)); + break; + + default: + gcc_unreachable (); + } + + /* See similar handling in gnat_stabilize_reference. */ + TREE_READONLY (result) = TREE_READONLY (e); + TREE_SIDE_EFFECTS (result) |= TREE_SIDE_EFFECTS (e); + TREE_THIS_VOLATILE (result) = TREE_THIS_VOLATILE (e); + + return result; +} + +/* This is equivalent to stabilize_reference in tree.c but we know how to + handle our own nodes and we take extra arguments. FORCE says whether to + force evaluation of everything. We set SUCCESS to true unless we walk + through something we don't know how to stabilize. */ + +tree +gnat_stabilize_reference (tree ref, bool force, bool *success) +{ + tree type = TREE_TYPE (ref); + enum tree_code code = TREE_CODE (ref); + tree result; + + /* Assume we'll success unless proven otherwise. */ + if (success) + *success = true; + + switch (code) + { + case CONST_DECL: + case VAR_DECL: + case PARM_DECL: + case RESULT_DECL: + /* No action is needed in this case. */ + return ref; + + case ADDR_EXPR: + CASE_CONVERT: + case FLOAT_EXPR: + case FIX_TRUNC_EXPR: + case VIEW_CONVERT_EXPR: + result + = build1 (code, type, + gnat_stabilize_reference (TREE_OPERAND (ref, 0), force, + success)); + break; + + case INDIRECT_REF: + case UNCONSTRAINED_ARRAY_REF: + result = build1 (code, type, + gnat_stabilize_reference_1 (TREE_OPERAND (ref, 0), + force)); + break; + + case COMPONENT_REF: + result = build3 (COMPONENT_REF, type, + gnat_stabilize_reference (TREE_OPERAND (ref, 0), force, + success), + TREE_OPERAND (ref, 1), NULL_TREE); + break; + + case BIT_FIELD_REF: + result = build3 (BIT_FIELD_REF, type, + gnat_stabilize_reference (TREE_OPERAND (ref, 0), force, + success), + gnat_stabilize_reference_1 (TREE_OPERAND (ref, 1), + force), + gnat_stabilize_reference_1 (TREE_OPERAND (ref, 2), + force)); + break; + + case ARRAY_REF: + case ARRAY_RANGE_REF: + result = build4 (code, type, + gnat_stabilize_reference (TREE_OPERAND (ref, 0), force, + success), + gnat_stabilize_reference_1 (TREE_OPERAND (ref, 1), + force), + NULL_TREE, NULL_TREE); + break; + + case CALL_EXPR: + case COMPOUND_EXPR: + result = gnat_stabilize_reference_1 (ref, force); + break; + + case CONSTRUCTOR: + /* Constructors with 1 element are used extensively to formally + convert objects to special wrapping types. */ + if (TREE_CODE (type) == RECORD_TYPE + && VEC_length (constructor_elt, CONSTRUCTOR_ELTS (ref)) == 1) + { + tree index + = VEC_index (constructor_elt, CONSTRUCTOR_ELTS (ref), 0)->index; + tree value + = VEC_index (constructor_elt, CONSTRUCTOR_ELTS (ref), 0)->value; + result + = build_constructor_single (type, index, + gnat_stabilize_reference_1 (value, + force)); + } + else + { + if (success) + *success = false; + return ref; + } + break; + + case ERROR_MARK: + ref = error_mark_node; + + /* ... fall through to failure ... */ + + /* If arg isn't a kind of lvalue we recognize, make no change. + Caller should recognize the error for an invalid lvalue. */ + default: + if (success) + *success = false; + return ref; + } + + /* TREE_THIS_VOLATILE and TREE_SIDE_EFFECTS set on the initial expression + may not be sustained across some paths, such as the way via build1 for + INDIRECT_REF. We reset those flags here in the general case, which is + consistent with the GCC version of this routine. + + Special care should be taken regarding TREE_SIDE_EFFECTS, because some + paths introduce side-effects where there was none initially (e.g. if a + SAVE_EXPR is built) and we also want to keep track of that. */ + TREE_READONLY (result) = TREE_READONLY (ref); + TREE_SIDE_EFFECTS (result) |= TREE_SIDE_EFFECTS (ref); + TREE_THIS_VOLATILE (result) = TREE_THIS_VOLATILE (ref); + + return result; +} -- cgit v1.2.1 From 3a701cae672f8f63a4472c34bae9f32975b9663b Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Sun, 11 Apr 2010 11:23:32 +0000 Subject: * gcc-interface/utils2.c (build_cond_expr): Take the address and dereference if the result type is passed by reference. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158201 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/gcc-interface/utils2.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'gcc/ada/gcc-interface/utils2.c') diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index a6ec65fd54d..29d60daf346 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -1291,10 +1291,12 @@ build_cond_expr (tree result_type, tree condition_operand, true_operand = convert (result_type, true_operand); false_operand = convert (result_type, false_operand); - /* If the result type is unconstrained, take the address of the operands - and then dereference our result. */ + /* If the result type is unconstrained, take the address of the operands and + then dereference the result. Likewise if the result type is passed by + reference because creating a temporary of this type is not allowed. */ if (TREE_CODE (result_type) == UNCONSTRAINED_ARRAY_TYPE - || CONTAINS_PLACEHOLDER_P (TYPE_SIZE (result_type))) + || CONTAINS_PLACEHOLDER_P (TYPE_SIZE (result_type)) + || (AGGREGATE_TYPE_P (result_type) && TYPE_BY_REFERENCE_P (result_type))) { result_type = build_pointer_type (result_type); true_operand = build_unary_op (ADDR_EXPR, result_type, true_operand); -- cgit v1.2.1 From c92ff1b0dc0734b64f6a653441c1b306d2782429 Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Sun, 11 Apr 2010 11:49:22 +0000 Subject: * gcc-interface/trans.c (lvalue_required_for_attribute_p): New static function. (lvalue_required_p) : Call it. (gnat_to_gnu) : Prevent build_component_ref from folding the result only if lvalue_required_for_attribute_p is true. * gcc-interface/utils.c (maybe_unconstrained_array): Pass correctly typed constant to build_component_ref. (unchecked_convert): Likewise. * gcc-interface/utils2.c (maybe_wrap_malloc): Likewise. (build_allocator): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158202 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/gcc-interface/utils2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc/ada/gcc-interface/utils2.c') diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index 29d60daf346..7d78c25ffba 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -1812,7 +1812,7 @@ maybe_wrap_malloc (tree data_size, tree data_type, Node_Id gnat_node) tree aligning_field = build_component_ref (aligning_record, NULL_TREE, - TYPE_FIELDS (aligning_type), 0); + TYPE_FIELDS (aligning_type), false); tree aligning_field_addr = build_unary_op (ADDR_EXPR, NULL_TREE, aligning_field); @@ -2003,7 +2003,7 @@ build_allocator (tree type, tree init, tree result_type, Entity_Id gnat_proc, build_component_ref (build_unary_op (INDIRECT_REF, NULL_TREE, convert (storage_ptr_type, storage)), - NULL_TREE, TYPE_FIELDS (storage_type), 0), + NULL_TREE, TYPE_FIELDS (storage_type), false), build_template (template_type, type, NULL_TREE)), convert (result_type, convert (storage_ptr_type, storage))); } -- cgit v1.2.1 From e568189fbcf2b6e91fd5928a44498540fe2ed5a8 Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Tue, 13 Apr 2010 07:08:24 +0000 Subject: * gimple.c (walk_gimple_op) : Do not request a pure rvalue on the RHS if the LHS is of a non-renamable type. * tree-ssa-ccp.c (maybe_fold_offset_to_component_ref): Fold result. ada/ * gcc-interface/ada-tree.h (TYPE_BY_REFERENCE_P): Delete. (DECL_CONST_ADDRESS_P): New macro. (SET_DECL_ORIGINAL_FIELD_TO_FIELD): Likewise. (SAME_FIELD_P): Likewise. * gcc-interface/decl.c (constructor_address_p): New static function. (gnat_to_gnu_entity) : Set DECL_CONST_ADDRESS_P according to the return value of above function. (gnat_to_gnu_entity) : Force BLKmode for all types passed by reference. : Likewise. Set TREE_ADDRESSABLE on the type if it passed by reference. (make_packable_type): Use SET_DECL_ORIGINAL_FIELD_TO_FIELD. (create_field_decl_from): Likewise. (substitute_in_type): Likewise. (purpose_member_field): Use SAME_FIELD_P. * gcc-interface/misc.c (must_pass_by_ref): Test TREE_ADDRESSABLE. * gcc-interface/trans.c (lvalue_required_p): Add ADDRESS_OF_CONSTANT parameter and adjust recursive calls. : New case. : Return 1 if the object is of a class-wide type. Adjust calls to lvalue_required_p. Do not return the initializer of a DECL_CONST_ADDRESS_P constant if an lvalue is required for it. (call_to_gnu): Delay issuing error message for a misaligned actual and avoid the associated back-end assertion. Test TREE_ADDRESSABLE. (gnat_gimplify_expr) : Handle non-static constructors. * gcc-interface/utils.c (make_dummy_type): Set TREE_ADDRESSABLE if the type is passed by reference. (convert) : Convert in-place in more cases. * gcc-interface/utils2.c (build_cond_expr): Drop TYPE_BY_REFERENCE_P. (build_simple_component_ref): Use SAME_FIELD_P. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158254 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/gcc-interface/utils2.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'gcc/ada/gcc-interface/utils2.c') diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index 7d78c25ffba..dbe83ed7ff8 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -1293,10 +1293,9 @@ build_cond_expr (tree result_type, tree condition_operand, /* If the result type is unconstrained, take the address of the operands and then dereference the result. Likewise if the result type is passed by - reference because creating a temporary of this type is not allowed. */ + reference, but this is natively handled in the gimplifier. */ if (TREE_CODE (result_type) == UNCONSTRAINED_ARRAY_TYPE - || CONTAINS_PLACEHOLDER_P (TYPE_SIZE (result_type)) - || (AGGREGATE_TYPE_P (result_type) && TYPE_BY_REFERENCE_P (result_type))) + || CONTAINS_PLACEHOLDER_P (TYPE_SIZE (result_type))) { result_type = build_pointer_type (result_type); true_operand = build_unary_op (ADDR_EXPR, result_type, true_operand); @@ -1588,22 +1587,15 @@ build_simple_component_ref (tree record_variable, tree component, tree new_field; /* First loop thru normal components. */ - for (new_field = TYPE_FIELDS (record_type); new_field; new_field = TREE_CHAIN (new_field)) - if (field == new_field - || DECL_ORIGINAL_FIELD (new_field) == field - || new_field == DECL_ORIGINAL_FIELD (field) - || (DECL_ORIGINAL_FIELD (field) - && (DECL_ORIGINAL_FIELD (field) - == DECL_ORIGINAL_FIELD (new_field)))) + if (SAME_FIELD_P (field, new_field)) break; /* Next, loop thru DECL_INTERNAL_P components if we haven't found the component in the first search. Doing this search in 2 steps is required to avoiding hidden homonymous fields in the _Parent field. */ - if (!new_field) for (new_field = TYPE_FIELDS (record_type); new_field; new_field = TREE_CHAIN (new_field)) -- cgit v1.2.1 From 7301bf0b4e62bb6010da7dcda048963a0f878f1e Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Thu, 15 Apr 2010 12:40:15 +0000 Subject: * gcc-interface/trans.c (call_to_gnu): Open a nesting level if this is a statement. Otherwise, if at top-level, push the processing of the elaboration routine. In the misaligned case, issue the error messages again on entry and create the temporary explicitly. Do not issue them for CONSTRUCTORs. For a function call, emit the range check if necessary. In the copy-in copy-out case, create the temporary for the return value explicitly. Do not unnecessarily convert by-ref parameters to the formal's type. Remove obsolete guards in conditions. (gnat_to_gnu) : For a function call, pass the target to call_to_gnu in all cases. (gnat_gimplify_expr) : Remove handling of SAVE_EXPR. (addressable_p) : Return false if not static. : New case. * gcc-interface/utils2.c (build_unary_op) : Fold a compound expression if it has unconstrained array type. (gnat_mark_addressable) : New case. (gnat_stabilize_reference) : Stabilize operands on an individual basis. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158371 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/gcc-interface/utils2.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'gcc/ada/gcc-interface/utils2.c') diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index dbe83ed7ff8..82575072852 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -1025,6 +1025,22 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) TREE_TYPE (result) = type = build_pointer_type (type); break; + case COMPOUND_EXPR: + /* Fold a compound expression if it has unconstrained array type + since the middle-end cannot handle it. But we don't it in the + general case because it may introduce aliasing issues if the + first operand is an indirect assignment and the second operand + the corresponding address, e.g. for an allocator. */ + if (TREE_CODE (type) == UNCONSTRAINED_ARRAY_TYPE) + { + result = build_unary_op (ADDR_EXPR, result_type, + TREE_OPERAND (operand, 1)); + result = build2 (COMPOUND_EXPR, TREE_TYPE (result), + TREE_OPERAND (operand, 0), result); + break; + } + goto common; + case ARRAY_REF: case ARRAY_RANGE_REF: case COMPONENT_REF: @@ -2119,6 +2135,10 @@ gnat_mark_addressable (tree t) t = TREE_OPERAND (t, 0); break; + case COMPOUND_EXPR: + t = TREE_OPERAND (t, 1); + break; + case CONSTRUCTOR: TREE_ADDRESSABLE (t) = 1; return true; @@ -2377,10 +2397,17 @@ gnat_stabilize_reference (tree ref, bool force, bool *success) break; case CALL_EXPR: - case COMPOUND_EXPR: result = gnat_stabilize_reference_1 (ref, force); break; + case COMPOUND_EXPR: + result = build2 (COMPOUND_EXPR, type, + gnat_stabilize_reference (TREE_OPERAND (ref, 0), force, + success), + gnat_stabilize_reference_1 (TREE_OPERAND (ref, 1), + force)); + break; + case CONSTRUCTOR: /* Constructors with 1 element are used extensively to formally convert objects to special wrapping types. */ -- cgit v1.2.1 From c7adf5b483731253e529fa1baa99f9bdc57dac9a Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Thu, 15 Apr 2010 20:21:08 +0000 Subject: * gcc-interface/trans.c (gigi): Set DECL_IGNORED_P on EH functions. (gnat_to_gnu) : Restore the value of input_location before translating the top-level node. (lvalue_required_p) : Return 1 if !constant. : Likewise. : Likewise. : Likewise. (call_to_gnu): Remove kludge. (gnat_to_gnu) : When not optimizing, force labels associated with user returns to be preserved. (gnat_to_gnu): Add special code to deal with boolean rvalues. * gcc-interface/utils2.c (compare_arrays): Set input_location on all comparisons. (build_unary_op) : Call build_fold_addr_expr. : Call build_fold_indirect_ref. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158388 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/gcc-interface/utils2.c | 47 ++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 15 deletions(-) (limited to 'gcc/ada/gcc-interface/utils2.c') diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index 82575072852..3a5b9620586 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -303,6 +303,9 @@ compare_arrays (tree result_type, tree a1, tree a2) comparison = build_binary_op (LT_EXPR, result_type, ub, lb); comparison = SUBSTITUTE_PLACEHOLDER_IN_EXPR (comparison, a1); + if (EXPR_P (comparison)) + SET_EXPR_LOCATION (comparison, input_location); + length1 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (length1, a1); length_zero_p = true; @@ -317,6 +320,8 @@ compare_arrays (tree result_type, tree a1, tree a2) { ub1 = TYPE_MAX_VALUE (TYPE_INDEX_TYPE (TYPE_DOMAIN (t1))); lb1 = TYPE_MIN_VALUE (TYPE_INDEX_TYPE (TYPE_DOMAIN (t1))); + /* Note that we know that UB2 and LB2 are constant and hence + cannot contain a PLACEHOLDER_EXPR. */ ub2 = TYPE_MAX_VALUE (TYPE_INDEX_TYPE (TYPE_DOMAIN (t2))); lb2 = TYPE_MIN_VALUE (TYPE_INDEX_TYPE (TYPE_DOMAIN (t2))); nbt = get_base_type (TREE_TYPE (ub1)); @@ -325,14 +330,15 @@ compare_arrays (tree result_type, tree a1, tree a2) = build_binary_op (EQ_EXPR, result_type, build_binary_op (MINUS_EXPR, nbt, ub1, lb1), build_binary_op (MINUS_EXPR, nbt, ub2, lb2)); - - /* Note that we know that UB2 and LB2 are constant and hence - cannot contain a PLACEHOLDER_EXPR. */ - comparison = SUBSTITUTE_PLACEHOLDER_IN_EXPR (comparison, a1); + if (EXPR_P (comparison)) + SET_EXPR_LOCATION (comparison, input_location); + length1 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (length1, a1); this_a1_is_null = build_binary_op (LT_EXPR, result_type, ub1, lb1); + if (EXPR_P (this_a1_is_null)) + SET_EXPR_LOCATION (this_a1_is_null, input_location); this_a2_is_null = convert (result_type, integer_zero_node); } @@ -344,13 +350,20 @@ compare_arrays (tree result_type, tree a1, tree a2) comparison = build_binary_op (EQ_EXPR, result_type, length1, length2); + if (EXPR_P (comparison)) + SET_EXPR_LOCATION (comparison, input_location); this_a1_is_null = build_binary_op (LT_EXPR, result_type, length1, convert (bt, integer_zero_node)); + if (EXPR_P (this_a1_is_null)) + SET_EXPR_LOCATION (this_a1_is_null, input_location); + this_a2_is_null = build_binary_op (LT_EXPR, result_type, length2, convert (bt, integer_zero_node)); + if (EXPR_P (this_a2_is_null)) + SET_EXPR_LOCATION (this_a2_is_null, input_location); } result = build_binary_op (TRUTH_ANDIF_EXPR, result_type, @@ -370,6 +383,7 @@ compare_arrays (tree result_type, tree a1, tree a2) if (!length_zero_p) { tree type = find_common_type (TREE_TYPE (a1), TREE_TYPE (a2)); + tree comparison; if (type) { @@ -377,8 +391,12 @@ compare_arrays (tree result_type, tree a1, tree a2) a2 = convert (type, a2); } - result = build_binary_op (TRUTH_ANDIF_EXPR, result_type, result, - fold_build2 (EQ_EXPR, result_type, a1, a2)); + comparison = fold_build2 (EQ_EXPR, result_type, a1, a2); + if (EXPR_P (comparison)) + SET_EXPR_LOCATION (comparison, input_location); + + result + = build_binary_op (TRUTH_ANDIF_EXPR, result_type, result, comparison); } /* The result is also true if both sizes are zero. */ @@ -1153,21 +1171,17 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) operand = convert (type, operand); } - if (type != error_mark_node) - operation_type = build_pointer_type (type); - gnat_mark_addressable (operand); - result = fold_build1 (ADDR_EXPR, operation_type, operand); + result = build_fold_addr_expr (operand); } TREE_CONSTANT (result) = staticp (operand) || TREE_CONSTANT (operand); break; case INDIRECT_REF: - /* If we want to refer to an entire unconstrained array, - make up an expression to do so. This will never survive to - the backend. If TYPE is a thin pointer, first convert the - operand to a fat pointer. */ + /* If we want to refer to an unconstrained array, use the appropriate + expression to do so. This will never survive down to the back-end. + But if TYPE is a thin pointer, first convert to a fat pointer. */ if (TYPE_IS_THIN_POINTER_P (type) && TYPE_UNCONSTRAINED_ARRAY (TREE_TYPE (type))) { @@ -1184,12 +1198,15 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) TREE_READONLY (result) = TYPE_READONLY (TYPE_UNCONSTRAINED_ARRAY (type)); } + + /* If we are dereferencing an ADDR_EXPR, return its operand. */ else if (TREE_CODE (operand) == ADDR_EXPR) result = TREE_OPERAND (operand, 0); + /* Otherwise, build and fold the indirect reference. */ else { - result = fold_build1 (op_code, TREE_TYPE (type), operand); + result = build_fold_indirect_ref (operand); TREE_READONLY (result) = TYPE_READONLY (TREE_TYPE (type)); } -- cgit v1.2.1 From ac45dde2731ceeb2cfdf1cbe927dadd6bd6b6307 Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Thu, 15 Apr 2010 21:15:47 +0000 Subject: * gcc-interface/cuintp.c (UI_To_gnu): Fix long line. * gcc-interface/gigi.h (MARK_VISITED): Skip objects of constant class. (process_attributes): Delete. (post_error_ne_num): Change parameter name. * gcc-interface/decl.c (gnat_to_gnu_entity): Do not force debug info with -g3. Remove a couple of obsolete lines. Minor tweaks. If type annotating mode, operate on trees to compute the adjustment to the sizes of tagged types. Fix long line. (cannot_be_superflat_p): Tweak head comment. (annotate_value): Fold local constant. (set_rm_size): Fix long line. * gcc-interface/trans.c (Identifier_to_gnu): Rework comments. (Attribute_to_gnu): Fix long line. : Remove useless assertion. Reorder statements. Use size_binop routine. (Loop_Statement_to_gnu): Use build5 in lieu of build_nt. Create local variables for the label and the test. Tweak comments. (Subprogram_Body_to_gnu): Reset cfun to NULL. (Compilation_Unit_to_gnu): Use the Sloc of the Unit node. (process_inlined_subprograms): Integrate into... (Compilation_Unit_to_gnu): ...this. (gnat_to_gnu): Fix long line. (post_error_ne_num): Change parameter name. * gcc-interface/utils.c (process_attributes): Static-ify. : Set input_location before proceeding. (create_type_decl): Add comment. (create_var_decl_1): Process the attributes after adding the VAR_DECL to the current binding level. (create_subprog_decl): Likewise for the FUNCTION_DECL. (end_subprog_body): Do not reset cfun to NULL. (build_vms_descriptor32): Fix long line. (build_vms_descriptor): Likewise. (handle_nonnull_attribute): Likewise. (convert_vms_descriptor64): Likewise. * gcc-interface/utils2.c (fill_vms_descriptor): Fix long line. (gnat_protect_expr): Fix thinko. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158390 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/gcc-interface/utils2.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'gcc/ada/gcc-interface/utils2.c') diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index 3a5b9620586..b6bd268feee 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -2121,7 +2121,8 @@ fill_vms_descriptor (tree expr, Entity_Id gnat_formal, Node_Id gnat_actual) convert (long_integer_type_node, addr64expr), malloc64low), - build_call_raise (CE_Range_Check_Failed, gnat_actual, + build_call_raise (CE_Range_Check_Failed, + gnat_actual, N_Raise_Constraint_Error), NULL_TREE)); } @@ -2228,9 +2229,12 @@ gnat_protect_expr (tree exp) unshared for gimplification; in order to avoid a complexity explosion at that point, we protect any expressions more complex than a simple arithmetic expression. */ - if (!TREE_SIDE_EFFECTS (exp) - && !EXPRESSION_CLASS_P (skip_simple_arithmetic (exp))) - return exp; + if (!TREE_SIDE_EFFECTS (exp)) + { + tree inner = skip_simple_arithmetic (exp); + if (!EXPR_P (inner) || REFERENCE_CLASS_P (inner)) + return exp; + } /* If this is a conversion, protect what's inside the conversion. */ if (code == NON_LVALUE_EXPR -- cgit v1.2.1 From d243069c4137f2baa717a2aa1863fa238d204709 Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Fri, 16 Apr 2010 12:07:02 +0000 Subject: * gcc-interface/decl.c (gnat_to_gnu_entity): Use boolean_type_node in lieu of integer_type_node for boolean operations. (choices_to_gnu): Likewise. * gcc-interface/trans.c (Attribute_to_gnu): Likewise. (Loop_Statement_to_gnu): Likewise. (establish_gnat_vms_condition_handler): Likewise. (Exception_Handler_to_gnu_sjlj): Likewise. (gnat_to_gnu): Likewise. (build_unary_op_trapv): Likewise. (build_binary_op_trapv): Likewise. (emit_range_check): Likewise. (emit_index_check): Likewise. (convert_with_check): Likewise. * gcc-interface/utils.c (convert_vms_descriptor64): Likewise. (convert_vms_descriptor32): Likewise. (convert_vms_descriptor): Likewise. * gcc-interface/utils2.c (nonbinary_modular_operation): Likewise. (compare_arrays): Use boolean instead of integer constants. (build_binary_op) : New case. Check that the result type is a boolean type. : Remove obsolete assertion. : Check that the result type is a boolean type. : Delete. : Check that the result type is a boolean type. (build_unary_op): Use boolean_type_node in lieu of integer_type_node for boolean operations. (fill_vms_descriptor): Likewise. Fix formatting nits. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158411 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/gcc-interface/utils2.c | 72 +++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 33 deletions(-) (limited to 'gcc/ada/gcc-interface/utils2.c') diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index b6bd268feee..33f3a613f60 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -242,11 +242,11 @@ find_common_type (tree t1, tree t2) static tree compare_arrays (tree result_type, tree a1, tree a2) { + tree result = convert (result_type, boolean_true_node); + tree a1_is_null = convert (result_type, boolean_false_node); + tree a2_is_null = convert (result_type, boolean_false_node); tree t1 = TREE_TYPE (a1); tree t2 = TREE_TYPE (a2); - tree result = convert (result_type, integer_one_node); - tree a1_is_null = convert (result_type, integer_zero_node); - tree a2_is_null = convert (result_type, integer_zero_node); bool a1_side_effects_p = TREE_SIDE_EFFECTS (a1); bool a2_side_effects_p = TREE_SIDE_EFFECTS (a2); bool length_zero_p = false; @@ -310,7 +310,7 @@ compare_arrays (tree result_type, tree a1, tree a2) length_zero_p = true; this_a1_is_null = comparison; - this_a2_is_null = convert (result_type, integer_one_node); + this_a2_is_null = convert (result_type, boolean_true_node); } /* If the length is some other constant value, we know that the @@ -339,7 +339,7 @@ compare_arrays (tree result_type, tree a1, tree a2) this_a1_is_null = build_binary_op (LT_EXPR, result_type, ub1, lb1); if (EXPR_P (this_a1_is_null)) SET_EXPR_LOCATION (this_a1_is_null, input_location); - this_a2_is_null = convert (result_type, integer_zero_node); + this_a2_is_null = convert (result_type, boolean_false_node); } /* Otherwise compare the computed lengths. */ @@ -491,7 +491,7 @@ nonbinary_modular_operation (enum tree_code op_code, tree type, tree lhs, { result = gnat_protect_expr (result); result = fold_build3 (COND_EXPR, op_type, - fold_build2 (LT_EXPR, integer_type_node, result, + fold_build2 (LT_EXPR, boolean_type_node, result, convert (op_type, integer_zero_node)), fold_build2 (PLUS_EXPR, op_type, result, modulus), result); @@ -502,7 +502,7 @@ nonbinary_modular_operation (enum tree_code op_code, tree type, tree lhs, { result = gnat_protect_expr (result); result = fold_build3 (COND_EXPR, op_type, - fold_build2 (GE_EXPR, integer_type_node, + fold_build2 (GE_EXPR, boolean_type_node, result, modulus), fold_build2 (MINUS_EXPR, op_type, result, modulus), @@ -716,16 +716,28 @@ build_binary_op (enum tree_code op_code, tree result_type, modulus = NULL_TREE; break; + case TRUTH_ANDIF_EXPR: + case TRUTH_ORIF_EXPR: + case TRUTH_AND_EXPR: + case TRUTH_OR_EXPR: + case TRUTH_XOR_EXPR: +#ifdef ENABLE_CHECKING + gcc_assert (TREE_CODE (get_base_type (result_type)) == BOOLEAN_TYPE); +#endif + operation_type = left_base_type; + left_operand = convert (operation_type, left_operand); + right_operand = convert (operation_type, right_operand); + break; + case GE_EXPR: case LE_EXPR: case GT_EXPR: case LT_EXPR: - gcc_assert (!POINTER_TYPE_P (left_type)); - - /* ... fall through ... */ - case EQ_EXPR: case NE_EXPR: +#ifdef ENABLE_CHECKING + gcc_assert (TREE_CODE (get_base_type (result_type)) == BOOLEAN_TYPE); +#endif /* If either operand is a NULL_EXPR, just return a new one. */ if (TREE_CODE (left_operand) == NULL_EXPR) return build2 (op_code, result_type, @@ -842,13 +854,6 @@ build_binary_op (enum tree_code op_code, tree result_type, modulus = NULL_TREE; break; - case PREINCREMENT_EXPR: - case PREDECREMENT_EXPR: - case POSTINCREMENT_EXPR: - case POSTDECREMENT_EXPR: - /* These operations are not used anymore. */ - gcc_unreachable (); - case LSHIFT_EXPR: case RSHIFT_EXPR: case LROTATE_EXPR: @@ -1001,7 +1006,9 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) break; case TRUTH_NOT_EXPR: - gcc_assert (result_type == base_type); +#ifdef ENABLE_CHECKING + gcc_assert (TREE_CODE (get_base_type (result_type)) == BOOLEAN_TYPE); +#endif result = invert_truthvalue (operand); break; @@ -1259,7 +1266,7 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) result = fold_build3 (COND_EXPR, operation_type, fold_build2 (NE_EXPR, - integer_type_node, + boolean_type_node, operand, convert (operation_type, @@ -2088,12 +2095,11 @@ build_allocator (tree type, tree init, tree result_type, Entity_Id gnat_proc, tree fill_vms_descriptor (tree expr, Entity_Id gnat_formal, Node_Id gnat_actual) { - tree field; tree parm_decl = get_gnu_tree (gnat_formal); - tree const_list = NULL_TREE; tree record_type = TREE_TYPE (TREE_TYPE (parm_decl)); - int do_range_check = - strcmp ("MBO", + tree const_list = NULL_TREE, field; + const bool do_range_check + = strcmp ("MBO", IDENTIFIER_POINTER (DECL_NAME (TYPE_FIELDS (record_type)))); expr = maybe_unconstrained_array (expr); @@ -2105,19 +2111,19 @@ fill_vms_descriptor (tree expr, Entity_Id gnat_formal, Node_Id gnat_actual) SUBSTITUTE_PLACEHOLDER_IN_EXPR (DECL_INITIAL (field), expr)); - /* Check to ensure that only 32bit pointers are passed in - 32bit descriptors */ - if (do_range_check && - strcmp (IDENTIFIER_POINTER (DECL_NAME (field)), "POINTER") == 0) + /* Check to ensure that only 32-bit pointers are passed in + 32-bit descriptors */ + if (do_range_check + && strcmp (IDENTIFIER_POINTER (DECL_NAME (field)), "POINTER") == 0) { - tree pointer64type = - build_pointer_type_for_mode (void_type_node, DImode, false); + tree pointer64type + = build_pointer_type_for_mode (void_type_node, DImode, false); tree addr64expr = build_unary_op (ADDR_EXPR, pointer64type, expr); - tree malloc64low = - build_int_cstu (long_integer_type_node, 0x80000000); + tree malloc64low + = build_int_cstu (long_integer_type_node, 0x80000000); add_stmt (build3 (COND_EXPR, void_type_node, - build_binary_op (GE_EXPR, long_integer_type_node, + build_binary_op (GE_EXPR, boolean_type_node, convert (long_integer_type_node, addr64expr), malloc64low), -- cgit v1.2.1 From 3fa661c420a097dd38a7a231c5df9b0a8b8a28ec Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Sat, 17 Apr 2010 08:14:08 +0000 Subject: * gcc-interface/gigi.h (enum standard_datatypes): Add new values ADT_sbitsize_one_node and ADT_sbitsize_unit_node. (sbitsize_one_node): New macro. (sbitsize_unit_node): Likewise. * gcc-interface/decl.c (gnat_to_gnu_entity) : Fix latent bug in the computation of subrange_p. Fold wider_p predicate. (cannot_be_superflat_p): Use an explicitly signed 64-bit type to do the final comparison. (make_aligning_type): Build real negation and use sizetype throughout the offset computation. (maybe_pad_type): Do not issue the warning when the new size expression is too complex. (annotate_value) : Simplify code handling negative values. * gcc-interface/misc.c (gnat_init): Initialize sbitsize_one_node and sbitsize_unit_node. * gcc-interface/trans.c (Attribute_to_gnu) : Fold double negation. (gnat_to_gnu) : Likewise. * gcc-interface/utils.c (convert): Use sbitsize_unit_node. * gcc-interface/utils2.c (compare_arrays): Compute real lengths and use constants in sizetype. Remove dead code and tweak comments. Generate equality instead of inequality comparisons for zero length tests. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158461 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/gcc-interface/utils2.c | 76 ++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 39 deletions(-) (limited to 'gcc/ada/gcc-interface/utils2.c') diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index 33f3a613f60..ca35cc7458a 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -260,28 +260,27 @@ compare_arrays (tree result_type, tree a1, tree a2) a2 = gnat_protect_expr (a2); /* Process each dimension separately and compare the lengths. If any - dimension has a size known to be zero, set SIZE_ZERO_P to 1 to - suppress the comparison of the data. */ + dimension has a length known to be zero, set LENGTH_ZERO_P to true + in order to suppress the comparison of the data at the end. */ while (TREE_CODE (t1) == ARRAY_TYPE && TREE_CODE (t2) == ARRAY_TYPE) { tree lb1 = TYPE_MIN_VALUE (TYPE_DOMAIN (t1)); tree ub1 = TYPE_MAX_VALUE (TYPE_DOMAIN (t1)); tree lb2 = TYPE_MIN_VALUE (TYPE_DOMAIN (t2)); tree ub2 = TYPE_MAX_VALUE (TYPE_DOMAIN (t2)); - tree bt = get_base_type (TREE_TYPE (lb1)); - tree length1 = fold_build2 (MINUS_EXPR, bt, ub1, lb1); - tree length2 = fold_build2 (MINUS_EXPR, bt, ub2, lb2); + tree length1 = size_binop (PLUS_EXPR, size_binop (MINUS_EXPR, ub1, lb1), + size_one_node); + tree length2 = size_binop (PLUS_EXPR, size_binop (MINUS_EXPR, ub2, lb2), + size_one_node); tree comparison, this_a1_is_null, this_a2_is_null; - tree nbt, tem; - bool btem; /* If the length of the first array is a constant, swap our operands - unless the length of the second array is the constant zero. - Note that we have set the `length' values to the length - 1. */ - if (TREE_CODE (length1) == INTEGER_CST - && !integer_zerop (fold_build2 (PLUS_EXPR, bt, length2, - convert (bt, integer_one_node)))) + unless the length of the second array is the constant zero. */ + if (TREE_CODE (length1) == INTEGER_CST && !integer_zerop (length2)) { + tree tem; + bool btem; + tem = a1, a1 = a2, a2 = tem; tem = t1, t1 = t2, t2 = tem; tem = lb1, lb1 = lb2, lb2 = tem; @@ -292,57 +291,56 @@ compare_arrays (tree result_type, tree a1, tree a2) a2_side_effects_p = btem; } - /* If the length of this dimension in the second array is the constant - zero, we can just go inside the original bounds for the first - array and see if last < first. */ - if (integer_zerop (fold_build2 (PLUS_EXPR, bt, length2, - convert (bt, integer_one_node)))) + /* If the length of the second array is the constant zero, we can just + use the original stored bounds for the first array and see whether + last < first holds. */ + if (integer_zerop (length2)) { - tree ub = TYPE_MAX_VALUE (TYPE_INDEX_TYPE (TYPE_DOMAIN (t1))); - tree lb = TYPE_MIN_VALUE (TYPE_INDEX_TYPE (TYPE_DOMAIN (t1))); + length_zero_p = true; - comparison = build_binary_op (LT_EXPR, result_type, ub, lb); + ub1 = TYPE_MAX_VALUE (TYPE_INDEX_TYPE (TYPE_DOMAIN (t1))); + lb1 = TYPE_MIN_VALUE (TYPE_INDEX_TYPE (TYPE_DOMAIN (t1))); + + comparison = build_binary_op (LT_EXPR, result_type, ub1, lb1); comparison = SUBSTITUTE_PLACEHOLDER_IN_EXPR (comparison, a1); if (EXPR_P (comparison)) SET_EXPR_LOCATION (comparison, input_location); - length1 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (length1, a1); - - length_zero_p = true; this_a1_is_null = comparison; this_a2_is_null = convert (result_type, boolean_true_node); } - /* If the length is some other constant value, we know that the - this dimension in the first array cannot be superflat, so we - can just use its length from the actual stored bounds. */ + /* Otherwise, if the length is some other constant value, we know that + this dimension in the second array cannot be superflat, so we can + just use its length computed from the actual stored bounds. */ else if (TREE_CODE (length2) == INTEGER_CST) { + tree bt; + ub1 = TYPE_MAX_VALUE (TYPE_INDEX_TYPE (TYPE_DOMAIN (t1))); lb1 = TYPE_MIN_VALUE (TYPE_INDEX_TYPE (TYPE_DOMAIN (t1))); /* Note that we know that UB2 and LB2 are constant and hence cannot contain a PLACEHOLDER_EXPR. */ ub2 = TYPE_MAX_VALUE (TYPE_INDEX_TYPE (TYPE_DOMAIN (t2))); lb2 = TYPE_MIN_VALUE (TYPE_INDEX_TYPE (TYPE_DOMAIN (t2))); - nbt = get_base_type (TREE_TYPE (ub1)); + bt = get_base_type (TREE_TYPE (ub1)); comparison = build_binary_op (EQ_EXPR, result_type, - build_binary_op (MINUS_EXPR, nbt, ub1, lb1), - build_binary_op (MINUS_EXPR, nbt, ub2, lb2)); + build_binary_op (MINUS_EXPR, bt, ub1, lb1), + build_binary_op (MINUS_EXPR, bt, ub2, lb2)); comparison = SUBSTITUTE_PLACEHOLDER_IN_EXPR (comparison, a1); if (EXPR_P (comparison)) SET_EXPR_LOCATION (comparison, input_location); - length1 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (length1, a1); - this_a1_is_null = build_binary_op (LT_EXPR, result_type, ub1, lb1); if (EXPR_P (this_a1_is_null)) SET_EXPR_LOCATION (this_a1_is_null, input_location); + this_a2_is_null = convert (result_type, boolean_false_node); } - /* Otherwise compare the computed lengths. */ + /* Otherwise, compare the computed lengths. */ else { length1 = SUBSTITUTE_PLACEHOLDER_IN_EXPR (length1, a1); @@ -353,24 +351,24 @@ compare_arrays (tree result_type, tree a1, tree a2) if (EXPR_P (comparison)) SET_EXPR_LOCATION (comparison, input_location); - this_a1_is_null - = build_binary_op (LT_EXPR, result_type, length1, - convert (bt, integer_zero_node)); + this_a1_is_null = build_binary_op (EQ_EXPR, result_type, length1, + size_zero_node); if (EXPR_P (this_a1_is_null)) SET_EXPR_LOCATION (this_a1_is_null, input_location); - this_a2_is_null - = build_binary_op (LT_EXPR, result_type, length2, - convert (bt, integer_zero_node)); + this_a2_is_null = build_binary_op (EQ_EXPR, result_type, length2, + size_zero_node); if (EXPR_P (this_a2_is_null)) SET_EXPR_LOCATION (this_a2_is_null, input_location); } + /* Append expressions for this dimension to the final expressions. */ result = build_binary_op (TRUTH_ANDIF_EXPR, result_type, result, comparison); a1_is_null = build_binary_op (TRUTH_ORIF_EXPR, result_type, this_a1_is_null, a1_is_null); + a2_is_null = build_binary_op (TRUTH_ORIF_EXPR, result_type, this_a2_is_null, a2_is_null); @@ -378,7 +376,7 @@ compare_arrays (tree result_type, tree a1, tree a2) t2 = TREE_TYPE (t2); } - /* Unless the size of some bound is known to be zero, compare the + /* Unless the length of some dimension is known to be zero, compare the data in the array. */ if (!length_zero_p) { -- cgit v1.2.1 From 526c98579389dee0c99901aea0c1030761f83797 Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Sat, 17 Apr 2010 08:24:16 +0000 Subject: * back-end.adb (Call_Back_End): Pass Standard_Character to gigi. * gcc-interface/gigi.h (gigi): Add standard_character parameter. (CHAR_TYPE_SIZE, SHORT_TYPE_SIZE, INT_TYPE_SIZE, LONG_TYPE_SIZE, LONG_LONG_TYPE_SIZE, FLOAT_TYPE_SIZE, DOUBLE_TYPE_SIZE, LONG_DOUBLE_TYPE_SIZE, SIZE_TYPE): Delete. * gcc-interface/decl.c (gnat_to_gnu_entity) : Call rm_size. * gcc-interface/misc.c (gnat_init): Set signedness of char as per flag_signed_char. Tag sizetype with "size_type" moniker. * gcc-interface/trans.c (gigi): Add standard_character parameter. Remove useless built-in types. Equate unsigned_char_type_node to Standard.Character. Use it instead of char_type_node throughout. (Attribute_to_gnu): Likewise. (gnat_to_gnu): Likewise. * gcc-interface/utils2.c (build_call_raise): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158462 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/gcc-interface/utils2.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'gcc/ada/gcc-interface/utils2.c') diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index ca35cc7458a..be7044bddfa 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -1499,12 +1499,13 @@ build_call_raise (int msg, Node_Id gnat_node, char kind) = (gnat_node != Empty && Sloc (gnat_node) != No_Location) ? Get_Logical_Line_Number (Sloc(gnat_node)) : input_line; - TREE_TYPE (filename) - = build_array_type (char_type_node, build_index_type (size_int (len))); + TREE_TYPE (filename) = build_array_type (unsigned_char_type_node, + build_index_type (size_int (len))); return build_call_2_expr (fndecl, - build1 (ADDR_EXPR, build_pointer_type (char_type_node), + build1 (ADDR_EXPR, + build_pointer_type (unsigned_char_type_node), filename), build_int_cst (NULL_TREE, line_number)); } -- cgit v1.2.1 From 3e70070e2728b17a16ceef391b6c74911db31065 Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Sat, 17 Apr 2010 14:16:36 +0000 Subject: * uintp.h (UI_Lt): Declare. * gcc-interface/decl.c (gnat_to_gnu_entity) : Do the size computation in sizetype. : Use unified handling for all index types. Do not generate MAX_EXPR-based expressions, only COND_EXPR-based ones. Add bypass for PATs. (annotate_value): Change test for negative values. (validate_size): Apply test for negative values on GNAT nodes. (set_rm_size): Likewise. * gcc-interface/misc.c (gnat_init): Set unsigned types for sizetypes. * gcc-interface/utils.c (rest_of_record_type_compilation): Change test for negative values. (max_size) : Do not reassociate a COND_EXPR on the LHS. (builtin_type_for_size): Adjust definition of signed_size_type_node. * gcc-interface/utils2.c (compare_arrays): Optimize comparison of lengths against zero. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158466 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/gcc-interface/utils2.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'gcc/ada/gcc-interface/utils2.c') diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index be7044bddfa..31c513699af 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -351,14 +351,26 @@ compare_arrays (tree result_type, tree a1, tree a2) if (EXPR_P (comparison)) SET_EXPR_LOCATION (comparison, input_location); - this_a1_is_null = build_binary_op (EQ_EXPR, result_type, length1, - size_zero_node); - if (EXPR_P (this_a1_is_null)) + /* If the length expression is of the form (cond ? val : 0), assume + that cond is equivalent to (length != 0). That's guaranteed by + construction of the array types in gnat_to_gnu_entity. */ + if (TREE_CODE (length1) == COND_EXPR + && integer_zerop (TREE_OPERAND (length1, 2))) + this_a1_is_null = invert_truthvalue (TREE_OPERAND (length1, 0)); + else + this_a1_is_null = build_binary_op (EQ_EXPR, result_type, length1, + size_zero_node); + if (EXPR_P (this_a1_is_null)) SET_EXPR_LOCATION (this_a1_is_null, input_location); - this_a2_is_null = build_binary_op (EQ_EXPR, result_type, length2, - size_zero_node); - if (EXPR_P (this_a2_is_null)) + /* Likewise for the second array. */ + if (TREE_CODE (length2) == COND_EXPR + && integer_zerop (TREE_OPERAND (length2, 2))) + this_a2_is_null = invert_truthvalue (TREE_OPERAND (length2, 0)); + else + this_a2_is_null = build_binary_op (EQ_EXPR, result_type, length2, + size_zero_node); + if (EXPR_P (this_a2_is_null)) SET_EXPR_LOCATION (this_a2_is_null, input_location); } -- cgit v1.2.1 From f39b90606c3c2bbaa6c975a629a4d2633198fb66 Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Sat, 17 Apr 2010 14:53:08 +0000 Subject: * gcc-interface/utils2.c (build_unary_op) : Do not issue warning. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158469 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/gcc-interface/utils2.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'gcc/ada/gcc-interface/utils2.c') diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index 31c513699af..9b00c0dfced 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -1080,9 +1080,8 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) case ARRAY_RANGE_REF: case COMPONENT_REF: case BIT_FIELD_REF: - /* If this is for 'Address, find the address of the prefix and - add the offset to the field. Otherwise, do this the normal - way. */ + /* If this is for 'Address, find the address of the prefix and add + the offset to the field. Otherwise, do this the normal way. */ if (op_code == ATTR_ADDR_EXPR) { HOST_WIDE_INT bitsize; @@ -1109,11 +1108,6 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) if (!offset) offset = size_zero_node; - if (bitpos % BITS_PER_UNIT != 0) - post_error - ("taking address of object not aligned on storage unit?", - error_gnat_node); - offset = size_binop (PLUS_EXPR, offset, size_int (bitpos / BITS_PER_UNIT)); -- cgit v1.2.1 From 8c77dd4889a88142439c59c55cc1d43db908eeb5 Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Sat, 8 May 2010 11:02:08 +0000 Subject: * gcc-interface/gigi.h (build_unc_object_type): Add DEBUG_INFO_P param. (build_unc_object_type_from_ptr): Likewise. * gcc-interface/utils.c (build_unc_object_type): Add DEBUG_INFO_P param and pass it to create_type_decl. Declare the type. Simplify. (build_unc_object_type_from_ptr): Add DEBUG_INFO_P parameter and pass it to build_unc_object_type. * gcc-interface/decl.c (gnat_to_gnu_entity): Adjust to above change. * gcc-interface/trans.c (Attribute_to_gnu): Likewise. (gnat_to_gnu): Likewise. * gcc-interface/utils2.c (build_allocator): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159180 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/gcc-interface/utils2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/ada/gcc-interface/utils2.c') diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index 9b00c0dfced..299860501b4 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -1984,7 +1984,7 @@ build_allocator (tree type, tree init, tree result_type, Entity_Id gnat_proc, { tree storage_type = build_unc_object_type_from_ptr (result_type, type, - get_identifier ("ALLOC")); + get_identifier ("ALLOC"), false); tree template_type = TREE_TYPE (TYPE_FIELDS (storage_type)); tree storage_ptr_type = build_pointer_type (storage_type); tree storage; -- cgit v1.2.1 From f70a50e703363936934dea49045d00f6501a590b Mon Sep 17 00:00:00 2001 From: steven Date: Tue, 25 May 2010 21:07:40 +0000 Subject: * gcc-interface/utils.c: Do not include function.h, pointer-set.h, and gimple.h. Explain why rtl.h has to be included. (handle_vector_size_attribute): Call reconstruct_complex_type directly. * gcc-interface/targtyps.c: Do not include tm_p.h * gcc-interface/utils2.c: Do not include flags.h. * gcc-interface/trans.c: Do not include expr.h. Include rtl.h instead, and explain why it has to be included. * gcc-interface/misc.c: Do not include expr.h, libfuncs.h, cgraph.h, and optabs.h. Include function.h and explain why. Explain why except.h is included. (enumerate_modes): Remove unused function. * gcc-interface/gigi.h (enumerate_modes): Remove prototype. * gcc-interface/Make-lang.in: Update dependencies. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159844 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/gcc-interface/utils2.c | 1 - 1 file changed, 1 deletion(-) (limited to 'gcc/ada/gcc-interface/utils2.c') diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index 299860501b4..1c224a3ef07 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -29,7 +29,6 @@ #include "tm.h" #include "tree.h" #include "ggc.h" -#include "flags.h" #include "output.h" #include "tree-inline.h" -- cgit v1.2.1 From 92940d4e46661a7632770b2835426c4ed9e98845 Mon Sep 17 00:00:00 2001 From: charlet Date: Wed, 23 Jun 2010 05:48:28 +0000 Subject: 2010-06-23 Robert Dewar * sem_ch6.adb: Minor reformatting. 2010-06-23 Doug Rupp * bindusg.adb (Display): Write -Hnn line. * bindgen.adb (Gen_Adainit_Ada): Write Heap_Size to binder file as necessary. * init.c (__gl_heap_size): Rename from __gl_no_malloc_64 and change valid values to 32 and 64. (GNAT$NO_MALLOC_64): Recognize TRUE, 1, FALSE, and 0 in addition to ENABLE, DISABLE as valid settings. * switch-b.adb (Scan_Binder_Switches): Process -Hnn switch. * opt.ads (Heap_Size): New global variable. * gcc-interface/utils2.c (maybe_wrap_malloc): Remove mostly redundant TARGET_MALLOC64 check. Fix comment. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161243 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/gcc-interface/utils2.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'gcc/ada/gcc-interface/utils2.c') diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index 1c224a3ef07..69f5f38cf21 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -1823,13 +1823,12 @@ maybe_wrap_malloc (tree data_size, tree data_type, Node_Id gnat_node) tree malloc_ptr; - /* On VMS, if 64-bit memory is disabled or pointers are 64-bit and the - allocator size is 32-bit or Convention C, allocate 32-bit memory. */ + /* On VMS, if pointers are 64-bit and the allocator size is 32-bit or + Convention C, allocate 32-bit memory. */ if (TARGET_ABI_OPEN_VMS - && (!TARGET_MALLOC64 - || (POINTER_SIZE == 64 - && (UI_To_Int (Esize (Etype (gnat_node))) == 32 - || Convention (Etype (gnat_node)) == Convention_C)))) + && (POINTER_SIZE == 64 + && (UI_To_Int (Esize (Etype (gnat_node))) == 32 + || Convention (Etype (gnat_node)) == Convention_C))) malloc_ptr = build_call_1_expr (malloc32_decl, size_to_malloc); else malloc_ptr = build_call_1_expr (malloc_decl, size_to_malloc); -- cgit v1.2.1 From 5cd86571c70d9a80880fb9611315ea89ca78bd5d Mon Sep 17 00:00:00 2001 From: froydnj Date: Tue, 29 Jun 2010 12:21:37 +0000 Subject: * gcc-interface/gigi.h (gnat_build_constructor): Take a VEC instead of a TREE_LIST. Update comment. * gcc-interface/trans.c (gigi): Build a VEC instead of a TREE_LIST. Adjust call to gnat_build_constructor. (Attribute_to_gnu): Likewise. (gnat_to_gnu): Likewise. (pos_to_constructor): Likewise. (extract_values): Likewise. * gcc-interface/utils.c (build_template): Likewise. (convert_vms_descriptor64): Likewise. (convert_vms_descriptor32): Likewise. (convert_to_fat_pointer): Likewise. (convert): Likewise. (unchecked_convert): Likewise. * gcc-interface/decl.c (gnat_to_gnu_entity): Likewise. * gcc-interface/utils2.c (build_allocator): Likewise. (fill_vms_descriptor): Likewise. (gnat_build_constructor): Take a VEC instead of a TREE_LIST. (compare_elmt_bitpos): Adjust for parameters being constructor_elts instead of TREE_LISTs. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161529 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/gcc-interface/utils2.c | 66 +++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 43 deletions(-) (limited to 'gcc/ada/gcc-interface/utils2.c') diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index 69f5f38cf21..ab3814ec4e0 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -1521,34 +1521,31 @@ build_call_raise (int msg, Node_Id gnat_node, char kind) static int compare_elmt_bitpos (const PTR rt1, const PTR rt2) { - const_tree const elmt1 = * (const_tree const *) rt1; - const_tree const elmt2 = * (const_tree const *) rt2; - const_tree const field1 = TREE_PURPOSE (elmt1); - const_tree const field2 = TREE_PURPOSE (elmt2); + const constructor_elt * const elmt1 = (const constructor_elt const *) rt1; + const constructor_elt * const elmt2 = (const constructor_elt const *) rt2; + const_tree const field1 = elmt1->index; + const_tree const field2 = elmt2->index; const int ret = tree_int_cst_compare (bit_position (field1), bit_position (field2)); return ret ? ret : (int) (DECL_UID (field1) - DECL_UID (field2)); } -/* Return a CONSTRUCTOR of TYPE whose list is LIST. */ +/* Return a CONSTRUCTOR of TYPE whose elements are V. */ tree -gnat_build_constructor (tree type, tree list) +gnat_build_constructor (tree type, VEC(constructor_elt,gc) *v) { bool allconstant = (TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST); bool side_effects = false; - tree elmt, result; - int n_elmts; + tree result, obj, val; + unsigned int n_elmts; /* Scan the elements to see if they are all constant or if any has side effects, to let us set global flags on the resulting constructor. Count the elements along the way for possible sorting purposes below. */ - for (n_elmts = 0, elmt = list; elmt; elmt = TREE_CHAIN (elmt), n_elmts ++) + FOR_EACH_CONSTRUCTOR_ELT (v, n_elmts, obj, val) { - tree obj = TREE_PURPOSE (elmt); - tree val = TREE_VALUE (elmt); - /* The predicate must be in keeping with output_constructor. */ if (!TREE_CONSTANT (val) || (TREE_CODE (type) == RECORD_TYPE @@ -1565,27 +1562,10 @@ gnat_build_constructor (tree type, tree list) by increasing bit position. This is necessary to ensure the constructor can be output as static data. */ if (allconstant && TREE_CODE (type) == RECORD_TYPE && n_elmts > 1) - { - /* Fill an array with an element tree per index, and ask qsort to order - them according to what a bitpos comparison function says. */ - tree *gnu_arr = (tree *) alloca (sizeof (tree) * n_elmts); - int i; - - for (i = 0, elmt = list; elmt; elmt = TREE_CHAIN (elmt), i++) - gnu_arr[i] = elmt; + qsort (VEC_address (constructor_elt, v), n_elmts, + sizeof (constructor_elt), compare_elmt_bitpos); - qsort (gnu_arr, n_elmts, sizeof (tree), compare_elmt_bitpos); - - /* Then reconstruct the list from the sorted array contents. */ - list = NULL_TREE; - for (i = n_elmts - 1; i >= 0; i--) - { - TREE_CHAIN (gnu_arr[i]) = list; - list = gnu_arr[i]; - } - } - - result = build_constructor_from_list (type, list); + result = build_constructor (type, v); TREE_CONSTANT (result) = TREE_STATIC (result) = allconstant; TREE_SIDE_EFFECTS (result) = side_effects; TREE_READONLY (result) = TYPE_READONLY (type) || allconstant; @@ -1986,7 +1966,6 @@ build_allocator (tree type, tree init, tree result_type, Entity_Id gnat_proc, tree template_type = TREE_TYPE (TYPE_FIELDS (storage_type)); tree storage_ptr_type = build_pointer_type (storage_type); tree storage; - tree template_cons = NULL_TREE; size = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TYPE_SIZE_UNIT (storage_type), init); @@ -2013,12 +1992,12 @@ build_allocator (tree type, tree init, tree result_type, Entity_Id gnat_proc, bounds. */ if (init) { - template_cons = tree_cons (TREE_CHAIN (TYPE_FIELDS (storage_type)), - init, NULL_TREE); - template_cons = tree_cons (TYPE_FIELDS (storage_type), - build_template (template_type, type, - init), - template_cons); + VEC(constructor_elt,gc) *v = VEC_alloc (constructor_elt, gc, 2); + + CONSTRUCTOR_APPEND_ELT (v, TYPE_FIELDS (storage_type), + build_template (template_type, type, init)); + CONSTRUCTOR_APPEND_ELT (v, TREE_CHAIN (TYPE_FIELDS (storage_type)), + init); return convert (result_type, @@ -2027,7 +2006,7 @@ build_allocator (tree type, tree init, tree result_type, Entity_Id gnat_proc, (MODIFY_EXPR, storage_type, build_unary_op (INDIRECT_REF, NULL_TREE, convert (storage_ptr_type, storage)), - gnat_build_constructor (storage_type, template_cons)), + gnat_build_constructor (storage_type, v)), convert (storage_ptr_type, storage))); } else @@ -2100,10 +2079,11 @@ fill_vms_descriptor (tree expr, Entity_Id gnat_formal, Node_Id gnat_actual) { tree parm_decl = get_gnu_tree (gnat_formal); tree record_type = TREE_TYPE (TREE_TYPE (parm_decl)); - tree const_list = NULL_TREE, field; + tree field; const bool do_range_check = strcmp ("MBO", IDENTIFIER_POINTER (DECL_NAME (TYPE_FIELDS (record_type)))); + VEC(constructor_elt,gc) *v = NULL; expr = maybe_unconstrained_array (expr); gnat_mark_addressable (expr); @@ -2135,10 +2115,10 @@ fill_vms_descriptor (tree expr, Entity_Id gnat_formal, Node_Id gnat_actual) N_Raise_Constraint_Error), NULL_TREE)); } - const_list = tree_cons (field, conexpr, const_list); + CONSTRUCTOR_APPEND_ELT (v, field, conexpr); } - return gnat_build_constructor (record_type, nreverse (const_list)); + return gnat_build_constructor (record_type, v); } /* Indicate that we need to take the address of T and that it therefore -- cgit v1.2.1 From 1767a056f10a2ccbc900df04d01193da73a3d272 Mon Sep 17 00:00:00 2001 From: froydnj Date: Thu, 15 Jul 2010 14:31:28 +0000 Subject: gcc/ * tree.h (DECL_CHAIN): Define. * alias.c: Carefully replace TREE_CHAIN with DECL_CHAIN. * c-decl.c: Likewise. * c-parser.c: Likewise. * c-typeck.c: Likewise. * cfgexpand.c: Likewise. * cgraph.c: Likewise. * cgraphunit.c: Likewise. * combine.c: Likewise. * config/alpha/alpha.c: Likewise. * config/arm/arm.c: Likewise. * config/frv/frv.c: Likewise. * config/i386/i386.c: Likewise. * config/i386/winnt-cxx.c: Likewise. * config/ia64/ia64.c: Likewise. * config/iq2000/iq2000.c: Likewise. * config/mep/mep.c: Likewise. * config/mips/mips.c: Likewise. * config/pa/som.h: Likewise. * config/rs6000/rs6000.c: Likewise. * config/s390/s390.c: Likewise. * config/sh/sh.c: Likewise. * config/sh/symbian-cxx.c: Likewise. * config/sparc/sparc.c: Likewise. * config/spu/spu.c: Likewise. * config/stormy16/stormy16.c: Likewise. * config/vxworks.c: Likewise. * config/xtensa/xtensa.c: Likewise. * coverage.c: Likewise. * dbxout.c: Likewise. * dwarf2out.c: Likewise. * emit-rtl.c: Likewise. * expr.c: Likewise. * function.c: Likewise. * gimple-low.c: Likewise. * gimple-pretty-print.c: Likewise. * gimplify.c: Likewise. * integrate.c: Likewise. * ipa-inline.c: Likewise. * ipa-prop.c: Likewise. * ipa-split.c: Likewise. * ipa-struct-reorg.c: Likewise. * ipa-type-escape.c: Likewise. * langhooks.c: Likewise. * lto-cgraph.c: Likewise. * omp-low.c: Likewise. * stor-layout.c: Likewise. * tree-cfg.c: Likewise. * tree-complex.c: Likewise. * tree-dfa.c: Likewise. * tree-dump.c: Likewise. * tree-inline.c: Likewise. * tree-mudflap.c: Likewise. * tree-nested.c: Likewise. * tree-object-size.c: Likewise. * tree-pretty-print.c: Likewise. * tree-sra.c: Likewise. * tree-ssa-live.c: Likewise. * tree-ssa-loop-niter.c: Likewise. * tree-ssa-math-opts.c: Likewise. * tree-ssa-reassoc.c: Likewise. * tree-ssa-sccvn.c: Likewise. * tree-ssa-structalias.c: Likewise. * tree-tailcall.c: Likewise. * tree-vrp.c: Likewise. * tree.c: Likewise. * var-tracking.c: Likewise. * varasm.c: Likewise. gcc/ada/ * gcc-interface/decl.c: Carefully replace TREE_CHAIN with DECL_CHAIN. * gcc-interface/trans.c: Likewise. * gcc-interface/utils.c: Likewise. * gcc-interface/utils2.c: Likewise. gcc/c-family/ * c-common.c: Carefully replace TREE_CHAIN with DECL_CHAIN. * c-format.c: Likewise. gcc/cp/ * cp-tree.h: Carefully replace TREE_CHAIN with DECL_CHAIN. * call.c: Likewise. * class.c: Likewise. * cp-gimplify.c: Likewise. * decl.c: Likewise. * decl2.c: Likewise. * init.c: Likewise. * mangle.c: Likewise. * name-lookup.c: Likewise. * optimize.c: Likewise. * parser.c: Likewise. * pt.c: Likewise. * rtti.c: Likewise. * search.c: Likewise. * semantics.c: Likewise. * typeck.c: Likewise. * typeck2.c: Likewise. gcc/fortran/ * f95-lang.c: Carefully replace TREE_CHAIN with DECL_CHAIN. * trans-common.c: Likewise. * trans-decl.c: Likewise. * trans-types.c: Likewise. * trans.c: Likewise. gcc/java/ * java-tree.h: Carefully replace TREE_CHAIN with DECL_CHAIN. * boehm.c: Likewise. * class.c: Likewise. * decl.c: Likewise. * expr.c: Likewise. * jcf-parse.c: Likewise. * typeck.c: Likewise. * verify-glue.c: Likewise. gcc/objc/ * objc-act.c: Carefully replace TREE_CHAIN with DECL_CHAIN. gcc/testsuite/ * g++.dg/plugin/attribute_plugin.c: Carefully replace TREE_CHAIN with DECL_CHAIN. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@162223 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/gcc-interface/utils2.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'gcc/ada/gcc-interface/utils2.c') diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index ab3814ec4e0..bd78686e240 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -1612,7 +1612,7 @@ build_simple_component_ref (tree record_variable, tree component, /* First loop thru normal components. */ for (new_field = TYPE_FIELDS (record_type); new_field; - new_field = TREE_CHAIN (new_field)) + new_field = DECL_CHAIN (new_field)) if (SAME_FIELD_P (field, new_field)) break; @@ -1622,7 +1622,7 @@ build_simple_component_ref (tree record_variable, tree component, _Parent field. */ if (!new_field) for (new_field = TYPE_FIELDS (record_type); new_field; - new_field = TREE_CHAIN (new_field)) + new_field = DECL_CHAIN (new_field)) if (DECL_INTERNAL_P (new_field)) { tree field_ref @@ -1996,7 +1996,7 @@ build_allocator (tree type, tree init, tree result_type, Entity_Id gnat_proc, CONSTRUCTOR_APPEND_ELT (v, TYPE_FIELDS (storage_type), build_template (template_type, type, init)); - CONSTRUCTOR_APPEND_ELT (v, TREE_CHAIN (TYPE_FIELDS (storage_type)), + CONSTRUCTOR_APPEND_ELT (v, DECL_CHAIN (TYPE_FIELDS (storage_type)), init); return convert @@ -2088,7 +2088,7 @@ fill_vms_descriptor (tree expr, Entity_Id gnat_formal, Node_Id gnat_actual) expr = maybe_unconstrained_array (expr); gnat_mark_addressable (expr); - for (field = TYPE_FIELDS (record_type); field; field = TREE_CHAIN (field)) + for (field = TYPE_FIELDS (record_type); field; field = DECL_CHAIN (field)) { tree conexpr = convert (TREE_TYPE (field), SUBSTITUTE_PLACEHOLDER_IN_EXPR -- cgit v1.2.1