From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id 8978F3858430; Tue, 1 Mar 2022 08:00:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8978F3858430 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Tom de Vries To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-7424] [nvptx] Add nvptx-gen.h and nvptx-gen.opt X-Act-Checkin: gcc X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: 22adaa5e565a0355dc013b4c1eeefd8ff4a96d9a X-Git-Newrev: d59d13c89503baf92d14b04c05708a6296916fad Message-Id: <20220301080001.8978F3858430@sourceware.org> Date: Tue, 1 Mar 2022 08:00:01 +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: Tue, 01 Mar 2022 08:00:01 -0000 https://gcc.gnu.org/g:d59d13c89503baf92d14b04c05708a6296916fad commit r12-7424-gd59d13c89503baf92d14b04c05708a6296916fad Author: Tom de Vries Date: Fri Feb 25 11:49:01 2022 +0100 [nvptx] Add nvptx-gen.h and nvptx-gen.opt Use nvptx-sm.def to generate new files nvptx-gen.h and nvptx-gen.opt, and: - include nvptx-gen.h in nvptx.h, and - add nvptx-gen.opt to extra_options (before nvptx.opt, in case that matters). Tested on nvptx. gcc/ChangeLog: 2022-02-25 Tom de Vries * config.gcc (nvptx*-*-*): Add nvptx/nvptx-gen.opt to extra_options. * config/nvptx/gen-copyright.sh: New file. * config/nvptx/gen-h.sh: New file. * config/nvptx/gen-opt.sh: New file. * config/nvptx/nvptx.h (TARGET_SM35, TARGET_SM53, TARGET_SM70) (TARGET_SM75, TARGET_SM80): Move ... * config/nvptx/nvptx-gen.h: ... here. New file, generate. * config/nvptx/nvptx.opt (Enum ptx_isa): Move ... * config/nvptx/nvptx-gen.opt: ... here. New file, generate. * config/nvptx/t-nvptx ($(srcdir)/config/nvptx/nvptx-gen.h) ($(srcdir)/config/nvptx/nvptx-gen.opt): New make target. Diff: --- gcc/config.gcc | 1 + gcc/config/nvptx/gen-copyright.sh | 82 +++++++++++++++++++++++++++++++++++++++ gcc/config/nvptx/gen-h.sh | 44 +++++++++++++++++++++ gcc/config/nvptx/gen-opt.sh | 66 +++++++++++++++++++++++++++++++ gcc/config/nvptx/nvptx-gen.h | 29 ++++++++++++++ gcc/config/nvptx/nvptx-gen.opt | 42 ++++++++++++++++++++ gcc/config/nvptx/nvptx.h | 6 +-- gcc/config/nvptx/nvptx.opt | 22 ----------- gcc/config/nvptx/t-nvptx | 17 ++++++++ 9 files changed, 282 insertions(+), 27 deletions(-) diff --git a/gcc/config.gcc b/gcc/config.gcc index 2cc5aeec9e4..3833bfa16a9 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -477,6 +477,7 @@ nvptx-*-*) cpu_type=nvptx c_target_objs="nvptx-c.o" cxx_target_objs="nvptx-c.o" + extra_options="${extra_options} nvptx/nvptx-gen.opt" ;; or1k*-*-*) cpu_type=or1k diff --git a/gcc/config/nvptx/gen-copyright.sh b/gcc/config/nvptx/gen-copyright.sh new file mode 100644 index 00000000000..79f48995acc --- /dev/null +++ b/gcc/config/nvptx/gen-copyright.sh @@ -0,0 +1,82 @@ +#!/bin/sh + +# Copyright (C) 2022 Free Software Foundation, Inc. +# +# This file is part of GCC. +# +# GCC is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GCC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +style="$1" +case $style in + opt) + ;; + c) + first=true + ;; + *) + echo "Unknown style: \"$style\"" + exit 1 + ;; +esac + +( cat <. +EOF +) | while read line; do + case $style in + opt) + if [ "$line" = "" ]; then + echo ";" + else + echo "; $line" + fi + ;; + c) + if $first; then + echo "/* $line" + first=false + else + if [ "$line" = "" ]; then + echo + else + echo " $line" + fi + fi + ;; + esac +done + + +case $style in + c) + echo "*/" + ;; +esac diff --git a/gcc/config/nvptx/gen-h.sh b/gcc/config/nvptx/gen-h.sh new file mode 100644 index 00000000000..605f874055a --- /dev/null +++ b/gcc/config/nvptx/gen-h.sh @@ -0,0 +1,44 @@ +#!/bin/sh + +# Copyright (C) 2022 Free Software Foundation, Inc. +# +# This file is part of GCC. +# +# GCC is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GCC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +nvptx_sm_def="$1/nvptx-sm.def" +gen_copyright_sh="$1/gen-copyright.sh" + +sms=$(grep ^NVPTX_SM $nvptx_sm_def | sed 's/.*(//;s/,.*//') + +cat <= PTX_ISA_SM$sm) +EOF +done diff --git a/gcc/config/nvptx/gen-opt.sh b/gcc/config/nvptx/gen-opt.sh new file mode 100644 index 00000000000..5248ed25090 --- /dev/null +++ b/gcc/config/nvptx/gen-opt.sh @@ -0,0 +1,66 @@ +#!/bin/sh + +# Copyright (C) 2022 Free Software Foundation, Inc. +# +# This file is part of GCC. +# +# GCC is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GCC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +nvptx_sm_def="$1/nvptx-sm.def" +gen_copyright_sh="$1/gen-copyright.sh" + +sms=$(grep ^NVPTX_SM $nvptx_sm_def | sed 's/.*(//;s/,.*//') + +last= +for sm in $sms; do + last="$sm" +done + +cat <. +*/ + +#define TARGET_SM30 (ptx_isa_option >= PTX_ISA_SM30) +#define TARGET_SM35 (ptx_isa_option >= PTX_ISA_SM35) +#define TARGET_SM53 (ptx_isa_option >= PTX_ISA_SM53) +#define TARGET_SM70 (ptx_isa_option >= PTX_ISA_SM70) +#define TARGET_SM75 (ptx_isa_option >= PTX_ISA_SM75) +#define TARGET_SM80 (ptx_isa_option >= PTX_ISA_SM80) diff --git a/gcc/config/nvptx/nvptx-gen.opt b/gcc/config/nvptx/nvptx-gen.opt new file mode 100644 index 00000000000..b6d433e6292 --- /dev/null +++ b/gcc/config/nvptx/nvptx-gen.opt @@ -0,0 +1,42 @@ +; -*- buffer-read-only: t -*- +; Generated automatically by gen-opt.sh from nvptx-sm.def. + +; Copyright (C) 2022 Free Software Foundation, Inc. +; +; This file is part of GCC. +; +; GCC is free software; you can redistribute it and/or modify it under +; the terms of the GNU General Public License as published by the Free +; Software Foundation; either version 3, or (at your option) any later +; version. +; +; GCC is distributed in the hope that it will be useful, but WITHOUT ANY +; WARRANTY; without even the implied warranty of MERCHANTABILITY or +; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +; for more details. +; +; You should have received a copy of the GNU General Public License +; along with GCC; see the file COPYING3. If not see +; . + +Enum +Name(ptx_isa) Type(int) +Known PTX ISA versions (for use with the -misa= option): + +EnumValue +Enum(ptx_isa) String(sm_30) Value(PTX_ISA_SM30) + +EnumValue +Enum(ptx_isa) String(sm_35) Value(PTX_ISA_SM35) + +EnumValue +Enum(ptx_isa) String(sm_53) Value(PTX_ISA_SM53) + +EnumValue +Enum(ptx_isa) String(sm_70) Value(PTX_ISA_SM70) + +EnumValue +Enum(ptx_isa) String(sm_75) Value(PTX_ISA_SM75) + +EnumValue +Enum(ptx_isa) String(sm_80) Value(PTX_ISA_SM80) diff --git a/gcc/config/nvptx/nvptx.h b/gcc/config/nvptx/nvptx.h index edffd088b15..4ab412bc7d8 100644 --- a/gcc/config/nvptx/nvptx.h +++ b/gcc/config/nvptx/nvptx.h @@ -86,11 +86,7 @@ #define Pmode (TARGET_ABI64 ? DImode : SImode) #define STACK_SIZE_MODE Pmode -#define TARGET_SM35 (ptx_isa_option >= PTX_ISA_SM35) -#define TARGET_SM53 (ptx_isa_option >= PTX_ISA_SM53) -#define TARGET_SM70 (ptx_isa_option >= PTX_ISA_SM70) -#define TARGET_SM75 (ptx_isa_option >= PTX_ISA_SM75) -#define TARGET_SM80 (ptx_isa_option >= PTX_ISA_SM80) +#include "nvptx-gen.h" #define TARGET_PTX_6_0 (ptx_version_option >= PTX_VERSION_6_0) #define TARGET_PTX_6_3 (ptx_version_option >= PTX_VERSION_6_3) diff --git a/gcc/config/nvptx/nvptx.opt b/gcc/config/nvptx/nvptx.opt index f555ad1d8bf..c83ceb3568b 100644 --- a/gcc/config/nvptx/nvptx.opt +++ b/gcc/config/nvptx/nvptx.opt @@ -51,28 +51,6 @@ mgomp Target Mask(GOMP) Generate code for OpenMP offloading: enables -msoft-stack and -muniform-simt. -Enum -Name(ptx_isa) Type(int) -Known PTX ISA versions (for use with the -misa= option): - -EnumValue -Enum(ptx_isa) String(sm_30) Value(PTX_ISA_SM30) - -EnumValue -Enum(ptx_isa) String(sm_35) Value(PTX_ISA_SM35) - -EnumValue -Enum(ptx_isa) String(sm_53) Value(PTX_ISA_SM53) - -EnumValue -Enum(ptx_isa) String(sm_70) Value(PTX_ISA_SM70) - -EnumValue -Enum(ptx_isa) String(sm_75) Value(PTX_ISA_SM75) - -EnumValue -Enum(ptx_isa) String(sm_80) Value(PTX_ISA_SM80) - ; Default needs to be in sync with default in ASM_SPEC in nvptx.h. misa= Target RejectNegative ToLower Joined Enum(ptx_isa) Var(ptx_isa_option) Init(PTX_ISA_SM35) diff --git a/gcc/config/nvptx/t-nvptx b/gcc/config/nvptx/t-nvptx index b1707665a9f..f17fc9c19aa 100644 --- a/gcc/config/nvptx/t-nvptx +++ b/gcc/config/nvptx/t-nvptx @@ -13,4 +13,21 @@ mkoffload$(exeext): mkoffload.o collect-utils.o libcommon-target.a $(LIBIBERTY) +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ mkoffload.o collect-utils.o libcommon-target.a $(LIBIBERTY) $(LIBS) +$(srcdir)/config/nvptx/nvptx.h: $(srcdir)/config/nvptx/nvptx-gen.h +$(srcdir)/config/nvptx/nvptx-gen.h: s-nvptx-gen-h; @true +s-nvptx-gen-h: $(srcdir)/config/nvptx/nvptx-sm.def + $(SHELL) $(srcdir)/config/nvptx/gen-h.sh "$(srcdir)/config/nvptx" \ + > tmp-nvptx-gen.h + $(SHELL) $(srcdir)/../move-if-change \ + tmp-nvptx-gen.h $(srcdir)/config/nvptx/nvptx-gen.h + $(STAMP) s-nvptx-gen-h + +$(srcdir)/config/nvptx/nvptx-gen.opt: s-nvptx-gen-opt; @true +s-nvptx-gen-opt: $(srcdir)/config/nvptx/nvptx-sm.def + $(SHELL) $(srcdir)/config/nvptx/gen-opt.sh "$(srcdir)/config/nvptx" \ + > tmp-nvptx-gen.opt + $(SHELL) $(srcdir)/../move-if-change \ + tmp-nvptx-gen.opt $(srcdir)/config/nvptx/nvptx-gen.opt + $(STAMP) s-nvptx-gen-opt + MULTILIB_OPTIONS = mgomp