[clang] [clang-tools-extra] [llvm] [clang] Simplify device kernel attributes (PR #137882)
Alexey Bader via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 17 16:08:10 PDT 2025
================
@@ -80,12 +80,19 @@ unsigned CodeGenTypes::ClangCallConvToLLVMCallConv(CallingConv CC) {
return llvm::CallingConv::AArch64_VectorCall;
case CC_AArch64SVEPCS:
return llvm::CallingConv::AArch64_SVE_VectorCall;
- case CC_AMDGPUKernelCall:
- return llvm::CallingConv::AMDGPU_KERNEL;
case CC_SpirFunction:
return llvm::CallingConv::SPIR_FUNC;
- case CC_OpenCLKernel:
- return CGM.getTargetCodeGenInfo().getOpenCLKernelCallingConv();
+ case CC_DeviceKernel: {
+ if (CGM.getLangOpts().OpenCL)
+ return CGM.getTargetCodeGenInfo().getOpenCLKernelCallingConv();
+ if (CGM.getTriple().isSPIROrSPIRV())
+ return llvm::CallingConv::SPIR_KERNEL;
+ if (CGM.getTriple().isAMDGPU())
+ return llvm::CallingConv::AMDGPU_KERNEL;
+ if (CGM.getTriple().isNVPTX())
+ return llvm::CallingConv::PTX_Kernel;
+ llvm_unreachable("Unknown kernel calling convention");
+ }
----------------
bader wrote:
@sarnex,
IMHO, the implementation of `CC_DeviceKernel` case should look like:
```c++
case CC_DeviceKernel:
return CGM.getTargetCodeGenInfo().getDeviceKernelCallingConv();
```
SPIR/SPIR-V/NVPTX/AMDGPU targets should define target specific calling convention.
i.e. getOpenCLKernelCallingConv -> getDeviceKernelCallingConv.
https://github.com/llvm/llvm-project/pull/137882
More information about the cfe-commits
mailing list