nvptx: Expose '-mptx=4.2'

'PTX_VERSION_4_2' was added in commit decde11183
"[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.
This commit is contained in:
Thomas Schwinge 2024-11-10 17:35:07 +01:00
parent 380ceb23b1
commit 1af83aa099
4 changed files with 30 additions and 3 deletions

View 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)

View 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)

View 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=}.

View file

@ -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;