public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-666] [Ada] Small housekeeping work in gnat_gimplify_expr Date: Thu, 19 May 2022 14:09:02 +0000 (GMT) [thread overview] Message-ID: <20220519140902.5208E386F82B@sourceware.org> (raw) https://gcc.gnu.org/g:9ae384160f4b2e3f3ad1576c737d72e127ffebc1 commit r13-666-g9ae384160f4b2e3f3ad1576c737d72e127ffebc1 Author: Eric Botcazou <ebotcazou@adacore.com> Date: Wed Mar 23 14:35:40 2022 +0100 [Ada] Small housekeeping work in gnat_gimplify_expr This alphabetizes the large switch statement, removes a useless nested switch statement, an artificial fall through and adds a default return. No functional changes. gcc/ada/ * gcc-interface/trans.cc (gnat_gimplify_expr): Tidy up. Diff: --- gcc/ada/gcc-interface/trans.cc | 131 +++++++++++++++++++---------------------- 1 file changed, 60 insertions(+), 71 deletions(-) diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc index 4577d9f110b..3e8842f4a92 100644 --- 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. */
reply other threads:[~2022-05-19 14:09 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220519140902.5208E386F82B@sourceware.org \ --to=pmderodat@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).