]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
nvptx: Expose '-mptx=4.2'
authorThomas Schwinge <tschwinge@baylibre.com>
Sun, 10 Nov 2024 16:35:07 +0000 (17:35 +0100)
committerThomas Schwinge <tschwinge@baylibre.com>
Fri, 6 Dec 2024 11:11:44 +0000 (12:11 +0100)
'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.

gcc/config/nvptx/nvptx.h
gcc/config/nvptx/nvptx.opt
gcc/doc/invoke.texi
gcc/testsuite/gcc.target/nvptx/mptx=4.2.c [new file with mode: 0644]

index 792da4901d226db433e9b138beb2a948a67dc768..d9a5e541257d6f43c00d05c25b553402f61991a7 100644 (file)
@@ -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)
index 53ddf451836e8c41b253efbb72a4fc3e97b142f3..408c8835444641dd8fda72bda7add4487446c22f 100644 (file)
@@ -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)
 
index 33a1b6b7983a87f0085e8071047be391531f5e25..a2234725e671a9a52c228e21c48e11a6f2a469e7 100644 (file)
@@ -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 (file)
index 0000000..e17ee1b
--- /dev/null
@@ -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;