https://gcc.gnu.org/g:1af83aa09979e5f2ca36f844d56ccd629268057d

commit r15-5977-g1af83aa09979e5f2ca36f844d56ccd629268057d
Author: Thomas Schwinge <tschwi...@baylibre.com>
Date:   Sun Nov 10 17:35:07 2024 +0100

    nvptx: Expose '-mptx=4.2'
    
    'PTX_VERSION_4_2' was added in commit 
decde11183bdccc46587d6614b75f3d56a2f2e4a
    "[nvptx] Choose -mptx default based on -misa" for use for '-march=sm_52'
    ('first_ptx_version_supporting_sm', 'PTX_ISA_SM53'), as documented by 
Nvidia.
    However, '-mptx=4.2' wasn't exposed to the user, but there's no reason not 
to.
    
            gcc/
            * config/nvptx/nvptx.h (TARGET_PTX_4_2): New.
            * config/nvptx/nvptx.opt (Enum(ptx_version)): Add 'EnumValue'
            '4.2' for 'PTX_VERSION_4_2'.
            * doc/invoke.texi (Nvidia PTX Options): Document '-mptx=4.2'.
            gcc/testsuite/
            * gcc.target/nvptx/mptx=4.2.c: New.

Diff:
---
 gcc/config/nvptx/nvptx.h                  |  1 +
 gcc/config/nvptx/nvptx.opt                |  3 +++
 gcc/doc/invoke.texi                       | 10 +++++++---
 gcc/testsuite/gcc.target/nvptx/mptx=4.2.c | 19 +++++++++++++++++++
 4 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/gcc/config/nvptx/nvptx.h b/gcc/config/nvptx/nvptx.h
index 792da4901d22..d9a5e541257d 100644
--- a/gcc/config/nvptx/nvptx.h
+++ b/gcc/config/nvptx/nvptx.h
@@ -90,6 +90,7 @@
 
 /* There are no 'TARGET_PTX_3_1' and smaller conditionals: our baseline is
    PTX ISA Version 3.1.  */
+#define TARGET_PTX_4_2 (ptx_version_option >= PTX_VERSION_4_2)
 #define TARGET_PTX_6_0 (ptx_version_option >= PTX_VERSION_6_0)
 #define TARGET_PTX_6_3 (ptx_version_option >= PTX_VERSION_6_3)
 #define TARGET_PTX_7_0 (ptx_version_option >= PTX_VERSION_7_0)
diff --git a/gcc/config/nvptx/nvptx.opt b/gcc/config/nvptx/nvptx.opt
index 53ddf451836e..408c88354446 100644
--- a/gcc/config/nvptx/nvptx.opt
+++ b/gcc/config/nvptx/nvptx.opt
@@ -127,6 +127,9 @@ Known PTX ISA versions (for use with the -mptx= option):
 EnumValue
 Enum(ptx_version) String(3.1) Value(PTX_VERSION_3_1)
 
+EnumValue
+Enum(ptx_version) String(4.2) Value(PTX_VERSION_4_2)
+
 EnumValue
 Enum(ptx_version) String(6.0) Value(PTX_VERSION_6_0)
 
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 33a1b6b7983a..a2234725e671 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -30070,9 +30070,13 @@ capable.  For instance, for @option{-march-map=sm_50} 
select
 
 @opindex mptx
 @item -mptx=@var{version-string}
-Generate code for the specified PTX ISA version (e.g.@: @samp{7.0}).
-Valid version strings include @samp{3.1}, @samp{6.0}, @samp{6.3}, and
-@samp{7.0}.  The default PTX ISA version is 6.0, unless a higher
+Generate code for the specified PTX ISA version.
+Valid version strings are
+@samp{3.1},
+@samp{4.2},
+@samp{6.0}, @samp{6.3},
+and @samp{7.0}.
+The default PTX ISA version is 6.0, unless a higher
 version is required for specified PTX ISA target architecture via
 option @option{-march=}.
 
diff --git a/gcc/testsuite/gcc.target/nvptx/mptx=4.2.c 
b/gcc/testsuite/gcc.target/nvptx/mptx=4.2.c
new file mode 100644
index 000000000000..e17ee1babf96
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nvptx/mptx=4.2.c
@@ -0,0 +1,19 @@
+/* { dg-do assemble } */
+/* { dg-options {-march=sm_30 -mptx=4.2} } */
+/* { dg-additional-options -save-temps } */
+/* { dg-final { scan-assembler-times {(?n)^    \.version       4\.2$} 1 } } */
+/* { dg-final { scan-assembler-times {(?n)^    \.target        sm_30$} 1 } } */
+
+#if __PTX_ISA_VERSION_MAJOR__ != 4
+#error wrong value for __PTX_ISA_VERSION_MAJOR__
+#endif
+
+#if __PTX_ISA_VERSION_MINOR__ != 2
+#error wrong value for __PTX_ISA_VERSION_MINOR__
+#endif
+
+#if __PTX_SM__ != 300
+#error wrong value for __PTX_SM__
+#endif
+
+int dummy;

Reply via email to