[llvm] [clang] Enable OpenCL hostcall printf (WIP) (PR #72556)

2023-11-19 Thread Sameer Sahasrabuddhe via cfe-commits
@@ -1,12 +1,68 @@ // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py -// RUN: %clang_cc1 -cl-std=CL1.2 -triple amdgcn-amd-amdhsa -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -cl-std=CL1.2 -triple amdgcn-amd-amdhsa -mprint

[llvm] [clang] Enable OpenCL hostcall printf (WIP) (PR #72556)

2023-11-19 Thread Sameer Sahasrabuddhe via cfe-commits
@@ -170,20 +173,49 @@ static Value *appendString(IRBuilder<> &Builder, Value *Desc, Value *Arg, return callAppendStringN(Builder, Desc, Arg, Length, IsLast); } +static Value *appendVectorArg(IRBuilder<> &Builder, Value *Desc, Value *Arg, + bool

[llvm] [clang] Enable OpenCL hostcall printf (WIP) (PR #72556)

2023-11-19 Thread Sameer Sahasrabuddhe via cfe-commits
@@ -406,5 +410,9 @@ TARGET_BUILTIN(__builtin_amdgcn_cvt_pk_fp8_f32, "iffiIb", "nc", "fp8-insts") TARGET_BUILTIN(__builtin_amdgcn_cvt_sr_bf8_f32, "ifiiIi", "nc", "fp8-insts") TARGET_BUILTIN(__builtin_amdgcn_cvt_sr_fp8_f32, "ifiiIi", "nc", "fp8-insts") +// OpenCL +LANGBUILTIN(p

[llvm] [clang] Enable OpenCL hostcall printf (WIP) (PR #72556)

2023-11-19 Thread Sameer Sahasrabuddhe via cfe-commits
@@ -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

[llvm] [clang] Enable OpenCL hostcall printf (WIP) (PR #72556)

2023-11-19 Thread Vikram Hegde via cfe-commits
@@ -278,7 +310,13 @@ static Value *callBufferedPrintfStart( StringData(StringRef(), LenWithNull, LenWithNullAligned, false)); } } else { - int AllocSize = M->getDataLayout().getTypeAllocSize(Args[i]->getType()); + int AllocSize = 0; + if (OC

[llvm] [clang] Enable OpenCL hostcall printf (WIP) (PR #72556)

2023-11-16 Thread Matt Arsenault via cfe-commits
@@ -278,7 +310,13 @@ static Value *callBufferedPrintfStart( StringData(StringRef(), LenWithNull, LenWithNullAligned, false)); } } else { - int AllocSize = M->getDataLayout().getTypeAllocSize(Args[i]->getType()); + int AllocSize = 0; + if (OC

[llvm] [clang] Enable OpenCL hostcall printf (WIP) (PR #72556)

2023-11-16 Thread Matt Arsenault via cfe-commits
@@ -170,20 +173,46 @@ static Value *appendString(IRBuilder<> &Builder, Value *Desc, Value *Arg, return callAppendStringN(Builder, Desc, Arg, Length, IsLast); } +static Value *appendVectorArg(IRBuilder<> &Builder, Value *Desc, Value *Arg, arsenm wrote: All