[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 07:41:20 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:
> The clspv/spirv targets don't provide implementations of all OpenCL builtins
What do you mean by this exactly? I think the system today is backwards and it results in confusing terminology. There are 2 possible interpretation of "target provided" library functions. The backend notion and the libclc notion.
> we need to replace that with a redirection to clz somehow
By `clz` do you mean OpenCL `clz` (Itanium mangled function defined in this bitcode lib) or system/target provided (libc) `clz`? Either way, it shouldn't matter. `__clc_clz` should not be defined in terms of either. The goal here is to just get a call to `llvm.ctlz` (which should be the universal implementation) in the IR. __clc_clz should always just be a wrapper around the intrinsic call. What you have in the impl file should already produce this after instcombine in the scalar case.
I see some of the target overrides are defined directly on the opencl entrypoints. These should be overriding the __clc wrappers, rather than directly overriding the entries. rocm device libs never tries to use the opencl entrypoints internally, and (libclc is originally a fork of the same lib from ~2014). I think the targets should only provide overrides of __clc wrappers, and not directly override the public entrypoints. Those wrappers may end up being implemented with the libm/libc system names (preferably by codegen)
https://github.com/llvm/llvm-project/pull/116786
More information about the cfe-commits
mailing list