From patchwork Tue Jun 18 09:22:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 1117759 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-503152-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="d0B6G4Iu"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45SjKN5VqPz9s7h for ; Tue, 18 Jun 2019 19:22:32 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=eSSkj7hWcTrbrKVqV tDQ7WEK6vfOWHPMeIBjCo0WV97cJLLvi3DleeEoTiA3mgtkVEc8b09qjjR2L4RJ+ Vwi4WjXDJ4BOy/8P5rRPGxsSXkqppApQgZsqz3H7DAiAPnFJ0rUJ54f/VtyitB4E Yu1a59bmAYwfLXOG51vqXRphTE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=TUyjgadKZ0cbpOeyppdRsEw C1bM=; b=d0B6G4IuPVLY9WNEEqUg5Ddx8bljT8dHo4W3nmhbQzxlg1ZuQTevTc0 pQcXq1bC1dlWzfUHTAhg5MPqWPJHM3LL4mzvFFSBmb9gX88mCH6BmD8wB/NCpyeM F6KjRwmkpkZwvWxjaYzbL+3vLfaG0ZBZIxUAH7TDDl3iid2mBK+w= Received: (qmail 12127 invoked by alias); 18 Jun 2019 09:22:23 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 12118 invoked by uid 89); 18 Jun 2019 09:22:23 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 18 Jun 2019 09:22:22 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id C6D6FAD09; Tue, 18 Jun 2019 09:22:19 +0000 (UTC) Subject: [nvptx, committed] Use define_insn parametrization To: Jakub Jelinek Cc: Alexander Monakov , "gcc-patches@gcc.gnu.org" References: <20190617150953.GS19695@tucnak> From: Tom de Vries Message-ID: Date: Tue, 18 Jun 2019 11:22:18 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190617150953.GS19695@tucnak> X-IsSubscribed: yes [ was: Re: [nvptx] Fix missing mode warnings in nvptx.md, omp part ] On 17-06-19 17:09, Jakub Jelinek wrote: > On Mon, Jun 17, 2019 at 04:53:24PM +0200, Tom de Vries wrote: >> Updated accordingly, and committed as attached. > > Note, current trunk allows one to define expanders that take mode as the > first argument, so you could > (define_insn "@set_softstack_" > [(unspec [(match_operand:P 0 "nvptx_register_operand" "R")] > UNSPEC_SET_SOFTSTACK)] > "TARGET_SOFT_STACK" > ... > and then just use gen_set_softstack (Pmode, arg). Thanks, that's useful. Committed as attached. Thanks, - Tom [nvptx] Use define_insn parametrization Parametrize some define_insn to simplify code in define_expands generating those insns. Build and reg-tested on x86_64 with nvptx accelerator. 2019-06-18 Tom de Vries * config/nvptx/nvptx-protos.h (gen_set_softstack_insn): Remove. * config/nvptx/nvptx.c (gen_set_softstack_insn): Remove. * config/nvptx/nvptx.md (define_insn "set_softstack_"): Rename to ... (define_insn "@set_softstack_"): ... this. (define_insn "omp_simt_enter_"): Rename to ... (define_insn "@omp_simt_enter_"): ... this. (define_insn "omp_simt_exit_"): Rename to ... (define_insn "@omp_simt_exit_"): ... this. --- gcc/config/nvptx/nvptx-protos.h | 1 - gcc/config/nvptx/nvptx.c | 12 ------------ gcc/config/nvptx/nvptx.md | 30 +++++++++--------------------- 3 files changed, 9 insertions(+), 34 deletions(-) diff --git a/gcc/config/nvptx/nvptx-protos.h b/gcc/config/nvptx/nvptx-protos.h index 061897a3921..be09a15e49c 100644 --- a/gcc/config/nvptx/nvptx-protos.h +++ b/gcc/config/nvptx/nvptx-protos.h @@ -57,6 +57,5 @@ extern const char *nvptx_output_set_softstack (unsigned); extern const char *nvptx_output_simt_enter (rtx, rtx, rtx); extern const char *nvptx_output_simt_exit (rtx); extern const char *nvptx_output_red_partition (rtx, rtx); -extern rtx gen_set_softstack_insn (rtx); #endif #endif diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c index aa4a67fbead..c53a1ae9f26 100644 --- a/gcc/config/nvptx/nvptx.c +++ b/gcc/config/nvptx/nvptx.c @@ -112,18 +112,6 @@ enum nvptx_data_area DATA_AREA_MAX }; -rtx -gen_set_softstack_insn (rtx op) -{ - gcc_assert (GET_MODE (op) == Pmode); - if (GET_MODE (op) == DImode) - return gen_set_softstack_di (op); - else if (GET_MODE (op) == SImode) - return gen_set_softstack_si (op); - else - gcc_unreachable (); -} - /* We record the data area in the target symbol flags. */ #define SYMBOL_DATA_AREA(SYM) \ (nvptx_data_area)((SYMBOL_REF_FLAGS (SYM) >> SYMBOL_FLAG_MACH_DEP_SHIFT) \ diff --git a/gcc/config/nvptx/nvptx.md b/gcc/config/nvptx/nvptx.md index 84c0ea45431..58a18fe21cf 100644 --- a/gcc/config/nvptx/nvptx.md +++ b/gcc/config/nvptx/nvptx.md @@ -1025,8 +1025,8 @@ "" { if (TARGET_SOFT_STACK) - emit_insn (gen_set_softstack_insn (gen_rtx_REG (Pmode, - SOFTSTACK_PREV_REGNUM))); + emit_insn (gen_set_softstack (Pmode, gen_rtx_REG (Pmode, + SOFTSTACK_PREV_REGNUM))); emit_jump_insn (gen_return ()); DONE; }) @@ -1059,7 +1059,7 @@ { emit_move_insn (stack_pointer_rtx, gen_rtx_MINUS (Pmode, stack_pointer_rtx, operands[1])); - emit_insn (gen_set_softstack_insn (stack_pointer_rtx)); + emit_insn (gen_set_softstack (Pmode, stack_pointer_rtx)); emit_move_insn (operands[0], virtual_stack_dynamic_rtx); DONE; } @@ -1071,7 +1071,7 @@ DONE; }) -(define_insn "set_softstack_" +(define_insn "@set_softstack_" [(unspec [(match_operand:P 0 "nvptx_register_operand" "R")] UNSPEC_SET_SOFTSTACK)] "TARGET_SOFT_STACK" @@ -1087,7 +1087,7 @@ if (TARGET_SOFT_STACK) { emit_move_insn (operands[0], operands[1]); - emit_insn (gen_set_softstack_insn (operands[0])); + emit_insn (gen_set_softstack (Pmode, operands[0])); } DONE; }) @@ -1237,7 +1237,7 @@ ;; Patterns for OpenMP SIMD-via-SIMT lowering -(define_insn "omp_simt_enter_" +(define_insn "@omp_simt_enter_" [(set (match_operand:P 0 "nvptx_register_operand" "=R") (unspec_volatile:P [(match_operand:P 1 "nvptx_nonmemory_operand" "Ri") (match_operand:P 2 "nvptx_nonmemory_operand" "Ri")] @@ -1261,13 +1261,7 @@ cfun->machine->simt_stack_align = MAX (UINTVAL (operands[2]), cfun->machine->simt_stack_align); cfun->machine->has_simtreg = true; - gcc_assert (GET_MODE (operands[0]) == Pmode); - if (GET_MODE (operands[0]) == DImode) - emit_insn (gen_omp_simt_enter_di (operands[0], operands[1], operands[2])); - else if (GET_MODE (operands[0]) == SImode) - emit_insn (gen_omp_simt_enter_si (operands[0], operands[1], operands[2])); - else - gcc_unreachable (); + emit_insn (gen_omp_simt_enter (Pmode, operands[0], operands[1], operands[2])); DONE; }) @@ -1275,17 +1269,11 @@ [(match_operand 0 "nvptx_register_operand" "R")] "" { - gcc_assert (GET_MODE (operands[0]) == Pmode); - if (GET_MODE (operands[0]) == DImode) - emit_insn (gen_omp_simt_exit_di (operands[0])); - else if (GET_MODE (operands[0]) == SImode) - emit_insn (gen_omp_simt_exit_si (operands[0])); - else - gcc_unreachable (); + emit_insn (gen_omp_simt_exit (Pmode, operands[0])); DONE; }) -(define_insn "omp_simt_exit_" +(define_insn "@omp_simt_exit_" [(unspec_volatile [(match_operand:P 0 "nvptx_register_operand" "R")] UNSPECV_SIMT_EXIT)] ""