https://gcc.gnu.org/g:0d70ea000c69c56b47c44855d9ba43f5c8737728

commit 0d70ea000c69c56b47c44855d9ba43f5c8737728
Author: Thomas Schwinge <tschwi...@baylibre.com>
Date:   Sun Nov 10 17:34:08 2024 +0100

    nvptx: Support '-mptx=4.1'
    
            gcc/
            * config/nvptx/nvptx-opts.h (enum ptx_version): Add
            'PTX_VERSION_4_1'.
            * config/nvptx/nvptx.cc (ptx_version_to_string)
            (ptx_version_to_number): Adjust.
            * config/nvptx/nvptx.h (TARGET_PTX_4_1): New.
            * config/nvptx/nvptx.opt (Enum(ptx_version)): Add 'EnumValue'
            '4.1' for 'PTX_VERSION_4_1'.
            * doc/invoke.texi (Nvidia PTX Options): Document '-mptx=4.1'.
            gcc/testsuite/
            * gcc.target/nvptx/mptx=4.1.c: New.
    
    (cherry picked from commit 18d80e5ecfa610a8a8f4b8e6381b695595c78192)

Diff:
---
 gcc/ChangeLog.omp                         | 12 ++++++++++++
 gcc/config/nvptx/nvptx-opts.h             |  1 +
 gcc/config/nvptx/nvptx.cc                 |  4 ++++
 gcc/config/nvptx/nvptx.h                  |  1 +
 gcc/config/nvptx/nvptx.opt                |  3 +++
 gcc/doc/invoke.texi                       |  2 +-
 gcc/testsuite/ChangeLog.omp               |  5 +++++
 gcc/testsuite/gcc.target/nvptx/mptx=4.1.c | 19 +++++++++++++++++++
 8 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index ec728b7751a7..c85aa341f54f 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -3,6 +3,18 @@
        Backported from trunk:
        2024-12-06  Thomas Schwinge  <tschwi...@baylibre.com>
 
+       * config/nvptx/nvptx-opts.h (enum ptx_version): Add
+       'PTX_VERSION_4_1'.
+       * config/nvptx/nvptx.cc (ptx_version_to_string)
+       (ptx_version_to_number): Adjust.
+       * config/nvptx/nvptx.h (TARGET_PTX_4_1): New.
+       * config/nvptx/nvptx.opt (Enum(ptx_version)): Add 'EnumValue'
+       '4.1' for 'PTX_VERSION_4_1'.
+       * doc/invoke.texi (Nvidia PTX Options): Document '-mptx=4.1'.
+
+       Backported from trunk:
+       2024-12-06  Thomas Schwinge  <tschwi...@baylibre.com>
+
        * 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'.
diff --git a/gcc/config/nvptx/nvptx-opts.h b/gcc/config/nvptx/nvptx-opts.h
index d0b47f0aeeff..1277f2130896 100644
--- a/gcc/config/nvptx/nvptx-opts.h
+++ b/gcc/config/nvptx/nvptx-opts.h
@@ -38,6 +38,7 @@ enum ptx_version
   PTX_VERSION_unset,
   PTX_VERSION_default = PTX_VERSION_unset,
   PTX_VERSION_3_1,
+  PTX_VERSION_4_1,
   PTX_VERSION_4_2,
   PTX_VERSION_6_0,
   PTX_VERSION_6_3,
diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc
index 588bb87c5b39..81c959437cda 100644
--- a/gcc/config/nvptx/nvptx.cc
+++ b/gcc/config/nvptx/nvptx.cc
@@ -258,6 +258,8 @@ ptx_version_to_string (enum ptx_version v)
     {
     case PTX_VERSION_3_1:
       return "3.1";
+    case PTX_VERSION_4_1:
+      return "4.1";
     case PTX_VERSION_4_2:
       return "4.2";
     case PTX_VERSION_6_0:
@@ -278,6 +280,8 @@ ptx_version_to_number (enum ptx_version v, bool major_p)
     {
     case PTX_VERSION_3_1:
       return major_p ? 3 : 1;
+    case PTX_VERSION_4_1:
+      return major_p ? 4 : 1;
     case PTX_VERSION_4_2:
       return major_p ? 4 : 2;
     case PTX_VERSION_6_0:
diff --git a/gcc/config/nvptx/nvptx.h b/gcc/config/nvptx/nvptx.h
index f2b65435a528..d58c83ae8795 100644
--- a/gcc/config/nvptx/nvptx.h
+++ b/gcc/config/nvptx/nvptx.h
@@ -93,6 +93,7 @@
 
 /* There are no 'TARGET_PTX_3_1' and smaller conditionals: our baseline is
    PTX ISA Version 3.1.  */
+#define TARGET_PTX_4_1 (ptx_version_option >= PTX_VERSION_4_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)
diff --git a/gcc/config/nvptx/nvptx.opt b/gcc/config/nvptx/nvptx.opt
index 408c88354446..12f96d0885b6 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.1) Value(PTX_VERSION_4_1)
+
 EnumValue
 Enum(ptx_version) String(4.2) Value(PTX_VERSION_4_2)
 
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 85a8c89867e8..6ba199d23d7e 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -30053,7 +30053,7 @@ capable.  For instance, for @option{-march-map=sm_50} 
select
 Generate code for the specified PTX ISA version.
 Valid version strings are
 @samp{3.1},
-@samp{4.2},
+@samp{4.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
diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index 90f9364c7373..65257663146c 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -3,6 +3,11 @@
        Backported from trunk:
        2024-12-06  Thomas Schwinge  <tschwi...@baylibre.com>
 
+       * gcc.target/nvptx/mptx=4.1.c: New.
+
+       Backported from trunk:
+       2024-12-06  Thomas Schwinge  <tschwi...@baylibre.com>
+
        * gcc.target/nvptx/mptx=4.2.c: New.
 
        Backported from trunk:
diff --git a/gcc/testsuite/gcc.target/nvptx/mptx=4.1.c 
b/gcc/testsuite/gcc.target/nvptx/mptx=4.1.c
new file mode 100644
index 000000000000..57d050c990ec
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nvptx/mptx=4.1.c
@@ -0,0 +1,19 @@
+/* { dg-do assemble } */
+/* { dg-options {-march=sm_30 -mptx=4.1} } */
+/* { dg-additional-options -save-temps } */
+/* { dg-final { scan-assembler-times {(?n)^    \.version       4\.1$} 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__ != 1
+#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