diff mbox series

[PUSHED] nvptx: Support '-march=sm_89'

Message ID 20241206113149.3765096-1-tschwinge@baylibre.com
State New
Headers show
Series [PUSHED] nvptx: Support '-march=sm_89' | expand

Commit Message

Thomas Schwinge Dec. 6, 2024, 11:31 a.m. UTC
gcc/
	* config/nvptx/nvptx-sm.def: Add '89'.
	* config/nvptx/nvptx-gen.h: Regenerate.
	* config/nvptx/nvptx-gen.opt: Likewise.
	* config/nvptx/nvptx.cc (first_ptx_version_supporting_sm): Adjust.
	* config/nvptx/nvptx.opt (-march-map=sm_89, -march-map=sm_90)
	(march-map=sm_90a): Likewise.
	* config.gcc: Likewise.
	* doc/invoke.texi (Nvidia PTX Options): Document '-march=sm_89'.
	* config/nvptx/gen-multilib-matches-tests: Extend.
	gcc/testsuite/
	* gcc.target/nvptx/march-map=sm_89.c: Adjust.
	* gcc.target/nvptx/march-map=sm_90.c: Likewise.
	* gcc.target/nvptx/march-map=sm_90a.c: Likewise.
	* gcc.target/nvptx/march=sm_89.c: New.
	libgomp/
	* testsuite/libgomp.c/declare-variant-3-sm89.c: New.
	* testsuite/libgomp.c/declare-variant-3.h: Adjust.
---
 gcc/config.gcc                                |  2 +-
 gcc/config/nvptx/gen-multilib-matches-tests   | 65 ++++++++++++++++---
 gcc/config/nvptx/nvptx-gen.h                  |  1 +
 gcc/config/nvptx/nvptx-gen.opt                |  3 +
 gcc/config/nvptx/nvptx-sm.def                 |  3 +-
 gcc/config/nvptx/nvptx.cc                     |  2 +
 gcc/config/nvptx/nvptx.opt                    |  6 +-
 gcc/doc/invoke.texi                           |  2 +-
 .../gcc.target/nvptx/march-map=sm_89.c        |  8 +--
 .../gcc.target/nvptx/march-map=sm_90.c        |  8 +--
 .../gcc.target/nvptx/march-map=sm_90a.c       |  8 +--
 gcc/testsuite/gcc.target/nvptx/march=sm_89.c  | 19 ++++++
 .../libgomp.c/declare-variant-3-sm89.c        |  8 +++
 .../testsuite/libgomp.c/declare-variant-3.h   |  8 +++
 14 files changed, 116 insertions(+), 27 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/nvptx/march=sm_89.c
 create mode 100644 libgomp/testsuite/libgomp.c/declare-variant-3-sm89.c
diff mbox series

Patch

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 21f3dcd9d009..a2d21b5f3436 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -5645,7 +5645,7 @@  case "${target}" in
 			sm_30 | sm_35 | sm_37 \
 			| sm_52 | sm_53 \
 			| sm_70 | sm_75 \
-			| sm_80 )
+			| sm_80 | sm_89 )
 				TM_MULTILIB_CONFIG="$TM_MULTILIB_CONFIG $nvptx_multilib"
 				;;
 			$with_arch )
diff --git a/gcc/config/nvptx/gen-multilib-matches-tests b/gcc/config/nvptx/gen-multilib-matches-tests
index 13b1c5b9d018..a07f19adbdb1 100644
--- a/gcc/config/nvptx/gen-multilib-matches-tests
+++ b/gcc/config/nvptx/gen-multilib-matches-tests
@@ -21,11 +21,12 @@  AEMM .=misa?sm_53
 AEMM .=misa?sm_70
 AEMM .=misa?sm_75
 AEMM .=misa?sm_80
+AEMM .=misa?sm_89
 CMMC
 
-BEGIN '--with-arch=sm_30', '--with-multilib-list=sm_30,sm_80'
+BEGIN '--with-arch=sm_30', '--with-multilib-list=sm_30,sm_89'
 SMOID sm_30
