aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/nvptx
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2022-02-25 11:47:12 +0100
committerTom de Vries <tdevries@suse.de>2022-03-01 08:58:35 +0100
commit7efe46935c5fce8db13e00aa6f4b0f1599b330e4 (patch)
tree997568c00309dd608f3437d66a4effd30f4ba5f5 /gcc/config/nvptx
parent4706670cd3b06bb024da0683776bf86c79d55940 (diff)
downloadgcc-7efe46935c5fce8db13e00aa6f4b0f1599b330e4.zip
gcc-7efe46935c5fce8db13e00aa6f4b0f1599b330e4.tar.gz
gcc-7efe46935c5fce8db13e00aa6f4b0f1599b330e4.tar.bz2
[nvptx] Add nvptx-sm.def
Add a file gcc/config/nvptx/nvptx-sm.def that lists all sm_xx versions used in the port, like so: ... NVPTX_SM(30, NVPTX_SM_SEP) NVPTX_SM(35, NVPTX_SM_SEP) NVPTX_SM(53, NVPTX_SM_SEP) NVPTX_SM(70, NVPTX_SM_SEP) NVPTX_SM(75, NVPTX_SM_SEP) NVPTX_SM(80,) ... and use it in various places using a pattern: ... #define NVPTX_SM(XX, SEP) { ... } #include "nvptx-sm.def" #undef NVPTX_SM ... Tested on nvptx. gcc/ChangeLog: 2022-02-25 Tom de Vries <tdevries@suse.de> * config/nvptx/nvptx-sm.def: New file. * config/nvptx/nvptx-c.cc (nvptx_cpu_cpp_builtins): Use nvptx-sm.def. * config/nvptx/nvptx-opts.h (enum ptx_isa): Same. * config/nvptx/nvptx.cc (sm_version_to_string) (nvptx_omp_device_kind_arch_isa): Same.
Diffstat (limited to 'gcc/config/nvptx')
-rw-r--r--gcc/config/nvptx/nvptx-c.cc22
-rw-r--r--gcc/config/nvptx/nvptx-opts.h11
-rw-r--r--gcc/config/nvptx/nvptx-sm.def30
-rw-r--r--gcc/config/nvptx/nvptx.cc36
4 files changed, 57 insertions, 42 deletions
diff --git a/gcc/config/nvptx/nvptx-c.cc b/gcc/config/nvptx/nvptx-c.cc
index b2375fb..02f7562 100644
--- a/gcc/config/nvptx/nvptx-c.cc
+++ b/gcc/config/nvptx/nvptx-c.cc
@@ -39,17 +39,15 @@ nvptx_cpu_cpp_builtins (void)
cpp_define (parse_in, "__nvptx_softstack__");
if (TARGET_UNIFORM_SIMT)
cpp_define (parse_in,"__nvptx_unisimt__");
- if (TARGET_SM80)
- cpp_define (parse_in, "__PTX_SM__=800");
- else if (TARGET_SM75)
- cpp_define (parse_in, "__PTX_SM__=750");
- else if (TARGET_SM70)
- cpp_define (parse_in, "__PTX_SM__=700");
- else if (TARGET_SM53)
- cpp_define (parse_in, "__PTX_SM__=530");
- else if (TARGET_SM35)
- cpp_define (parse_in, "__PTX_SM__=350");
- else
- cpp_define (parse_in,"__PTX_SM__=300");
+
+ const char *ptx_sm = NULL;
+#define NVPTX_SM(XX, SEP) \
+ { \
+ if (TARGET_SM ## XX) \
+ ptx_sm = "__PTX_SM__=" #XX "0"; \
+ }
+#include "nvptx-sm.def"
+#undef NVPTX_SM
+ cpp_define (parse_in, ptx_sm);
}
diff --git a/gcc/config/nvptx/nvptx-opts.h b/gcc/config/nvptx/nvptx-opts.h
index 30852b6..86b433c 100644
--- a/gcc/config/nvptx/nvptx-opts.h
+++ b/gcc/config/nvptx/nvptx-opts.h
@@ -22,12 +22,11 @@
enum ptx_isa
{
- PTX_ISA_SM30,
- PTX_ISA_SM35,
- PTX_ISA_SM53,
- PTX_ISA_SM70,
- PTX_ISA_SM75,
- PTX_ISA_SM80
+#define NVPTX_SM(XX, SEP) PTX_ISA_SM ## XX SEP
+#define NVPTX_SM_SEP ,
+#include "nvptx-sm.def"
+#undef NVPTX_SM_SEP
+#undef NVPTX_SM
};
enum ptx_version
diff --git a/gcc/config/nvptx/nvptx-sm.def b/gcc/config/nvptx/nvptx-sm.def
new file mode 100644
index 0000000..c552eb0
--- /dev/null
+++ b/gcc/config/nvptx/nvptx-sm.def
@@ -0,0 +1,30 @@
+/* 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/>. */
+
+#ifndef NVPTX_SM_SEP
+#define NVPTX_SM_SEP
+#endif
+
+NVPTX_SM (30, NVPTX_SM_SEP)
+NVPTX_SM (35, NVPTX_SM_SEP)
+NVPTX_SM (53, NVPTX_SM_SEP)
+NVPTX_SM (70, NVPTX_SM_SEP)
+NVPTX_SM (75, NVPTX_SM_SEP)
+NVPTX_SM (80,)
+
+#undef NVPTX_SM_SEP
diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc
index 7862a90..f3179ef 100644
--- a/gcc/config/nvptx/nvptx.cc
+++ b/gcc/config/nvptx/nvptx.cc
@@ -276,18 +276,11 @@ sm_version_to_string (enum ptx_isa sm)
{
switch (sm)
{
- case PTX_ISA_SM30:
- return "30";
- case PTX_ISA_SM35:
- return "35";
- case PTX_ISA_SM53:
- return "53";
- case PTX_ISA_SM70:
- return "70";
- case PTX_ISA_SM75:
- return "75";
- case PTX_ISA_SM80:
- return "80";
+#define NVPTX_SM(XX, SEP) \
+ case PTX_ISA_SM ## XX: \
+ return #XX;
+#include "nvptx-sm.def"
+#undef NVPTX_SM
default:
gcc_unreachable ();
}
@@ -6177,18 +6170,13 @@ nvptx_omp_device_kind_arch_isa (enum omp_device_kind_arch_isa trait,
case omp_device_arch:
return strcmp (name, "nvptx") == 0;
case omp_device_isa:
- if (strcmp (name, "sm_30") == 0)
- return !TARGET_SM35;
- if (strcmp (name, "sm_35") == 0)
- return TARGET_SM35 && !TARGET_SM53;
- if (strcmp (name, "sm_53") == 0)
- return TARGET_SM53 && !TARGET_SM70;
- if (strcmp (name, "sm_70") == 0)
- return TARGET_SM70 && !TARGET_SM75;
- if (strcmp (name, "sm_75") == 0)
- return TARGET_SM75 && !TARGET_SM80;
- if (strcmp (name, "sm_80") == 0)
- return TARGET_SM80;
+#define NVPTX_SM(XX, SEP) \
+ { \
+ if (strcmp (name, "sm_" #XX) == 0) \
+ return ptx_isa_option == PTX_ISA_SM ## XX; \
+ }
+#include "nvptx-sm.def"
+#undef NVPTX_SM
return 0;
default:
gcc_unreachable ();