* [Ada] Small housekeeping work in gnat_gimplify_expr
@ 2022-05-19 14:16 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-05-19 14:16 UTC (permalink / raw)
To: gcc-patches; +Cc: Eric Botcazou
[-- Attachment #1: Type: text/plain, Size: 285 bytes --]
This alphabetizes the large switch statement, removes a useless nested
switch statement, an artificial fall through and adds a default return.
No functional changes.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* gcc-interface/trans.cc (gnat_gimplify_expr): Tidy up.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 4668 bytes --]
diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc
--- a/gcc/ada/gcc-interface/trans.cc
+++ b/gcc/ada/gcc-interface/trans.cc
@@ -8638,30 +8638,6 @@ gnat_gimplify_expr (tree *expr_p, gimple_seq *pre_p,
switch (TREE_CODE (expr))
{
- case NULL_EXPR:
- /* If this is an aggregate type, build a null pointer of the appropriate
- type and dereference it. */
- if (AGGREGATE_TYPE_P (type)
- || TREE_CODE (type) == UNCONSTRAINED_ARRAY_TYPE)
- *expr_p = build_unary_op (INDIRECT_REF, NULL_TREE,
- convert (build_pointer_type (type),
- integer_zero_node));
- /* Otherwise, just make a VAR_DECL. */
- else
- {
- *expr_p = create_tmp_var (type, NULL);
- suppress_warning (*expr_p);
- }
-
- gimplify_and_add (TREE_OPERAND (expr, 0), pre_p);
- return GS_OK;
-
- case UNCONSTRAINED_ARRAY_REF:
- /* We should only do this if we are just elaborating for side-effects,
- but we can't know that yet. */
- *expr_p = TREE_OPERAND (*expr_p, 0);
- return GS_OK;
-
case ADDR_EXPR:
op = TREE_OPERAND (expr, 0);
@@ -8695,8 +8671,7 @@ gnat_gimplify_expr (tree *expr_p, gimple_seq *pre_p,
else
op = inner;
}
-
- return GS_UNHANDLED;
+ break;
case CALL_EXPR:
/* If we are passing a constant fat pointer CONSTRUCTOR, make sure it is
@@ -8720,8 +8695,62 @@ gnat_gimplify_expr (tree *expr_p, gimple_seq *pre_p,
*(CALL_EXPR_ARGP (expr) + i) = tree_output_constant_def (arg);
}
}
+ break;
+
+ case DECL_EXPR:
+ op = DECL_EXPR_DECL (expr);
+
+ /* The expressions for the RM bounds must be gimplified to ensure that
+ they are properly elaborated. See gimplify_decl_expr. */
+ if ((TREE_CODE (op) == TYPE_DECL || TREE_CODE (op) == VAR_DECL)
+ && !TYPE_SIZES_GIMPLIFIED (TREE_TYPE (op))
+ && (INTEGRAL_TYPE_P (TREE_TYPE (op))
+ || SCALAR_FLOAT_TYPE_P (TREE_TYPE (op))))
+ {
+ tree type = TYPE_MAIN_VARIANT (TREE_TYPE (op)), t, val;
+
+ val = TYPE_RM_MIN_VALUE (type);
+ if (val)
+ {
+ gimplify_one_sizepos (&val, pre_p);
+ for (t = type; t; t = TYPE_NEXT_VARIANT (t))
+ SET_TYPE_RM_MIN_VALUE (t, val);
+ }
+
+ val = TYPE_RM_MAX_VALUE (type);
+ if (val)
+ {
+ gimplify_one_sizepos (&val, pre_p);
+ for (t = type; t; t = TYPE_NEXT_VARIANT (t))
+ SET_TYPE_RM_MAX_VALUE (t, val);
+ }
+ }
+ break;
+
+ case NULL_EXPR:
+ /* If this is an aggregate type, build a null pointer of the appropriate
+ type and dereference it. */
+ if (AGGREGATE_TYPE_P (type)
+ || TREE_CODE (type) == UNCONSTRAINED_ARRAY_TYPE)
+ *expr_p = build_unary_op (INDIRECT_REF, NULL_TREE,
+ convert (build_pointer_type (type),
+ integer_zero_node));
+
+ /* Otherwise, just make a VAR_DECL. */
+ else
+ {
+ *expr_p = create_tmp_var (type, NULL);
+ suppress_warning (*expr_p);
+ }
- return GS_UNHANDLED;
+ gimplify_and_add (TREE_OPERAND (expr, 0), pre_p);
+ return GS_OK;
+
+ case UNCONSTRAINED_ARRAY_REF:
+ /* We should only do this if we are just elaborating for side effects,
+ but we can't know that yet. */
+ *expr_p = TREE_OPERAND (*expr_p, 0);
+ return GS_OK;
case VIEW_CONVERT_EXPR:
op = TREE_OPERAND (expr, 0);
@@ -8742,53 +8771,13 @@ gnat_gimplify_expr (tree *expr_p, gimple_seq *pre_p,
TREE_OPERAND (expr, 0) = new_var;
return GS_OK;
}
-
- return GS_UNHANDLED;
-
- case DECL_EXPR:
- op = DECL_EXPR_DECL (expr);
-
- /* The expressions for the RM bounds must be gimplified to ensure that
- they are properly elaborated. See gimplify_decl_expr. */
- if ((TREE_CODE (op) == TYPE_DECL || TREE_CODE (op) == VAR_DECL)
- && !TYPE_SIZES_GIMPLIFIED (TREE_TYPE (op)))
- switch (TREE_CODE (TREE_TYPE (op)))
- {
- case INTEGER_TYPE:
- case ENUMERAL_TYPE:
- case BOOLEAN_TYPE:
- case REAL_TYPE:
- {
- tree type = TYPE_MAIN_VARIANT (TREE_TYPE (op)), t, val;
-
- val = TYPE_RM_MIN_VALUE (type);
- if (val)
- {
- gimplify_one_sizepos (&val, pre_p);
- for (t = type; t; t = TYPE_NEXT_VARIANT (t))
- SET_TYPE_RM_MIN_VALUE (t, val);
- }
-
- val = TYPE_RM_MAX_VALUE (type);
- if (val)
- {
- gimplify_one_sizepos (&val, pre_p);
- for (t = type; t; t = TYPE_NEXT_VARIANT (t))
- SET_TYPE_RM_MAX_VALUE (t, val);
- }
-
- }
- break;
-
- default:
- break;
- }
-
- /* ... fall through ... */
+ break;
default:
- return GS_UNHANDLED;
+ break;
}
+
+ return GS_UNHANDLED;
}
/* Generate GIMPLE in place for the statement at *STMT_P. */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-19 14:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-19 14:16 [Ada] Small housekeeping work in gnat_gimplify_expr Pierre-Marie de Rodat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).