-SMOIL sm_30 sm_80
+SMOIL sm_30 sm_89
 AEMM .=misa?sm_30
 AEMM .=misa?sm_35
 AEMM .=misa?sm_37
@@ -33,11 +34,12 @@  AEMM .=misa?sm_52
 AEMM .=misa?sm_53
 AEMM .=misa?sm_70
 AEMM .=misa?sm_75
+AEMM .=misa?sm_80
 CMMC
 
-BEGIN '--with-arch=sm_30', '--with-multilib-list=sm_30,sm_35,sm_37,sm_52,sm_53,sm_70,sm_75,sm_80'
+BEGIN '--with-arch=sm_30', '--with-multilib-list=sm_30,sm_35,sm_37,sm_52,sm_53,sm_70,sm_75,sm_80,sm_89'
 SMOID sm_30
-SMOIL sm_30 sm_35 sm_37 sm_52 sm_53 sm_70 sm_75 sm_80
+SMOIL sm_30 sm_35 sm_37 sm_52 sm_53 sm_70 sm_75 sm_80 sm_89
 AEMM .=misa?sm_30
 CMMC
 
@@ -53,6 +55,7 @@  AEMM .=misa?sm_53
 AEMM .=misa?sm_70
 AEMM .=misa?sm_75
 AEMM .=misa?sm_80
+AEMM .=misa?sm_89
 CMMC
 
 BEGIN '--with-arch=sm_35', '--with-multilib-list=sm_35,sm_30'
@@ -65,6 +68,7 @@  AEMM .=misa?sm_53
 AEMM .=misa?sm_70
 AEMM .=misa?sm_75
 AEMM .=misa?sm_80
+AEMM .=misa?sm_89
 CMMC
 
 
@@ -78,6 +82,7 @@  AEMM .=misa?sm_53
 AEMM .=misa?sm_70
 AEMM .=misa?sm_75
 AEMM .=misa?sm_80
+AEMM .=misa?sm_89
 CMMC
 
 
@@ -90,6 +95,7 @@  AEMM .=misa?sm_52
 AEMM .=misa?sm_53
 AEMM .=misa?sm_70
 AEMM misa?sm_75=misa?sm_80
+AEMM misa?sm_75=misa?sm_89
 CMMC
 
 
@@ -103,6 +109,7 @@  AEMM .=misa?sm_53
 AEMM .=misa?sm_70
 AEMM .=misa?sm_75
 AEMM .=misa?sm_80
+AEMM .=misa?sm_89
 CMMC
 
 BEGIN '--with-arch=sm_53', '--with-multilib-list=sm_53,sm_37'
@@ -115,11 +122,12 @@  AEMM .=misa?sm_53
 AEMM .=misa?sm_70
 AEMM .=misa?sm_75
 AEMM .=misa?sm_80
+AEMM .=misa?sm_89
 CMMC
 
-BEGIN '--with-arch=sm_53', '--with-multilib-list=sm_53=sm_30,sm_35,sm_37,sm_52,sm_70,sm_75,sm_80'
+BEGIN '--with-arch=sm_53', '--with-multilib-list=sm_53=sm_30,sm_35,sm_37,sm_52,sm_70,sm_75,sm_80,sm_89'
 SMOID sm_53
-SMOIL sm_53 sm_30 sm_35 sm_37 sm_52 sm_70 sm_75 sm_80
+SMOIL sm_53 sm_30 sm_35 sm_37 sm_52 sm_70 sm_75 sm_80 sm_89
 AEMM .=misa?sm_53
 CMMC
 
@@ -135,6 +143,7 @@  AEMM .=misa?sm_53
 AEMM .=misa?sm_70
 AEMM .=misa?sm_75
 AEMM .=misa?sm_80
+AEMM .=misa?sm_89
 CMMC
 
 BEGIN '--with-arch=sm_70', '--with-multilib-list=sm_70,sm_30'
@@ -147,6 +156,7 @@  AEMM misa?sm_30=misa?sm_53
 AEMM .=misa?sm_70
 AEMM .=misa?sm_75
 AEMM .=misa?sm_80
