From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 1AD93385C417; Wed, 6 Oct 2021 10:02:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1AD93385C417 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-4208] More consistently dump GIMPLE FE consumable stmts X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: ba837323dbda2bca5a1c8a4c78092a88241dcfa3 X-Git-Newrev: 90c3a62272313bb08cd5d9a948ff2d71af73b294 Message-Id: <20211006100230.1AD93385C417@sourceware.org> Date: Wed, 6 Oct 2021 10:02:30 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Oct 2021 10:02:30 -0000 https://gcc.gnu.org/g:90c3a62272313bb08cd5d9a948ff2d71af73b294 commit r12-4208-g90c3a62272313bb08cd5d9a948ff2d71af73b294 Author: Richard Biener Date: Tue Oct 5 14:49:42 2021 +0200 More consistently dump GIMPLE FE consumable stmts The following makes more stmts consumable with the GIMPLE FE when dumping with -gimple. In particular addresses in GIMPLE operand position require wrapping with _Literal. The TDF_ flag space is now exhausted and I've removed overlaps and re-ordered things as to how it is supposed to work and made it uint32_t and prepared the operator overloads for an easy migration to uint64_t once required. 2021-10-05 Richard Biener PR c/102605 * dumpfile.h (TDF_GIMPLE_VAL): New. (dump_flag): Re-order and adjust TDF_* flags. Make the enum uint32_t. Use std::underlying_type in the operator overloads. (optgroup_flag): Likewise for the operator overloads. * tree-pretty-print.c (dump_generic_node): Wrap ADDR_EXPR in _Literal if TDF_GIMPLE_VAL. * gimple-pretty-print.c (dump_gimple_assign): Add TDF_GIMPLE_VAL to flags when dumping operands where only is_gimple_val are allowed. (dump_gimple_cond): Likewise. Diff: --- gcc/dumpfile.h | 55 +++++++++++++++++++++++++++-------------------- gcc/gimple-pretty-print.c | 21 +++++++++++++----- gcc/tree-pretty-print.c | 10 ++++++++- 3 files changed, 57 insertions(+), 29 deletions(-) diff --git a/gcc/dumpfile.h b/gcc/dumpfile.h index 6c7758dd2fb..76226753845 100644 --- a/gcc/dumpfile.h +++ b/gcc/dumpfile.h @@ -74,7 +74,7 @@ enum dump_kind the DUMP_OPTIONS array in dumpfile.c. The TDF_* flags coexist with MSG_* flags (for -fopt-info) and the bit values must be chosen to allow that. */ -enum dump_flag +enum dump_flag : uint32_t { /* Value of TDF_NONE is used just for bits filtered by TDF_KIND_MASK. */ TDF_NONE = 0, @@ -140,23 +140,26 @@ enum dump_flag /* Dump SCEV details. */ TDF_SCEV = (1 << 19), - /* Dump in GIMPLE FE syntax */ + /* Dump in GIMPLE FE syntax. */ TDF_GIMPLE = (1 << 20), /* Dump folding details. */ TDF_FOLDING = (1 << 21), + /* Dumping for range path solver. */ + TDF_THREADING = (1 << 22), + /* MSG_* flags for expressing the kinds of message to be emitted by -fopt-info. */ /* -fopt-info optimized sources. */ - MSG_OPTIMIZED_LOCATIONS = (1 << 22), + MSG_OPTIMIZED_LOCATIONS = (1 << 23), /* Missed opportunities. */ - MSG_MISSED_OPTIMIZATION = (1 << 23), + MSG_MISSED_OPTIMIZATION = (1 << 24), /* General optimization info. */ - MSG_NOTE = (1 << 24), + MSG_NOTE = (1 << 25), /* Mask for selecting MSG_-kind flags. */ MSG_ALL_KINDS = (MSG_OPTIMIZED_LOCATIONS @@ -175,33 +178,33 @@ enum dump_flag sub-option of -fopt-info to show the internal messages. */ /* Implicitly supplied for messages at the top-level dump scope. */ - MSG_PRIORITY_USER_FACING = (1 << 25), + MSG_PRIORITY_USER_FACING = (1 << 26), /* Implicitly supplied for messages within nested dump scopes. */ - MSG_PRIORITY_INTERNALS = (1 << 26), + MSG_PRIORITY_INTERNALS = (1 << 27), /* Supplied when an opt_problem generated in a nested scope is re-emitted at the top-level. We want to default to showing these in -fopt-info output, but to *not* show them in dump files, as the message would be shown twice, messing up "scan-tree-dump-times" in DejaGnu tests. */ - MSG_PRIORITY_REEMITTED = (1 << 27), + MSG_PRIORITY_REEMITTED = (1 << 28), /* Mask for selecting MSG_PRIORITY_* flags. */ MSG_ALL_PRIORITIES = (MSG_PRIORITY_USER_FACING | MSG_PRIORITY_INTERNALS | MSG_PRIORITY_REEMITTED), - /* Dumping for -fcompare-debug. */ - TDF_COMPARE_DEBUG = (1 << 28), + /* All -fdump- flags. */ + TDF_ALL_VALUES = (1 << 29) - 1, - /* For error. */ - TDF_ERROR = (1 << 26), + /* Dumping for -fcompare-debug. */ + TDF_COMPARE_DEBUG = (1 << 29), - /* Dumping for range path solver. */ - TDF_THREADING = (1 << 27), + /* Dump a GIMPLE value which means wrapping certain things with _Literal. */ + TDF_GIMPLE_VAL = (1 << 30), - /* All values. */ - TDF_ALL_VALUES = (1 << 29) - 1 + /* For error. */ + TDF_ERROR = ((uint32_t)1 << 31), }; /* Dump flags type. */ @@ -211,32 +214,36 @@ typedef enum dump_flag dump_flags_t; static inline dump_flags_t operator| (dump_flags_t lhs, dump_flags_t rhs) { - return (dump_flags_t)((int)lhs | (int)rhs); + return (dump_flags_t)((std::underlying_type::type)lhs + | (std::underlying_type::type)rhs); } static inline dump_flags_t operator& (dump_flags_t lhs, dump_flags_t rhs) { - return (dump_flags_t)((int)lhs & (int)rhs); + return (dump_flags_t)((std::underlying_type::type)lhs + & (std::underlying_type::type)rhs); } static inline dump_flags_t operator~ (dump_flags_t flags) { - return (dump_flags_t)~((int)flags); + return (dump_flags_t)~((std::underlying_type::type)flags); } static inline dump_flags_t & operator|= (dump_flags_t &lhs, dump_flags_t rhs) { - lhs = (dump_flags_t)((int)lhs | (int)rhs); + lhs = (dump_flags_t)((std::underlying_type::type)lhs + | (std::underlying_type::type)rhs); return lhs; } static inline dump_flags_t & operator&= (dump_flags_t &lhs, dump_flags_t rhs) { - lhs = (dump_flags_t)((int)lhs & (int)rhs); + lhs = (dump_flags_t)((std::underlying_type::type)lhs + & (std::underlying_type::type)rhs); return lhs; } @@ -275,13 +282,15 @@ typedef enum optgroup_flag optgroup_flags_t; static inline optgroup_flags_t operator| (optgroup_flags_t lhs, optgroup_flags_t rhs) { - return (optgroup_flags_t)((int)lhs | (int)rhs); + return (optgroup_flags_t)((std::underlying_type::type)lhs + | (std::underlying_type::type)rhs); } static inline optgroup_flags_t & operator|= (optgroup_flags_t &lhs, optgroup_flags_t rhs) { - lhs = (optgroup_flags_t)((int)lhs | (int)rhs); + lhs = (optgroup_flags_t)((std::underlying_type::type)lhs + | (std::underlying_type::type)rhs); return lhs; } diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c index 0ca4a949612..1cd1597359e 100644 --- a/gcc/gimple-pretty-print.c +++ b/gcc/gimple-pretty-print.c @@ -677,11 +677,18 @@ dump_gimple_assign (pretty_printer *buffer, const gassign *gs, int spc, } if (gimple_num_ops (gs) == 2) - dump_unary_rhs (buffer, gs, spc, flags); + dump_unary_rhs (buffer, gs, spc, + ((flags & TDF_GIMPLE) + && gimple_assign_rhs_class (gs) != GIMPLE_SINGLE_RHS) + ? (flags | TDF_GIMPLE_VAL) : flags); else if (gimple_num_ops (gs) == 3) - dump_binary_rhs (buffer, gs, spc, flags); + dump_binary_rhs (buffer, gs, spc, + (flags & TDF_GIMPLE) + ? (flags | TDF_GIMPLE_VAL) : flags); else if (gimple_num_ops (gs) == 4) - dump_ternary_rhs (buffer, gs, spc, flags); + dump_ternary_rhs (buffer, gs, spc, + (flags & TDF_GIMPLE) + ? (flags | TDF_GIMPLE_VAL) : flags); else gcc_unreachable (); if (!(flags & TDF_RHS_ONLY)) @@ -1085,11 +1092,15 @@ dump_gimple_cond (pretty_printer *buffer, const gcond *gs, int spc, { if (!(flags & TDF_RHS_ONLY)) pp_string (buffer, "if ("); - dump_generic_node (buffer, gimple_cond_lhs (gs), spc, flags, false); + dump_generic_node (buffer, gimple_cond_lhs (gs), spc, + flags | ((flags & TDF_GIMPLE) ? TDF_GIMPLE_VAL : TDF_NONE), + false); pp_space (buffer); pp_string (buffer, op_symbol_code (gimple_cond_code (gs))); pp_space (buffer); - dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false); + dump_generic_node (buffer, gimple_cond_rhs (gs), spc, + flags | ((flags & TDF_GIMPLE) ? TDF_GIMPLE_VAL : TDF_NONE), + false); if (!(flags & TDF_RHS_ONLY)) { edge_iterator ei; diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c index 81d86ebf97d..30a3945c37c 100644 --- a/gcc/tree-pretty-print.c +++ b/gcc/tree-pretty-print.c @@ -2873,10 +2873,18 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags, break; /* Unary arithmetic and logic expressions. */ + case ADDR_EXPR: + if (flags & TDF_GIMPLE_VAL) + { + pp_string (pp, "_Literal ("); + dump_generic_node (pp, TREE_TYPE (node), spc, + flags & ~TDF_GIMPLE_VAL, false); + pp_character (pp, ')'); + } + /* Fallthru. */ case NEGATE_EXPR: case BIT_NOT_EXPR: case TRUTH_NOT_EXPR: - case ADDR_EXPR: case PREDECREMENT_EXPR: case PREINCREMENT_EXPR: case INDIRECT_REF: