@@ -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);
}
@@ -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
new file mode 100644
@@ -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
@@ -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 ();