+AEMM .=misa?sm_89
 CMMC
 
 BEGIN '--with-arch=sm_70', '--with-multilib-list=sm_70,sm_53'
@@ -159,6 +169,7 @@  AEMM misa?sm_53=misa?sm_52
 AEMM .=misa?sm_70
 AEMM .=misa?sm_75
 AEMM .=misa?sm_80
+AEMM .=misa?sm_89
 CMMC
 
 BEGIN '--with-arch=sm_70', '--with-multilib-list=sm_70,sm_53,sm_30'
@@ -170,6 +181,7 @@  AEMM misa?sm_30=misa?sm_52
 AEMM .=misa?sm_70
 AEMM .=misa?sm_75
 AEMM .=misa?sm_80
+AEMM .=misa?sm_89
 CMMC
 
 
@@ -183,6 +195,7 @@  AEMM misa?sm_30=misa?sm_53
 AEMM misa?sm_30=misa?sm_70
 AEMM .=misa?sm_75
 AEMM .=misa?sm_80
+AEMM .=misa?sm_89
 CMMC
 
 BEGIN '--with-arch=sm_75', '--with-multilib-list=sm_75,sm_53'
@@ -195,6 +208,7 @@  AEMM misa?sm_53=misa?sm_52
 AEMM misa?sm_53=misa?sm_70
 AEMM .=misa?sm_75
 AEMM .=misa?sm_80
+AEMM .=misa?sm_89
 CMMC
 
 BEGIN '--with-arch=sm_75', '--with-multilib-list=sm_75,sm_30,sm_53'
@@ -206,6 +220,7 @@  AEMM misa?sm_30=misa?sm_52
 AEMM misa?sm_53=misa?sm_70
 AEMM .=misa?sm_75
 AEMM .=misa?sm_80
+AEMM .=misa?sm_89
 CMMC
 
 
@@ -220,6 +235,7 @@  AEMM .=misa?sm_53
 AEMM .=misa?sm_70
 AEMM .=misa?sm_75
 AEMM .=misa?sm_80
+AEMM .=misa?sm_89
 CMMC
 
 BEGIN '--with-arch=sm_80', '--with-multilib-list=sm_80,sm_30'
@@ -232,6 +248,7 @@  AEMM misa?sm_30=misa?sm_53
 AEMM misa?sm_30=misa?sm_70
 AEMM misa?sm_30=misa?sm_75
 AEMM .=misa?sm_80
+AEMM .=misa?sm_89
 CMMC
 
 BEGIN '--with-arch=sm_80', '--with-multilib-list=sm_80,sm_75'
@@ -244,10 +261,40 @@  AEMM misa?sm_75=misa?sm_52
 AEMM misa?sm_75=misa?sm_53
 AEMM misa?sm_75=misa?sm_70
 AEMM .=misa?sm_80
+AEMM .=misa?sm_89
 CMMC
 
-BEGIN '--with-arch=sm_80', '--with-multilib-list=sm_80,sm_30,sm_35,sm_37,sm_52,sm_53,sm_70,sm_75'
-SMOID sm_80
-SMOIL sm_80 sm_30 sm_35 sm_37 sm_52 sm_53 sm_70 sm_75
+
+BEGIN '--with-arch=sm_89', '--with-multilib-list=sm_89'
+SMOID sm_89
+SMOIL sm_89
+AEMM .=misa?sm_30
+AEMM .=misa?sm_35
+AEMM .=misa?sm_37
+AEMM .=misa?sm_52
+AEMM .=misa?sm_53
+AEMM .=misa?sm_70
+AEMM .=misa?sm_75
 AEMM .=misa?sm_80
+AEMM .=misa?sm_89
+CMMC
+
+BEGIN '--with-arch=sm_89', '--with-multilib-list=sm_89,sm_52'
+SMOID sm_89
+SMOIL sm_89 sm_52
+AEMM misa?sm_52=misa?sm_30
+AEMM misa?sm_52=misa?sm_35
+AEMM misa?sm_52=misa?sm_37
+AEMM misa?sm_52=misa?sm_53
+AEMM misa?sm_52=misa?sm_70
+AEMM misa?sm_52=misa?sm_75
+AEMM misa?sm_52=misa?sm_80
+AEMM .=misa?sm_89
+CMMC
+
+
+BEGIN '--with-arch=sm_89', '--with-multilib-list=sm_89,sm_30,sm_35,sm_37,sm_52,sm_53,sm_70,sm_75,sm_80'
+SMOID sm_89
+SMOIL sm_89 sm_30 sm_35 sm_37 sm_52 sm_53 sm_70 sm_75 sm_80
+AEMM .=misa?sm_89
 CMMC
diff --git a/gcc/config/nvptx/nvptx-gen.h b/gcc/config/nvptx/nvptx-gen.h
index 5f271a33c357..416ee8a26290 100644
--- a/gcc/config/nvptx/nvptx-gen.h
+++ b/gcc/config/nvptx/nvptx-gen.h
@@ -29,3 +29,4 @@ 
 #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)
+#define TARGET_SM89 (ptx_isa_option >= PTX_ISA_SM89)
diff --git a/gcc/config/nvptx/nvptx-gen.opt b/gcc/config/nvptx/nvptx-gen.opt
index 0d76885c475e..cc8492e086bc 100644
--- a/gcc/config/nvptx/nvptx-gen.opt
+++ b/gcc/config/nvptx/nvptx-gen.opt
@@ -46,3 +46,6 @@  Enum(ptx_isa) String(sm_75) Value(PTX_ISA_SM75)
 
 EnumValue
 Enum(ptx_isa) String(sm_80) Value(PTX_ISA_SM80)
+
+EnumValue
+Enum(ptx_isa) String(sm_89) Value(PTX_ISA_SM89)
diff --git a/gcc/config/nvptx/nvptx-sm.def b/gcc/config/nvptx/nvptx-sm.def
index 0fafc8aeddfa..5656ac73cf73 100644
--- a/gcc/config/nvptx/nvptx-sm.def
+++ b/gcc/config/nvptx/nvptx-sm.def
@@ -27,6 +27,7 @@  NVPTX_SM (52, NVPTX_SM_SEP)
 NVPTX_SM (53, NVPTX_SM_SEP)
 NVPTX_SM (70, NVPTX_SM_SEP)
 NVPTX_SM (75, NVPTX_SM_SEP)
-NVPTX_SM (80,)
+NVPTX_SM (80, NVPTX_SM_SEP)
+NVPTX_SM (89,)
 
 #undef NVPTX_SM_SEP
diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc
index 65d339b36ede..96536a0e3d13 100644
--- a/gcc/config/nvptx/nvptx.cc
+++ b/gcc/config/nvptx/nvptx.cc
@@ -226,6 +226,8 @@  first_ptx_version_supporting_sm (enum ptx_isa sm)
       return PTX_VERSION_6_3;
     case PTX_ISA_SM80:
       return PTX_VERSION_7_0;
+    case PTX_ISA_SM89:
+      return PTX_VERSION_7_8;
     default:
       gcc_unreachable ();
     }
diff --git a/gcc/config/nvptx/nvptx.opt b/gcc/config/nvptx/nvptx.opt
index 842cbbbedeee..f2077f4c750a 100644
--- a/gcc/config/nvptx/nvptx.opt
+++ b/gcc/config/nvptx/nvptx.opt
@@ -112,13 +112,13 @@  march-map=sm_87
 Target RejectNegative Alias(misa=,sm_80)
 
 march-map=sm_89
-Target RejectNegative Alias(misa=,sm_80)
+Target RejectNegative Alias(misa=,sm_89)
 
 march-map=sm_90
-Target RejectNegative Alias(misa=,sm_80)
+Target RejectNegative Alias(misa=,sm_89)
 
 march-map=sm_90a
-Target RejectNegative Alias(misa=,sm_80)
+Target RejectNegative Alias(misa=,sm_89)
 
 Enum
 Name(ptx_version) Type(enum ptx_version)
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 8271e6474817..57b6ca126400 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -30049,7 +30049,7 @@  Valid architecture strings are
 @samp{sm_30}, @samp{sm_35}, @samp{sm_37},
 @samp{sm_52}, @samp{sm_53},
 @samp{sm_70}, @samp{sm_75},
