================ @@ -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()); + if (IsBuffered) + return Arg; return Builder.CreateBitCast(Arg, Int64Ty); } - if (isa<PointerType>(Ty)) { + if (!IsBuffered && isa<PointerType>(Ty)) { return Builder.CreatePtrToInt(Arg, Int64Ty); ---------------- vikramRH wrote:
The pointer is just pushed onto the buffer. The cast is necessary for the hostcall case to be compatible with device lib functions https://github.com/llvm/llvm-project/pull/72556 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits