From patchwork Tue Feb 22 13:53:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 51288 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 5F822383D827 for ; Tue, 22 Feb 2022 13:54:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5F822383D827 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1645538051; bh=8MoXp7fh09EC5iJF5NGbyQxYRcQc1wAG57blcGW8Ark=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=DtXv9VCMlTPTGk4FhISOmMBlpXuhWaMy2QMz3bccGdO+L8N0o60d0SJCVy/rE8NHS 5+oCHUOp0Z27uX397D7alLRWz9fzhXL6wBz8Xtbw6gVb0hihBXloFkbZfRxtdhSLJ6 Cp0ZvaSRkBqU5eY9XgADQRnyCJeAHlYeL9Ulbdv8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id BD17D3858032 for ; Tue, 22 Feb 2022 13:53:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BD17D3858032 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-out1.suse.de (Postfix) with ESMTPS id 80F3E21102 for ; Tue, 22 Feb 2022 13:53:40 +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 6EA0413B98 for ; Tue, 22 Feb 2022 13:53:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id xrmOGeTqFGLubgAAMHmgww (envelope-from ) for ; Tue, 22 Feb 2022 13:53:40 +0000 Date: Tue, 22 Feb 2022 14:53:39 +0100 To: gcc-patches@gcc.gnu.org Subject: [committed][nvptx] Add -mptx-comment Message-ID: <20220222135337.GA1196@delia.home> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-12.6 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, T_SCC_BODY_TEXT_LINE 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: Tom de Vries via Gcc-patches From: Tom de Vries Reply-To: Tom de Vries Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi, Add functionality that indicates which insns are added by -minit-regs, such that for instance we have for pr53465.s: ... // #APP // 9 "gcc/testsuite/gcc.c-torture/execute/pr53465.c" 1 // Start: Added by -minit-regs=3: // #NO_APP mov.u32 %r26, 0; // #APP // 9 "gcc/testsuite/gcc.c-torture/execute/pr53465.c" 1 // End: Added by -minit-regs=3: // #NO_APP ... Can be switched off using -mno-ptx-comment. Tested on nvptx. Committed to trunk. Thanks, - Tom [nvptx] Add -mptx-comment gcc/ChangeLog: 2022-02-21 Tom de Vries * config/nvptx/nvptx.cc (gen_comment): New function. (workaround_uninit_method_1, workaround_uninit_method_2) (workaround_uninit_method_3): : Use gen_comment. * config/nvptx/nvptx.opt (mptx-comment): New option. --- gcc/config/nvptx/nvptx.cc | 42 ++++++++++++++++++++++++++++++++++++++++++ gcc/config/nvptx/nvptx.opt | 3 +++ 2 files changed, 45 insertions(+) diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc index a37a6c78b41..981b91f7095 100644 --- a/gcc/config/nvptx/nvptx.cc +++ b/gcc/config/nvptx/nvptx.cc @@ -5372,6 +5372,17 @@ workaround_barsyncs (void) } #endif +static rtx +gen_comment (const char *s) +{ + const char *sep = " "; + size_t len = strlen (ASM_COMMENT_START) + strlen (sep) + strlen (s) + 1; + char *comment = (char *) alloca (len); + snprintf (comment, len, "%s%s%s", ASM_COMMENT_START, sep, s); + return gen_rtx_ASM_INPUT_loc (VOIDmode, ggc_strdup (comment), + cfun->function_start_locus); +} + /* Initialize all declared regs at function entry. Advantage : Fool-proof. Disadvantage: Potentially creates a lot of long live ranges and adds a lot @@ -5394,6 +5405,8 @@ workaround_uninit_method_1 (void) gcc_assert (CONST0_RTX (GET_MODE (reg))); start_sequence (); + if (nvptx_comment && first != NULL) + emit_insn (gen_comment ("Start: Added by -minit-regs=1")); emit_move_insn (reg, CONST0_RTX (GET_MODE (reg))); rtx_insn *inits = get_insns (); end_sequence (); @@ -5411,6 +5424,9 @@ workaround_uninit_method_1 (void) else insert_here = emit_insn_after (inits, insert_here); } + + if (nvptx_comment && insert_here != NULL) + emit_insn_after (gen_comment ("End: Added by -minit-regs=1"), insert_here); } /* Find uses of regs that are not defined on all incoming paths, and insert a @@ -5446,6 +5462,8 @@ workaround_uninit_method_2 (void) gcc_assert (CONST0_RTX (GET_MODE (reg))); start_sequence (); + if (nvptx_comment && first != NULL) + emit_insn (gen_comment ("Start: Added by -minit-regs=2:")); emit_move_insn (reg, CONST0_RTX (GET_MODE (reg))); rtx_insn *inits = get_insns (); end_sequence (); @@ -5463,6 +5481,9 @@ workaround_uninit_method_2 (void) else insert_here = emit_insn_after (inits, insert_here); } + + if (nvptx_comment && insert_here != NULL) + emit_insn_after (gen_comment ("End: Added by -minit-regs=2"), insert_here); } /* Find uses of regs that are not defined on all incoming paths, and insert a @@ -5531,6 +5552,27 @@ workaround_uninit_method_3 (void) } } + if (nvptx_comment) + FOR_EACH_BB_FN (bb, cfun) + { + if (single_pred_p (bb)) + continue; + + edge e; + edge_iterator ei; + FOR_EACH_EDGE (e, ei, bb->preds) + { + if (e->insns.r == NULL_RTX) + continue; + start_sequence (); + emit_insn (gen_comment ("Start: Added by -minit-regs=3:")); + emit_insn (e->insns.r); + emit_insn (gen_comment ("End: Added by -minit-regs=3:")); + e->insns.r = get_insns (); + end_sequence (); + } + } + commit_edge_insertions (); } diff --git a/gcc/config/nvptx/nvptx.opt b/gcc/config/nvptx/nvptx.opt index 08580071731..e56ec9288da 100644 --- a/gcc/config/nvptx/nvptx.opt +++ b/gcc/config/nvptx/nvptx.opt @@ -95,3 +95,6 @@ Specify the version of the ptx version to use. minit-regs= Target Var(nvptx_init_regs) IntegerRange(0, 3) Joined UInteger Init(3) Initialize ptx registers. + +mptx-comment +Target Var(nvptx_comment) Init(1) Undocumented