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. --- 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/gcc.target/nvptx/mptx=4.1.c | 19 +++++++++++++++++++ 6 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/nvptx/mptx=4.1.c
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 fb5a45a18e3c..85c6f5d75912 100644 --- a/gcc/config/nvptx/nvptx.cc +++ b/gcc/config/nvptx/nvptx.cc @@ -252,6 +252,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: @@ -272,6 +274,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 d9a5e541257d..7b7e172f7878 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_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 a2234725e671..6ec68347967d 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -30073,7 +30073,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/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; -- 2.34.1