Commit 2117b9bb by Eric Botcazou Committed by Eric Botcazou

decl.c (gnat_to_gnu_entity): Minor tweak.

	* gcc-interface/decl.c (gnat_to_gnu_entity): Minor tweak.
	* gcc-interface/trans.c (finalize_nrv_unc_r): Use CONSTRUCTOR_ELT.
	* gcc-interface/utils.c (convert): Likewise and simplify.
	(remove_conversions): Likewise.
	* gcc-interface/utils2.c (compare_fat_pointers): Likewise.
	(build_unary_op): Likewise and simplify.

From-SVN: r223653
parent f797c2b7
2015-05-25 Eric Botcazou <ebotcazou@adacore.com> 2015-05-25 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/decl.c (gnat_to_gnu_entity): Minor tweak.
* gcc-interface/trans.c (finalize_nrv_unc_r): Use CONSTRUCTOR_ELT.
* gcc-interface/utils.c (convert): Likewise and simplify.
(remove_conversions): Likewise.
* gcc-interface/utils2.c (compare_fat_pointers): Likewise.
(build_unary_op): Likewise and simplify.
2015-05-25 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/gigi.h (build_atomic_load): Adjust prototype. * gcc-interface/gigi.h (build_atomic_load): Adjust prototype.
(build_atomic_store): Likewise. (build_atomic_store): Likewise.
(build_load_modify_store): Declare. (build_load_modify_store): Declare.
......
...@@ -1335,8 +1335,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -1335,8 +1335,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
= TREE_TYPE (DECL_CHAIN (TYPE_FIELDS (gnu_alloc_type))); = TREE_TYPE (DECL_CHAIN (TYPE_FIELDS (gnu_alloc_type)));
if (TREE_CODE (gnu_expr) == CONSTRUCTOR if (TREE_CODE (gnu_expr) == CONSTRUCTOR
&& 1 == vec_safe_length (CONSTRUCTOR_ELTS (gnu_expr))) && vec_safe_length (CONSTRUCTOR_ELTS (gnu_expr)) == 1)
gnu_expr = 0; gnu_expr = NULL_TREE;
else else
gnu_expr gnu_expr
= build_component_ref = build_component_ref
......
...@@ -3309,12 +3309,12 @@ finalize_nrv_unc_r (tree *tp, int *walk_subtrees, void *data) ...@@ -3309,12 +3309,12 @@ finalize_nrv_unc_r (tree *tp, int *walk_subtrees, void *data)
if (TREE_CODE (ret_val) == COMPOUND_EXPR if (TREE_CODE (ret_val) == COMPOUND_EXPR
&& TREE_CODE (TREE_OPERAND (ret_val, 0)) == INIT_EXPR) && TREE_CODE (TREE_OPERAND (ret_val, 0)) == INIT_EXPR)
{ {
tree rhs = TREE_OPERAND (TREE_OPERAND (ret_val, 0), 1);
if (TYPE_IS_FAT_POINTER_P (TREE_TYPE (ret_val))) if (TYPE_IS_FAT_POINTER_P (TREE_TYPE (ret_val)))
ret_val ret_val = CONSTRUCTOR_ELT (rhs, 1)->value;
= (*CONSTRUCTOR_ELTS (TREE_OPERAND (TREE_OPERAND (ret_val, 0),
1)))[1].value;
else else
ret_val = TREE_OPERAND (TREE_OPERAND (ret_val, 0), 1); ret_val = rhs;
} }
/* Strip useless conversions around the return value. */ /* Strip useless conversions around the return value. */
...@@ -3365,20 +3365,21 @@ finalize_nrv_unc_r (tree *tp, int *walk_subtrees, void *data) ...@@ -3365,20 +3365,21 @@ finalize_nrv_unc_r (tree *tp, int *walk_subtrees, void *data)
if (TYPE_IS_FAT_POINTER_P (TREE_TYPE (alloc))) if (TYPE_IS_FAT_POINTER_P (TREE_TYPE (alloc)))
{ {
tree cst = TREE_OPERAND (alloc, 1);
/* The new initial value is a COMPOUND_EXPR with the allocation in /* The new initial value is a COMPOUND_EXPR with the allocation in
the first arm and the value of P_ARRAY in the second arm. */ the first arm and the value of P_ARRAY in the second arm. */
DECL_INITIAL (new_var) DECL_INITIAL (new_var)
= build2 (COMPOUND_EXPR, TREE_TYPE (new_var), = build2 (COMPOUND_EXPR, TREE_TYPE (new_var),
TREE_OPERAND (alloc, 0), TREE_OPERAND (alloc, 0),
(*CONSTRUCTOR_ELTS (TREE_OPERAND (alloc, 1)))[0].value); CONSTRUCTOR_ELT (cst, 0)->value);
/* Build a modified CONSTRUCTOR that references NEW_VAR. */ /* Build a modified CONSTRUCTOR that references NEW_VAR. */
p_array = TYPE_FIELDS (TREE_TYPE (alloc)); p_array = TYPE_FIELDS (TREE_TYPE (alloc));
CONSTRUCTOR_APPEND_ELT (v, p_array, CONSTRUCTOR_APPEND_ELT (v, p_array,
fold_convert (TREE_TYPE (p_array), new_var)); fold_convert (TREE_TYPE (p_array), new_var));
CONSTRUCTOR_APPEND_ELT (v, DECL_CHAIN (p_array), CONSTRUCTOR_APPEND_ELT (v, DECL_CHAIN (p_array),
(*CONSTRUCTOR_ELTS ( CONSTRUCTOR_ELT (cst, 1)->value);
TREE_OPERAND (alloc, 1)))[1].value);
new_ret = build_constructor (TREE_TYPE (alloc), v); new_ret = build_constructor (TREE_TYPE (alloc), v);
} }
else else
......
...@@ -4067,10 +4067,8 @@ convert (tree type, tree expr) ...@@ -4067,10 +4067,8 @@ convert (tree type, tree expr)
/* If we have just converted to this padded type, just get the /* If we have just converted to this padded type, just get the
inner expression. */ inner expression. */
if (TREE_CODE (expr) == CONSTRUCTOR if (TREE_CODE (expr) == CONSTRUCTOR)
&& !vec_safe_is_empty (CONSTRUCTOR_ELTS (expr)) unpadded = CONSTRUCTOR_ELT (expr, 0)->value;
&& (*CONSTRUCTOR_ELTS (expr))[0].index == TYPE_FIELDS (etype))
unpadded = (*CONSTRUCTOR_ELTS (expr))[0].value;
/* Otherwise, build an explicit component reference. */ /* Otherwise, build an explicit component reference. */
else else
...@@ -4632,7 +4630,7 @@ remove_conversions (tree exp, bool true_address) ...@@ -4632,7 +4630,7 @@ remove_conversions (tree exp, bool true_address)
&& TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE && TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE
&& TYPE_JUSTIFIED_MODULAR_P (TREE_TYPE (exp))) && TYPE_JUSTIFIED_MODULAR_P (TREE_TYPE (exp)))
return return
remove_conversions ((*CONSTRUCTOR_ELTS (exp))[0].value, true); remove_conversions (CONSTRUCTOR_ELT (exp, 0)->value, true);
break; break;
case COMPONENT_REF: case COMPONENT_REF:
......
...@@ -461,7 +461,7 @@ compare_fat_pointers (location_t loc, tree result_type, tree p1, tree p2) ...@@ -461,7 +461,7 @@ compare_fat_pointers (location_t loc, tree result_type, tree p1, tree p2)
/* The constant folder doesn't fold fat pointer types so we do it here. */ /* The constant folder doesn't fold fat pointer types so we do it here. */
if (TREE_CODE (p1) == CONSTRUCTOR) if (TREE_CODE (p1) == CONSTRUCTOR)
p1_array = (*CONSTRUCTOR_ELTS (p1))[0].value; p1_array = CONSTRUCTOR_ELT (p1, 0)->value;
else else
p1_array = build_component_ref (p1, NULL_TREE, p1_array = build_component_ref (p1, NULL_TREE,
TYPE_FIELDS (TREE_TYPE (p1)), true); TYPE_FIELDS (TREE_TYPE (p1)), true);
...@@ -472,7 +472,7 @@ compare_fat_pointers (location_t loc, tree result_type, tree p1, tree p2) ...@@ -472,7 +472,7 @@ compare_fat_pointers (location_t loc, tree result_type, tree p1, tree p2)
null_pointer_node)); null_pointer_node));
if (TREE_CODE (p2) == CONSTRUCTOR) if (TREE_CODE (p2) == CONSTRUCTOR)
p2_array = (*CONSTRUCTOR_ELTS (p2))[0].value; p2_array = CONSTRUCTOR_ELT (p2, 0)->value;
else else
p2_array = build_component_ref (p2, NULL_TREE, p2_array = build_component_ref (p2, NULL_TREE,
TYPE_FIELDS (TREE_TYPE (p2)), true); TYPE_FIELDS (TREE_TYPE (p2)), true);
...@@ -493,14 +493,14 @@ compare_fat_pointers (location_t loc, tree result_type, tree p1, tree p2) ...@@ -493,14 +493,14 @@ compare_fat_pointers (location_t loc, tree result_type, tree p1, tree p2)
= fold_build2_loc (loc, EQ_EXPR, result_type, p1_array, p2_array); = fold_build2_loc (loc, EQ_EXPR, result_type, p1_array, p2_array);
if (TREE_CODE (p1) == CONSTRUCTOR) if (TREE_CODE (p1) == CONSTRUCTOR)
p1_bounds = (*CONSTRUCTOR_ELTS (p1))[1].value; p1_bounds = CONSTRUCTOR_ELT (p1, 1)->value;
else else
p1_bounds p1_bounds
= build_component_ref (p1, NULL_TREE, = build_component_ref (p1, NULL_TREE,
DECL_CHAIN (TYPE_FIELDS (TREE_TYPE (p1))), true); DECL_CHAIN (TYPE_FIELDS (TREE_TYPE (p1))), true);
if (TREE_CODE (p2) == CONSTRUCTOR) if (TREE_CODE (p2) == CONSTRUCTOR)
p2_bounds = (*CONSTRUCTOR_ELTS (p2))[1].value; p2_bounds = CONSTRUCTOR_ELT (p2, 1)->value;
else else
p2_bounds p2_bounds
= build_component_ref (p2, NULL_TREE, = build_component_ref (p2, NULL_TREE,
...@@ -1445,15 +1445,13 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) ...@@ -1445,15 +1445,13 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand)
offset = size_binop (PLUS_EXPR, offset, offset = size_binop (PLUS_EXPR, offset,
size_int (bitpos / BITS_PER_UNIT)); size_int (bitpos / BITS_PER_UNIT));
/* Take the address of INNER, convert the offset to void *, and /* Take the address of INNER, convert it to a pointer to our type
add then. It will later be converted to the desired result and add the offset. */
type, if any. */ inner = build_unary_op (ADDR_EXPR,
inner = build_unary_op (ADDR_EXPR, NULL_TREE, inner); build_pointer_type (TREE_TYPE (operand)),
inner = convert (ptr_void_type_node, inner); inner);
result = build_binary_op (POINTER_PLUS_EXPR, ptr_void_type_node, result = build_binary_op (POINTER_PLUS_EXPR, TREE_TYPE (inner),
inner, offset); inner, offset);
result = convert (build_pointer_type (TREE_TYPE (operand)),
result);
break; break;
} }
goto common; goto common;
...@@ -1464,12 +1462,12 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) ...@@ -1464,12 +1462,12 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand)
a pointer to our type. */ a pointer to our type. */
if (TYPE_IS_PADDING_P (type)) if (TYPE_IS_PADDING_P (type))
{ {
result = (*CONSTRUCTOR_ELTS (operand))[0].value; result
result = convert (build_pointer_type (TREE_TYPE (operand)), = build_unary_op (ADDR_EXPR,
build_unary_op (ADDR_EXPR, NULL_TREE, result)); build_pointer_type (TREE_TYPE (operand)),
CONSTRUCTOR_ELT (operand, 0)->value);
break; break;
} }
goto common; goto common;
case NOP_EXPR: case NOP_EXPR:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment