[AMDGPU] add support for hostcall buffer pointer as hidden kernel argument
Hostcall is a service that allows a kernel to submit requests to the
host using shared buffers, and block until a response is
received. This will eventually replace the shared buffer currently
used for printf, and repurposes the same hidden kernel argument. This
change introduces a new ValueKind in the HSA metadata to represent the
hostcall buffer.
Differential Revision: https://reviews.llvm.org/D70038
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp b/llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp
index 9f5bcd8..511d629 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp
@@ -421,7 +421,12 @@
if (HiddenArgNumBytes >= 32) {
if (Func.getParent()->getNamedMetadata("llvm.printf.fmts"))
emitKernelArg(DL, Int8PtrTy, ValueKind::HiddenPrintfBuffer);
- else
+ else if (Func.getParent()->getFunction("__ockl_hostcall_internal")) {
+ // The printf runtime binding pass should have ensured that hostcall and
+ // printf are not used in the same module.
+ assert(!Func.getParent()->getNamedMetadata("llvm.printf.fmts"));
+ emitKernelArg(DL, Int8PtrTy, ValueKind::HiddenHostcallBuffer);
+ } else
emitKernelArg(DL, Int8PtrTy, ValueKind::HiddenNone);
}
@@ -854,7 +859,12 @@
if (HiddenArgNumBytes >= 32) {
if (Func.getParent()->getNamedMetadata("llvm.printf.fmts"))
emitKernelArg(DL, Int8PtrTy, "hidden_printf_buffer", Offset, Args);
- else
+ else if (Func.getParent()->getFunction("__ockl_hostcall_internal")) {
+ // The printf runtime binding pass should have ensured that hostcall and
+ // printf are not used in the same module.
+ assert(!Func.getParent()->getNamedMetadata("llvm.printf.fmts"));
+ emitKernelArg(DL, Int8PtrTy, "hidden_hostcall_buffer", Offset, Args);
+ } else
emitKernelArg(DL, Int8PtrTy, "hidden_none", Offset, Args);
}