-and @samp{sm_80}.
+@samp{sm_80}, and @samp{sm_89}.
 The default depends on how the compiler has been configured, see
 @option{--with-arch}.
 
diff --git a/gcc/testsuite/gcc.target/nvptx/march-map=sm_89.c b/gcc/testsuite/gcc.target/nvptx/march-map=sm_89.c
index 24aabf6710fa..996af781f5bd 100644
--- a/gcc/testsuite/gcc.target/nvptx/march-map=sm_89.c
+++ b/gcc/testsuite/gcc.target/nvptx/march-map=sm_89.c
@@ -1,18 +1,18 @@ 
 /* { dg-do assemble } */
 /* { dg-options {-march-map=sm_89 -mptx=_} } */
 /* { dg-additional-options -save-temps } */
-/* { dg-final { scan-assembler-times {(?n)^	\.version	7\.0$} 1 } } */
-/* { dg-final { scan-assembler-times {(?n)^	\.target	sm_80$} 1 } } */
+/* { dg-final { scan-assembler-times {(?n)^	\.version	7\.8$} 1 } } */
+/* { dg-final { scan-assembler-times {(?n)^	\.target	sm_89$} 1 } } */
 
 #if __PTX_ISA_VERSION_MAJOR__ != 7
 #error wrong value for __PTX_ISA_VERSION_MAJOR__
 #endif
 
-#if __PTX_ISA_VERSION_MINOR__ != 0
+#if __PTX_ISA_VERSION_MINOR__ != 8
 #error wrong value for __PTX_ISA_VERSION_MINOR__
 #endif
 
-#if __PTX_SM__ != 800
+#if __PTX_SM__ != 890
 #error wrong value for __PTX_SM__
 #endif
 
diff --git a/gcc/testsuite/gcc.target/nvptx/march-map=sm_90.c b/gcc/testsuite/gcc.target/nvptx/march-map=sm_90.c
index 77aea4e6c992..0915df7a150f 100644
--- a/gcc/testsuite/gcc.target/nvptx/march-map=sm_90.c
+++ b/gcc/testsuite/gcc.target/nvptx/march-map=sm_90.c
@@ -1,18 +1,18 @@ 
 /* { dg-do assemble } */
 /* { dg-options {-march-map=sm_90 -mptx=_} } */
 /* { dg-additional-options -save-temps } */
-/* { dg-final { scan-assembler-times {(?n)^	\.version	7\.0$} 1 } } */
-/* { dg-final { scan-assembler-times {(?n)^	\.target	sm_80$} 1 } } */
+/* { dg-final { scan-assembler-times {(?n)^	\.version	7\.8$} 1 } } */
+/* { dg-final { scan-assembler-times {(?n)^	\.target	sm_89$} 1 } } */
 
 #if __PTX_ISA_VERSION_MAJOR__ != 7
 #error wrong value for __PTX_ISA_VERSION_MAJOR__
 #endif
 
-#if __PTX_ISA_VERSION_MINOR__ != 0
+#if __PTX_ISA_VERSION_MINOR__ != 8
 #error wrong value for __PTX_ISA_VERSION_MINOR__
 #endif
 
-#if __PTX_SM__ != 800
+#if __PTX_SM__ != 890
 #error wrong value for __PTX_SM__
 #endif
 
diff --git a/gcc/testsuite/gcc.target/nvptx/march-map=sm_90a.c b/gcc/testsuite/gcc.target/nvptx/march-map=sm_90a.c
index b83fe654cf66..08a701502572 100644
--- a/gcc/testsuite/gcc.target/nvptx/march-map=sm_90a.c
+++ b/gcc/testsuite/gcc.target/nvptx/march-map=sm_90a.c
@@ -1,18 +1,18 @@ 
 /* { dg-do assemble } */
 /* { dg-options {-march-map=sm_90a -mptx=_} } */
 /* { dg-additional-options -save-temps } */
-/* { dg-final { scan-assembler-times {(?n)^	\.version	7\.0$} 1 } } */
-/* { dg-final { scan-assembler-times {(?n)^	\.target	sm_80$} 1 } } */
+/* { dg-final { scan-assembler-times {(?n)^	\.version	7\.8$} 1 } } */
+/* { dg-final { scan-assembler-times {(?n)^	\.target	sm_89$} 1 } } */
 
 #if __PTX_ISA_VERSION_MAJOR__ != 7
 #error wrong value for __PTX_ISA_VERSION_MAJOR__
 #endif
 
-#if __PTX_ISA_VERSION_MINOR__ != 0
+#if __PTX_ISA_VERSION_MINOR__ != 8
 #error wrong value for __PTX_ISA_VERSION_MINOR__
 #endif
 
-#if __PTX_SM__ != 800
+#if __PTX_SM__ != 890
 #error wrong value for __PTX_SM__
 #endif
 
diff --git a/gcc/testsuite/gcc.target/nvptx/march=sm_89.c b/gcc/testsuite/gcc.target/nvptx/march=sm_89.c
new file mode 100644
index 000000000000..bd57061759dc
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nvptx/march=sm_89.c
@@ -0,0 +1,19 @@ 
+/* { dg-do assemble } */
+/* { dg-options {-march=sm_89 -mptx=_} } */
+/* { dg-additional-options -save-temps } */
+/* { dg-final { scan-assembler-times {(?n)^	\.version	7\.8$} 1 } } */
+/* { dg-final { scan-assembler-times {(?n)^	\.target	sm_89$} 1 } } */
+
+#if __PTX_ISA_VERSION_MAJOR__ != 7
+#error wrong value for __PTX_ISA_VERSION_MAJOR__
+#endif
+
+#if __PTX_ISA_VERSION_MINOR__ != 8
+#error wrong value for __PTX_ISA_VERSION_MINOR__
+#endif
+
+#if __PTX_SM__ != 890
+#error wrong value for __PTX_SM__
+#endif
+
+int dummy;
diff --git a/libgomp/testsuite/libgomp.c/declare-variant-3-sm89.c b/libgomp/testsuite/libgomp.c/declare-variant-3-sm89.c
new file mode 100644
index 000000000000..cd2e472a1040
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/declare-variant-3-sm89.c
@@ -0,0 +1,8 @@ 
+/* { dg-do link { target { offload_target_nvptx } } } */
+/* { dg-additional-options -foffload=nvptx-none } */
+/* { dg-additional-options "-foffload=-misa=sm_89 -foffload=-mptx=_" } */
+/* { dg-additional-options "-foffload=-fdump-tree-optimized" } */
+
+#include "declare-variant-3.h"
+
+/* { dg-final { only_for_offload_target nvptx-none scan-offload-tree-dump "= f89 \\(\\);" "optimized" } } */
diff --git a/libgomp/testsuite/libgomp.c/declare-variant-3.h b/libgomp/testsuite/libgomp.c/declare-variant-3.h
index 8db0fc536adb..c9c8f4a385fb 100644
--- a/libgomp/testsuite/libgomp.c/declare-variant-3.h
+++ b/libgomp/testsuite/libgomp.c/declare-variant-3.h
@@ -56,6 +56,13 @@  f80 (void)
   return 80;
 }
 
+__attribute__ ((noipa))
+int
+f89 (void)
+{
+  return 89;
+}
+
 #pragma omp declare variant (f30) match (device={isa("sm_30")})
 #pragma omp declare variant (f35) match (device={isa("sm_35")})
 #pragma omp declare variant (f37) match (device={isa("sm_37")})
@@ -64,6 +71,7 @@  f80 (void)
 #pragma omp declare variant (f70) match (device={isa("sm_70")})
 #pragma omp declare variant (f75) match (device={isa("sm_75")})
 #pragma omp declare variant (f80) match (device={isa("sm_80")})
+#pragma omp declare variant (f89) match (device={isa("sm_89")})
 __attribute__ ((noipa))
 int
 f (void)