Commit 722356ce by Eric Botcazou Committed by Eric Botcazou

trans.c (Attribute_to_gnu): Use remove_conversions.

	* gcc-interface/trans.c (Attribute_to_gnu): Use remove_conversions.
	(push_range_check_info): Likewise.
	(gnat_to_gnu) <N_Code_Statement>: Likewise.
	* gcc-interface/utils2.c (build_unary_op) <INDIRECT_REF>: Likewise.
	(gnat_invariant_expr): Likewise.
	* gcc-interface/utils.c (compute_related_constant): Likewise.
	(max_size): Fix handling of SAVE_EXPR.
	(remove_conversions): Fix formatting.

From-SVN: r179873
parent 4eb20b03
2011-10-12 Eric Botcazou <ebotcazou@adacore.com> 2011-10-12 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/trans.c (Attribute_to_gnu): Use remove_conversions.
(push_range_check_info): Likewise.
(gnat_to_gnu) <N_Code_Statement>: Likewise.
* gcc-interface/utils2.c (build_unary_op) <INDIRECT_REF>: Likewise.
(gnat_invariant_expr): Likewise.
* gcc-interface/utils.c (compute_related_constant): Likewise.
(max_size): Fix handling of SAVE_EXPR.
(remove_conversions): Fix formatting.
2011-10-12 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/ada-tree.h (DECL_LOOP_PARM_P): New flag. * gcc-interface/ada-tree.h (DECL_LOOP_PARM_P): New flag.
(DECL_INDUCTION_VAR): New macro. (DECL_INDUCTION_VAR): New macro.
(SET_DECL_INDUCTION_VAR): Likewise. (SET_DECL_INDUCTION_VAR): Likewise.
......
...@@ -1364,10 +1364,7 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute) ...@@ -1364,10 +1364,7 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute)
don't try to build a trampoline. */ don't try to build a trampoline. */
if (attribute == Attr_Code_Address) if (attribute == Attr_Code_Address)
{ {
for (gnu_expr = gnu_result; gnu_expr = remove_conversions (gnu_result, false);
CONVERT_EXPR_P (gnu_expr);
gnu_expr = TREE_OPERAND (gnu_expr, 0))
TREE_CONSTANT (gnu_expr) = 1;
if (TREE_CODE (gnu_expr) == ADDR_EXPR) if (TREE_CODE (gnu_expr) == ADDR_EXPR)
TREE_NO_TRAMPOLINE (gnu_expr) = TREE_CONSTANT (gnu_expr) = 1; TREE_NO_TRAMPOLINE (gnu_expr) = TREE_CONSTANT (gnu_expr) = 1;
...@@ -1378,10 +1375,7 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute) ...@@ -1378,10 +1375,7 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute)
a useful warning with -Wtrampolines. */ a useful warning with -Wtrampolines. */
else if (TREE_CODE (TREE_TYPE (gnu_prefix)) == FUNCTION_TYPE) else if (TREE_CODE (TREE_TYPE (gnu_prefix)) == FUNCTION_TYPE)
{ {
for (gnu_expr = gnu_result; gnu_expr = remove_conversions (gnu_result, false);
CONVERT_EXPR_P (gnu_expr);
gnu_expr = TREE_OPERAND (gnu_expr, 0))
;
if (TREE_CODE (gnu_expr) == ADDR_EXPR if (TREE_CODE (gnu_expr) == ADDR_EXPR
&& decl_function_context (TREE_OPERAND (gnu_expr, 0))) && decl_function_context (TREE_OPERAND (gnu_expr, 0)))
...@@ -2156,8 +2150,7 @@ push_range_check_info (tree var) ...@@ -2156,8 +2150,7 @@ push_range_check_info (tree var)
if (VEC_empty (loop_info, gnu_loop_stack)) if (VEC_empty (loop_info, gnu_loop_stack))
return NULL; return NULL;
while (CONVERT_EXPR_P (var) || TREE_CODE (var) == VIEW_CONVERT_EXPR) var = remove_conversions (var, false);
var = TREE_OPERAND (var, 0);
if (TREE_CODE (var) != VAR_DECL) if (TREE_CODE (var) != VAR_DECL)
return NULL; return NULL;
...@@ -6139,7 +6132,7 @@ gnat_to_gnu (Node_Id gnat_node) ...@@ -6139,7 +6132,7 @@ gnat_to_gnu (Node_Id gnat_node)
is modelled on the C front-end. */ is modelled on the C front-end. */
if (!allows_reg) if (!allows_reg)
{ {
STRIP_NOPS (output); output = remove_conversions (output, false);
if (TREE_CODE (output) == CONST_DECL if (TREE_CODE (output) == CONST_DECL
&& DECL_CONST_CORRESPONDING_VAR (output)) && DECL_CONST_CORRESPONDING_VAR (output))
output = DECL_CONST_CORRESPONDING_VAR (output); output = DECL_CONST_CORRESPONDING_VAR (output);
...@@ -6167,7 +6160,7 @@ gnat_to_gnu (Node_Id gnat_node) ...@@ -6167,7 +6160,7 @@ gnat_to_gnu (Node_Id gnat_node)
mark it addressable. */ mark it addressable. */
if (!allows_reg && allows_mem) if (!allows_reg && allows_mem)
{ {
STRIP_NOPS (input); input = remove_conversions (input, false);
if (TREE_CODE (input) == CONST_DECL if (TREE_CODE (input) == CONST_DECL
&& DECL_CONST_CORRESPONDING_VAR (input)) && DECL_CONST_CORRESPONDING_VAR (input))
input = DECL_CONST_CORRESPONDING_VAR (input); input = DECL_CONST_CORRESPONDING_VAR (input);
......
...@@ -1147,11 +1147,11 @@ compute_related_constant (tree op0, tree op1) ...@@ -1147,11 +1147,11 @@ compute_related_constant (tree op0, tree op1)
static tree static tree
split_plus (tree in, tree *pvar) split_plus (tree in, tree *pvar)
{ {
/* Strip NOPS in order to ease the tree traversal and maximize the /* Strip conversions in order to ease the tree traversal and maximize the
potential for constant or plus/minus discovery. We need to be careful potential for constant or plus/minus discovery. We need to be careful
to always return and set *pvar to bitsizetype trees, but it's worth to always return and set *pvar to bitsizetype trees, but it's worth
the effort. */ the effort. */
STRIP_NOPS (in); in = remove_conversions (in, false);
*pvar = convert (bitsizetype, in); *pvar = convert (bitsizetype, in);
...@@ -2288,7 +2288,9 @@ max_size (tree exp, bool max_p) ...@@ -2288,7 +2288,9 @@ max_size (tree exp, bool max_p)
switch (TREE_CODE_LENGTH (code)) switch (TREE_CODE_LENGTH (code))
{ {
case 1: case 1:
if (code == NON_LVALUE_EXPR) if (code == SAVE_EXPR)
return exp;
else if (code == NON_LVALUE_EXPR)
return max_size (TREE_OPERAND (exp, 0), max_p); return max_size (TREE_OPERAND (exp, 0), max_p);
else else
return return
...@@ -2330,9 +2332,7 @@ max_size (tree exp, bool max_p) ...@@ -2330,9 +2332,7 @@ max_size (tree exp, bool max_p)
} }
case 3: case 3:
if (code == SAVE_EXPR) if (code == COND_EXPR)
return exp;
else if (code == COND_EXPR)
return fold_build2 (max_p ? MAX_EXPR : MIN_EXPR, type, return fold_build2 (max_p ? MAX_EXPR : MIN_EXPR, type,
max_size (TREE_OPERAND (exp, 1), max_p), max_size (TREE_OPERAND (exp, 1), max_p),
max_size (TREE_OPERAND (exp, 2), max_p)); max_size (TREE_OPERAND (exp, 2), max_p));
...@@ -4359,8 +4359,9 @@ remove_conversions (tree exp, bool true_address) ...@@ -4359,8 +4359,9 @@ remove_conversions (tree exp, bool true_address)
return remove_conversions (TREE_OPERAND (exp, 0), true_address); return remove_conversions (TREE_OPERAND (exp, 0), true_address);
break; break;
case VIEW_CONVERT_EXPR: case NON_LVALUE_EXPR:
CASE_CONVERT: CASE_CONVERT:
case VIEW_CONVERT_EXPR:
case NON_LVALUE_EXPR:
return remove_conversions (TREE_OPERAND (exp, 0), true_address); return remove_conversions (TREE_OPERAND (exp, 0), true_address);
default: default:
......
...@@ -1277,13 +1277,8 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) ...@@ -1277,13 +1277,8 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand)
case INDIRECT_REF: case INDIRECT_REF:
{ {
bool can_never_be_null; tree t = remove_conversions (operand, false);
tree t = operand; bool can_never_be_null = DECL_P (t) && DECL_CAN_NEVER_BE_NULL_P (t);
while (CONVERT_EXPR_P (t) || TREE_CODE (t) == VIEW_CONVERT_EXPR)
t = TREE_OPERAND (t, 0);
can_never_be_null = DECL_P (t) && DECL_CAN_NEVER_BE_NULL_P (t);
/* If TYPE is a thin pointer, first convert to the fat pointer. */ /* If TYPE is a thin pointer, first convert to the fat pointer. */
if (TYPE_IS_THIN_POINTER_P (type) if (TYPE_IS_THIN_POINTER_P (type)
...@@ -2608,16 +2603,13 @@ gnat_invariant_expr (tree expr) ...@@ -2608,16 +2603,13 @@ gnat_invariant_expr (tree expr)
{ {
tree type = TREE_TYPE (expr), t; tree type = TREE_TYPE (expr), t;
STRIP_NOPS (expr); expr = remove_conversions (expr, false);
while ((TREE_CODE (expr) == CONST_DECL while ((TREE_CODE (expr) == CONST_DECL
|| (TREE_CODE (expr) == VAR_DECL && TREE_READONLY (expr))) || (TREE_CODE (expr) == VAR_DECL && TREE_READONLY (expr)))
&& decl_function_context (expr) == current_function_decl && decl_function_context (expr) == current_function_decl
&& DECL_INITIAL (expr)) && DECL_INITIAL (expr))
{ expr = remove_conversions (DECL_INITIAL (expr), false);
expr = DECL_INITIAL (expr);
STRIP_NOPS (expr);
}
if (TREE_CONSTANT (expr)) if (TREE_CONSTANT (expr))
return fold_convert (type, expr); return fold_convert (type, 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