[clang] 5a4a014 - [OpenCL] Move printf declaration to opencl-c-base.h

Sven van Haastregt via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 18 03:27:49 PST 2021


Author: Sven van Haastregt
Date: 2021-02-18T11:27:19Z
New Revision: 5a4a01460f1a8f29db9aa3581097dd8bc105425c

URL: https://github.com/llvm/llvm-project/commit/5a4a01460f1a8f29db9aa3581097dd8bc105425c
DIFF: https://github.com/llvm/llvm-project/commit/5a4a01460f1a8f29db9aa3581097dd8bc105425c.diff

LOG: [OpenCL] Move printf declaration to opencl-c-base.h

Supporting `printf` with `-fdeclare-opencl-builtins` would require
special handling (for e.g. varargs and format attributes) for just
this one function.  Instead, move the `printf` declaration to the
shared base header.

Differential Revision: https://reviews.llvm.org/D96789

Added: 
    

Modified: 
    clang/lib/Headers/opencl-c-base.h
    clang/lib/Headers/opencl-c.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/Headers/opencl-c-base.h b/clang/lib/Headers/opencl-c-base.h
index fdd50324bd74..30ac9d19fbbd 100644
--- a/clang/lib/Headers/opencl-c-base.h
+++ b/clang/lib/Headers/opencl-c-base.h
@@ -460,6 +460,12 @@ typedef struct {
 
 #endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
 
+#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
+// OpenCL v1.2 s6.12.13, v2.0 s6.13.13 - printf
+
+int printf(__constant const char* st, ...) __attribute__((format(printf, 1, 2)));
+#endif
+
 #ifdef cl_intel_device_side_avc_motion_estimation
 #pragma OPENCL EXTENSION cl_intel_device_side_avc_motion_estimation : begin
 

diff  --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index ab665628c8e1..b686ff387788 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -14176,12 +14176,6 @@ half16 __ovld __cnfn shuffle2(half8 x, half8 y, ushort16 mask);
 half16 __ovld __cnfn shuffle2(half16 x, half16 y, ushort16 mask);
 #endif //cl_khr_fp16
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
-// OpenCL v1.2 s6.12.13, v2.0 s6.13.13 - printf
-
-int printf(__constant const char* st, ...) __attribute__((format(printf, 1, 2)));
-#endif
-
 // OpenCL v1.1 s6.11.3, v1.2 s6.12.14, v2.0 s6.13.14 - Image Read and Write Functions
 
 #ifdef cl_khr_gl_msaa_sharing


        


More information about the cfe-commits mailing list