From patchwork Wed Sep 4 12:09:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 1980722 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=1VuKkU86; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WzLsf00FWz1yg3 for ; Wed, 4 Sep 2024 22:10:13 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D3509385E003 for ; Wed, 4 Sep 2024 12:10:11 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id 3644C3858C98 for ; Wed, 4 Sep 2024 12:09:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3644C3858C98 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=baylibre.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3644C3858C98 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::335 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725451790; cv=none; b=x/GpncHzP4TYHP5030r+DzKSgvsNPdEp+NITOOc89+crPugh1g/n8AJcXpPH3PvID2JDx56LWt67+PzOAM/Js6E19aMjulTI+zataTQL2HMAuCgIxXbwyFbtakjeIy10+HWilmJJklfIXMWOkE1vXYcOlvFbl1KyCyJjR+5pLRM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725451790; c=relaxed/simple; bh=wcqygTUHrGEStPVw0MYCfp7zKXXROW10eJW0RHIsHLk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=j7b1qK1J9hR/supULPG+R37k3uK7f+MQqtHrJaHg5VsbgzKmWeHWudo3Cqr8cwntdmBqBMoQ2oaKydFIabrescc0LLwqsy8JG3KhWGu92TzZPdGVc92szwKtH/ixtO78n6SiZve5415S7RaTpREeCW0TTcB1suND8swFaM35ZHQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-42bbf138477so41949965e9.2 for ; Wed, 04 Sep 2024 05:09:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1725451785; x=1726056585; darn=gcc.gnu.org; h=mime-version:message-id:date:user-agent:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=Vnt8gqSO/d4Owb1IRU2OS8ncYYtDsXdeUiQXfGugyA4=; b=1VuKkU86e3YwHlHDAawgmoQqVVW3bUziKFXlaGCjEkSPNsYnn/DKpES+Z3RkIm/j30 W7aHP4WLNcaAoeGQ4pHCzL58MzaLqK2D+/0BqZ3qN2flc2Pc5h6AftCwodK7pZFq8XcN BPWl5hTBGzIcAc6+HgIz2g72q3LitvdRqWvhodXZqPMikSqKAk9nmEflTF976Y9zkdLk iArqRQA1bUCuqpYbKztvIL/+xiwUDW2Cn3B/Z2MDKzl+vx/Mp6d76U0k/7oGy0EGNZqf EAWqMiYHDUZnHqnPPdIv6vtIgTVGXGRKKWLG4LYG6Kg8BR6k0GVy05k4bTYzwm/+6tA1 J4Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725451785; x=1726056585; h=mime-version:message-id:date:user-agent:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Vnt8gqSO/d4Owb1IRU2OS8ncYYtDsXdeUiQXfGugyA4=; b=DeJTq+nW7aqwsLbJDn+kH/NvkHDxHd9bMUWRqz4j/bQYj48BneEXCWr2KQpnAE7un2 TuCfDPb+avGEkKpEEzEQ7eZML75mm/vw/SmfMjSkvsiVSgRAaQZ3VmBtuGdDL64r25j7 1WqA+UpwXniPQmCtiv4j+rjKmIrnd4ao00ZXiMDmVrxszFpB9Gg4NrEERu0+edgxqUV6 l4/F1WZRZE0YQQjh+4MBVGbQ8ivvfxXwcf0gImtdteb5h0ZpV6p2KA2tzrW0aeSvbveS wZwlJwX1IgHEGW6vhXQeKdMopQngCOX57dRM8MuPhTnPMG5NE9dl9L8u2BLiL8Z3A2/r 9LqA== X-Gm-Message-State: AOJu0YxdyASzunEpAzwfhPOqmxt5M5UcRQMc0Qy0oRcc8QqQx4lXdbMb 8MpQs8pSHLJeSuFON54nzcUEwgMO6OWT7YpPkJICui0PGJXbV9lkGcLFBVnI5Xw6zcLTHZP15DQ A X-Google-Smtp-Source: AGHT+IG2GVv9CwshPpYwFWVMtbFVNICoWyGfYHcnzOFdGz1Yrgo/gzOSjg9V6m2KapjdwPVMuqwACg== X-Received: by 2002:a05:600c:3ca0:b0:426:5e8e:410a with SMTP id 5b1f17b1804b1-42c8810319emr56083995e9.24.1725451784914; Wed, 04 Sep 2024 05:09:44 -0700 (PDT) Received: from euler.schwinge.ddns.net (p200300c8b733b9005e8fc6f38b6af531.dip0.t-ipconnect.de. [2003:c8:b733:b900:5e8f:c6f3:8b6a:f531]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-374c8e4f1b3sm9132209f8f.27.2024.09.04.05.09.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 05:09:43 -0700 (PDT) From: Thomas Schwinge To: gcc-patches@gcc.gnu.org Cc: Tom de Vries Subject: nvptx: Use 'enum ptx_version', 'enum ptx_isa' instead of 'int' User-Agent: Notmuch/0.30+8~g47a4bad (https://notmuchmail.org) Emacs/29.4 (x86_64-pc-linux-gnu) Date: Wed, 04 Sep 2024 14:09:41 +0200 Message-ID: <87v7zbliwq.fsf@euler.schwinge.ddns.net> MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Hi! Pushed to trunk branch in commit fee2fbedbb43ad7a017a33ed2b820be79b75e7e5 "nvptx: Use 'enum ptx_version', 'enum ptx_isa' instead of 'int'", see attached. Grüße Thomas From fee2fbedbb43ad7a017a33ed2b820be79b75e7e5 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Mon, 22 Jul 2024 10:49:16 +0200 Subject: [PATCH] nvptx: Use 'enum ptx_version', 'enum ptx_isa' instead of 'int' This allows getting rid of the respective type casts. No change in behavior intended. gcc/ * config/nvptx/gen-opt.sh: Use 'enum ptx_isa' instead of 'int'. * config/nvptx/nvptx-gen.opt: Regenerate. * config/nvptx/nvptx.opt: Use 'enum ptx_version' instead of 'int'. * config/nvptx/nvptx-opts.h (enum ptx_isa): Add 'PTX_ISA_unset'. (enum ptx_version): Add 'PTX_VERSION_unset'. * config/nvptx/nvptx-c.cc (nvptx_cpu_cpp_builtins): Adjust. * config/nvptx/nvptx.cc (default_ptx_version_option) (handle_ptx_version_option, nvptx_option_override) (nvptx_file_start): Likewise. --- gcc/config/nvptx/gen-opt.sh | 14 +++++++++++++- gcc/config/nvptx/nvptx-c.cc | 6 ++---- gcc/config/nvptx/nvptx-gen.opt | 2 +- gcc/config/nvptx/nvptx-opts.h | 4 +++- gcc/config/nvptx/nvptx.cc | 24 ++++++++++++------------ gcc/config/nvptx/nvptx.opt | 9 ++++++--- 6 files changed, 37 insertions(+), 22 deletions(-) diff --git a/gcc/config/nvptx/gen-opt.sh b/gcc/config/nvptx/gen-opt.sh index 3f7838251d2..6022f51f897 100644 --- a/gcc/config/nvptx/gen-opt.sh +++ b/gcc/config/nvptx/gen-opt.sh @@ -38,12 +38,24 @@ echo . $gen_copyright_sh opt +# Not emitting the following here (in addition to having it in 'nvptx.opt'), as +# we'll otherwise run into: +# +# gtyp-input.list:10: file [...]/gcc/config/nvptx/nvptx-opts.h specified more than once for language (all) +# make[2]: *** [Makefile:2981: s-gtype] Error 1 +: || +cat <. Enum -Name(ptx_isa) Type(int) +Name(ptx_isa) Type(enum ptx_isa) Known PTX ISA target architectures (for use with the -misa= option): EnumValue diff --git a/gcc/config/nvptx/nvptx-opts.h b/gcc/config/nvptx/nvptx-opts.h index f8975327223..fb5147c143e 100644 --- a/gcc/config/nvptx/nvptx-opts.h +++ b/gcc/config/nvptx/nvptx-opts.h @@ -22,6 +22,7 @@ enum ptx_isa { + PTX_ISA_unset, #define NVPTX_SM(XX, SEP) PTX_ISA_SM ## XX SEP #define NVPTX_SM_SEP , #include "nvptx-sm.def" @@ -31,7 +32,8 @@ enum ptx_isa enum ptx_version { - PTX_VERSION_default, + PTX_VERSION_unset, + PTX_VERSION_default = PTX_VERSION_unset, PTX_VERSION_3_0, PTX_VERSION_3_1, PTX_VERSION_4_2, diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc index 2a8f713c680..144b8d0c874 100644 --- a/gcc/config/nvptx/nvptx.cc +++ b/gcc/config/nvptx/nvptx.cc @@ -231,8 +231,7 @@ first_ptx_version_supporting_sm (enum ptx_isa sm) static enum ptx_version default_ptx_version_option (void) { - enum ptx_version first - = first_ptx_version_supporting_sm ((enum ptx_isa) ptx_isa_option); + enum ptx_version first = first_ptx_version_supporting_sm (ptx_isa_option); /* Pick a version that supports the sm. */ enum ptx_version res = first; @@ -311,20 +310,21 @@ sm_version_to_string (enum ptx_isa sm) static void handle_ptx_version_option (void) { - if (!OPTION_SET_P (ptx_version_option) - || ptx_version_option == PTX_VERSION_default) + if (!OPTION_SET_P (ptx_version_option)) + gcc_checking_assert (ptx_version_option == PTX_VERSION_default); + + if (ptx_version_option == PTX_VERSION_default) { ptx_version_option = default_ptx_version_option (); return; } - enum ptx_version first - = first_ptx_version_supporting_sm ((enum ptx_isa) ptx_isa_option); + enum ptx_version first = first_ptx_version_supporting_sm (ptx_isa_option); if (ptx_version_option < first) error ("PTX version (%<-mptx%>) needs to be at least %s to support selected" " %<-misa%> (sm_%s)", ptx_version_to_string (first), - sm_version_to_string ((enum ptx_isa)ptx_isa_option)); + sm_version_to_string (ptx_isa_option)); } /* Implement TARGET_OPTION_OVERRIDE. */ @@ -336,7 +336,9 @@ nvptx_option_override (void) /* Via nvptx 'OPTION_DEFAULT_SPECS', '-misa' always appears on the command line; but handle the case that the compiler is not run via the driver. */ - if (!OPTION_SET_P (ptx_isa_option)) + gcc_checking_assert ((ptx_isa_option == PTX_ISA_unset) + == (!OPTION_SET_P (ptx_isa_option))); + if (ptx_isa_option == PTX_ISA_unset) fatal_error (UNKNOWN_LOCATION, "%<-march=%> must be specified"); handle_ptx_version_option (); @@ -5953,13 +5955,11 @@ nvptx_file_start (void) fputs ("// BEGIN PREAMBLE\n", asm_out_file); fputs ("\t.version\t", asm_out_file); - fputs (ptx_version_to_string ((enum ptx_version)ptx_version_option), - asm_out_file); + fputs (ptx_version_to_string (ptx_version_option), asm_out_file); fputs ("\n", asm_out_file); fputs ("\t.target\tsm_", asm_out_file); - fputs (sm_version_to_string ((enum ptx_isa)ptx_isa_option), - asm_out_file); + fputs (sm_version_to_string (ptx_isa_option), asm_out_file); fputs ("\n", asm_out_file); fprintf (asm_out_file, "\t.address_size %d\n", GET_MODE_BITSIZE (Pmode)); diff --git a/gcc/config/nvptx/nvptx.opt b/gcc/config/nvptx/nvptx.opt index deb006663d7..c0407405228 100644 --- a/gcc/config/nvptx/nvptx.opt +++ b/gcc/config/nvptx/nvptx.opt @@ -17,6 +17,9 @@ ; along with GCC; see the file COPYING3. If not see ; . +HeaderInclude +config/nvptx/nvptx-opts.h + ; It's not clear whether this was ever build/tested/used, so this is no longer ; exposed to the user. ;m32 @@ -53,7 +56,7 @@ Target Mask(GOMP) Generate code for OpenMP offloading: enables -msoft-stack and -muniform-simt. misa= -Target RejectNegative ToLower Joined Enum(ptx_isa) Var(ptx_isa_option) +Target RejectNegative ToLower Joined Enum(ptx_isa) Var(ptx_isa_option) Init(PTX_ISA_unset) Specify the PTX ISA target architecture to use. march= @@ -118,7 +121,7 @@ march-map=sm_90a Target RejectNegative Alias(misa=,sm_80) Enum -Name(ptx_version) Type(int) +Name(ptx_version) Type(enum ptx_version) Known PTX ISA versions (for use with the -mptx= option): EnumValue @@ -137,7 +140,7 @@ EnumValue Enum(ptx_version) String(_) Value(PTX_VERSION_default) mptx= -Target RejectNegative ToLower Joined Enum(ptx_version) Var(ptx_version_option) +Target RejectNegative ToLower Joined Enum(ptx_version) Var(ptx_version_option) Init(PTX_VERSION_unset) Specify the PTX ISA version to use. minit-regs= -- 2.34.1