[HIPSPV] Convert HIP kernels to SPIR-V kernels
authorHenry Linjamäki <henry.linjamaki@parmance.com>
Wed, 8 Dec 2021 07:47:25 +0000 (10:47 +0300)
committerAlexey Bader <alexey.bader@intel.com>
Wed, 8 Dec 2021 09:18:15 +0000 (12:18 +0300)
commit9ae5810b53c2e096d7442ba8af3f00ebc3d301b0
treeb249f8291a9b3e1a7cf1402ad414319c71ae3837
parent45aa435661d80843554d425156f300b207d8a0a0
[HIPSPV] Convert HIP kernels to SPIR-V kernels

This patch translates HIP kernels to SPIR-V kernels when the HIP
compilation mode is targeting SPIR-S. This involves:

* Setting Cuda calling convention to CC_OpenCLKernel (which maps to
  SPIR_KERNEL in LLVM IR later on).

* Coercing pointer arguments with default address space (AS) qualifier
  to CrossWorkGroup AS (__global in OpenCL). HIPSPV's device code is
  ultimately SPIR-V for OpenCL execution environment (as
  starter/default) where Generic or Function (OpenCL's private) is not
  supported as storage class for kernel pointer types. This leaves the
  CrossWorkGroup to be the only reasonable choice for HIP buffers.

Reviewed By: yaxunl

Differential Revision: https://reviews.llvm.org/D109818
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGenHIP/hipspv-kernel.cpp [new file with mode: 0644]