]> git.ipfire.org Git - thirdparty/gcc.git/commit - gcc/config.gcc
nvptx: Add a __PTX_SM__ predefined macro based on target ISA.
authorRoger Sayle <roger@nextmovesoftware.com>
Tue, 24 Aug 2021 17:02:18 +0000 (18:02 +0100)
committerRoger Sayle <roger@nextmovesoftware.com>
Tue, 24 Aug 2021 17:02:18 +0000 (18:02 +0100)
commit3c496e92d795a8fe5c527e3c5b5a6606669ae50d
tree7e8fd24555d97b4e0f13a42aca74f9e5050d57f7
parent820f0940d7ace1306430a9dcf1bd9577508a7a7e
nvptx: Add a __PTX_SM__ predefined macro based on target ISA.

This patch adds a __PTX_SM__ predefined macro to the nvptx backend that
allows code to check the compute model being targeted by the compiler.
This is equivalent to the __CUDA_ARCH__ macro defined by CUDA's nvcc
compiler, but to avoid causing problems for source code that checks
for that compiler, this macro uses GCC's nomenclature; it's easy
enough for users to "#define __CUDA_ARCH__ __PTX_SM__".

What might have been a four line patch is actually a little more
complicated, as this patch takes the opportunity to upgrade the
nvptx backend to use the now preferred nvptx-c.c idiom.

2021-08-24  Roger Sayle  <roger@nextmovesoftware.com>
    Tom de Vries  <tdevries@suse.de>

gcc/ChangeLog
* config.gcc (nvptx-*-*): Define {c,c++}_target_objs.
* config/nvptx/nvptx-protos.h (nvptx_cpu_cpp_builtins): Prototype.
* config/nvptx/nvptx.h (TARGET_CPU_CPP_BUILTINS): Implement with
a call to the new nvptx_cpu_cpp_builtins function in nvptx-c.c.
* config/nvptx/t-nvptx (nvptx-c.o): New rule.
* config/nvptx/nvptx-c.c: New source file.
(nvptx_cpu_cpp_builtins): Move implementation here.
gcc/config.gcc
gcc/config/nvptx/nvptx-c.c [new file with mode: 0644]
gcc/config/nvptx/nvptx-protos.h
gcc/config/nvptx/nvptx.h
gcc/config/nvptx/t-nvptx