From patchwork Tue Oct 5 12:53:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 45883 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0B0B9385DC2C for ; Tue, 5 Oct 2021 12:55:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0B0B9385DC2C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1633438556; bh=cT+IywcPocw7vI6BfBYdKdk6za339vUMtYXY8hAvKVs=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=yh7W3YSflQmwKGnN9He2pEgu1e71m8SuUFgLcWi8m3eTJk1E6CmLDRaSZRb4oH+NZ VOVjsL1lSfDmXyuSaCU4CKol24a4CfNw8IYJIm3woz5ygM0QVet5GUk8b9Ppiiz6oh gzCzzMwOtNZrwOZfXidJxoNg6K0HuUxqVz8d1XgE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 7872E385C408 for ; Tue, 5 Oct 2021 12:53:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7872E385C408 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 4E6FA1FD57 for ; Tue, 5 Oct 2021 12:53:45 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3A93613C50 for ; Tue, 5 Oct 2021 12:53:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id oOYrDdlKXGHveAAAMHmgww (envelope-from ) for ; Tue, 05 Oct 2021 12:53:45 +0000 Date: Tue, 5 Oct 2021 14:53:44 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] More consistently dump GIMPLE FE consumable stmts Message-ID: <1q5o3517-5or1-1114-92s2-qpn3o6818p29@fhfr.qr> MIME-Version: 1.0 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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. Bootstrap & regtest pending on x86_64-unknown-linux-gnu. 2021-10-05 Richard Biener PR c/102605 * dumpfile.h (TDF_GIMPLE_VAL): New. Re-order and adjust TDF_* flags. * 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. --- gcc/dumpfile.h | 33 ++++++++++++++++++--------------- gcc/gimple-pretty-print.c | 21 ++++++++++++++++----- gcc/tree-pretty-print.c | 10 +++++++++- 3 files changed, 43 insertions(+), 21 deletions(-) diff --git a/gcc/dumpfile.h b/gcc/dumpfile.h index 6c7758dd2fb..b2a728e7395 100644 --- a/gcc/dumpfile.h +++ b/gcc/dumpfile.h @@ -140,23 +140,29 @@ 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), + + /* All -fdump- flags. */ + TDF_ALL_VALUES = (1 << 23) - 1, + /* 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,16 +181,16 @@ 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 @@ -192,16 +198,13 @@ enum dump_flag | MSG_PRIORITY_REEMITTED), /* Dumping for -fcompare-debug. */ - TDF_COMPARE_DEBUG = (1 << 28), + TDF_COMPARE_DEBUG = (1 << 29), - /* For error. */ - TDF_ERROR = (1 << 26), + /* Dump a GIMPLE value which means wrapping certain things with _Literal. */ + TDF_GIMPLE_VAL = (1 << 30), - /* Dumping for range path solver. */ - TDF_THREADING = (1 << 27), - - /* All values. */ - TDF_ALL_VALUES = (1 << 29) - 1 + /* For error. */ + TDF_ERROR = (1 << 31), }; /* Dump flags type. */ diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c index 0ca4a949612..72417a08104 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 : (flags | TDF_GIMPLE_VAL)); 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: