summaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorVikram <Vikram.Hegde@amd.com>2023-05-11 05:00:17 -0400
committerVikram <Vikram.Hegde@amd.com>2023-06-10 09:55:00 -0400
commit631c965483e03355cdc1dba578e787b259c4d79d (patch)
treeab33b4937c83fd63cf97d8c6d869759e07a8673f /clang/lib/CodeGen/CodeGenModule.cpp
parent55aeb23fe0084d930ecd7335092d712bd71694c7 (diff)
[AMDGPU] Non hostcall printf support for HIP
This is an alternative to currently existing hostcall implementation and uses printf buffer similar to OpenCL, The data stored in the buffer (i.e the data frame) for each printf call are as follows, 1. Control DWord - contains info regarding stream, format string constness and size of data frame 2. Hash of the format string (if constant) else the format string itself 3. Printf arguments (each aligned to 8 byte boundary) The format string Hash is generated using LLVM's MD5 Message-Digest Algorithm implementation and only low 64 bits are used. The implementation still uses amdhsa metadata and hash is stored as part of format string itself to ensure minimal changes in runtime. Differential Revision: https://reviews.llvm.org/D150427
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index ac8ff6455612..b5bd9f7c94f5 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -611,6 +611,17 @@ void CodeGenModule::Release() {
"amdgpu_code_object_version",
getTarget().getTargetOpts().CodeObjectVersion);
}
+
+ // Currently, "-mprintf-kind" option is only supported for HIP
+ if (LangOpts.HIP) {
+ auto *MDStr = llvm::MDString::get(
+ getLLVMContext(), (getTarget().getTargetOpts().AMDGPUPrintfKindVal ==
+ TargetOptions::AMDGPUPrintfKind::Hostcall)
+ ? "hostcall"
+ : "buffered");
+ getModule().addModuleFlag(llvm::Module::Error, "amdgpu_printf_kind",
+ MDStr);
+ }
}
// Emit a global array containing all external kernels or device variables