diff options
author | Tom de Vries <tdevries@suse.de> | 2022-02-25 11:49:01 +0100 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2022-03-01 08:58:36 +0100 |
commit | d59d13c89503baf92d14b04c05708a6296916fad (patch) | |
tree | 1fc7c4f552cca79736bb2a5ff74071248f5700af /gcc/config/nvptx | |
parent | 22adaa5e565a0355dc013b4c1eeefd8ff4a96d9a (diff) | |
download | gcc-d59d13c89503baf92d14b04c05708a6296916fad.zip gcc-d59d13c89503baf92d14b04c05708a6296916fad.tar.gz gcc-d59d13c89503baf92d14b04c05708a6296916fad.tar.bz2 |
[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 <tdevries@suse.de>
* 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.
Diffstat (limited to 'gcc/config/nvptx')
-rw-r--r-- | gcc/config/nvptx/gen-copyright.sh | 82 | ||||
-rw-r--r-- | gcc/config/nvptx/gen-h.sh | 44 | ||||
-rw-r--r-- | gcc/config/nvptx/gen-opt.sh | 66 | ||||
-rw-r--r-- | gcc/config/nvptx/nvptx-gen.h | 29 | ||||
-rw-r--r-- | gcc/config/nvptx/nvptx-gen.opt | 42 | ||||
-rw-r--r-- | gcc/config/nvptx/nvptx.h | 6 | ||||
-rw-r--r-- | gcc/config/nvptx/nvptx.opt | 22 | ||||
-rw-r--r-- | gcc/config/nvptx/t-nvptx | 17 |
8 files changed, 281 insertions, 27 deletions
diff --git a/gcc/config/nvptx/gen-copyright.sh b/gcc/config/nvptx/gen-copyright.sh new file mode 100644 index 0000000..79f4899 --- /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 +# <http://www.gnu.org/licenses/>. + +style="$1" +case $style in + opt) + ;; + c) + first=true + ;; + *) + echo "Unknown style: \"$style\"" + exit 1 + ;; +esac + +( cat <<EOF +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 +<http://www.gnu.org/licenses/>. +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 0000000..605f874 --- /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 +# <http://www.gnu.org/licenses/>. + +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 <<EOF +/* -*- buffer-read-only: t -*- + Generated automatically by gen-h.sh from nvptx-sm.def. +*/ +EOF + +# Separator. +echo + +. $gen_copyright_sh c + +# Separator. +echo + +for sm in $sms; do + cat <<EOF +#define TARGET_SM$sm (ptx_isa_option >= 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 0000000..5248ed2 --- /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 +# <http://www.gnu.org/licenses/>. + +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 <<EOF +; -*- buffer-read-only: t -*- +; Generated automatically by gen-opt.sh from nvptx-sm.def. +EOF + +# Separator. +echo + +. $gen_copyright_sh opt + +# Separator. +echo + +cat <<EOF +Enum +Name(ptx_isa) Type(int) +Known PTX ISA versions (for use with the -misa= option): +EOF + +# Separator. +echo + +for sm in $sms; do + cat <<EOF +EnumValue +Enum(ptx_isa) String(sm_$sm) Value(PTX_ISA_SM$sm) +EOF + + if [ "$sm" == "$last" ]; then + # Don't end with trailing empty line. + continue + fi + + # Separator. + echo +done diff --git a/gcc/config/nvptx/nvptx-gen.h b/gcc/config/nvptx/nvptx-gen.h new file mode 100644 index 0000000..1d6f0db --- /dev/null +++ b/gcc/config/nvptx/nvptx-gen.h @@ -0,0 +1,29 @@ +/* -*- buffer-read-only: t -*- + Generated automatically by gen-h.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 + <http://www.gnu.org/licenses/>. +*/ + +#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 0000000..b6d433e --- /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 +; <http://www.gnu.org/licenses/>. + +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 edffd08..4ab412b 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 f555ad1..c83ceb3 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 b170766..f17fc9c 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 |