[clang] [llvm] Enable OpenCL hostcall printf (WIP) (PR #72556)
Sameer Sahasrabuddhe via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 19 22:49:37 PST 2023
================
@@ -26,28 +26,31 @@ using namespace llvm;
#define DEBUG_TYPE "amdgpu-emit-printf"
-static Value *fitArgInto64Bits(IRBuilder<> &Builder, Value *Arg) {
+static Value *fitArgInto64Bits(IRBuilder<> &Builder, Value *Arg,
+ bool IsBuffered) {
+ const DataLayout &DL = Builder.GetInsertBlock()->getModule()->getDataLayout();
auto Int64Ty = Builder.getInt64Ty();
auto Ty = Arg->getType();
if (auto IntTy = dyn_cast<IntegerType>(Ty)) {
- switch (IntTy->getBitWidth()) {
- case 32:
- return Builder.CreateZExt(Arg, Int64Ty);
- case 64:
- return Arg;
+ if (IntTy->getBitWidth() < 64) {
+ return Builder.CreateZExt(Arg, Builder.getInt64Ty());
}
}
- if (Ty->getTypeID() == Type::DoubleTyID) {
+ if (Ty->isFloatingPointTy()) {
+ if (DL.getTypeAllocSize(Ty) < 8)
+ Arg = Builder.CreateFPExt(Arg, Builder.getDoubleTy());
----------------
ssahasra wrote:
This typecast should not be necessary. Default argument promotions in C++ for variadic functions ensure that all floating point arguments are promoted to double. If that is not happening, can you demonstrate with a test?
https://github.com/llvm/llvm-project/pull/72556
More information about the cfe-commits
mailing list