[libclc] [libclc] Move several integer functions to CLC library (PR #116786)
Matt Arsenault via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 4 09:17:52 PST 2024
================
@@ -0,0 +1,21 @@
+#ifndef __CLC_INTEGER_CLC_CLZ_H__
+#define __CLC_INTEGER_CLC_CLZ_H__
+
+#if defined(CLC_CLSPV) || defined(CLC_SPIRV)
+// clspv and spir-v targets provide their own OpenCL-compatible clz
+#define __clc_clz clz
----------------
arsenm wrote:
> I'm not sure why wrapping the intrinsic isn't a suitable implementation for SPIR-V targets.
I assert it must be and SPIRV must handle the intrinsic.
> I keep going back and forth between whether libclc should be judgemental about that, or whether it should allow targets to opt out of any definition they want.
The intent of libclc is not a free form user library. It is compiler data for clang to implement opencl. Allowing targets to define the implementation function as a redirection to the standard entrypoint just doesn't make sense. Plus every target should be dragged to use the generic implementation as much as possible, or else there's little point in using shared infrastructure. In cases where there's a direct llvm intrinsic there's no sensible reason to emit something else.
https://github.com/llvm/llvm-project/pull/116786
More information about the cfe-commits
mailing list