[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

Karol Herbst via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 21 05:54:27 PST 2024


================
@@ -322,22 +322,26 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
 
     if ( ARCH STREQUAL spirv OR ARCH STREQUAL spirv64 )
       set( build_flags -O0 -finline-hint-functions -DCLC_SPIRV )
-      set( opt_flags )
+      set( clc_opt_flags )
+      # Inline CLC functions into OpenCL builtins
+      set( opencl_opt_flags "--passes=always-inline" )
----------------
karolherbst wrote:

`fma` was just an example and that's already done like that. In the SPIR-V we see `OpExtInst` for it and others. For builtins where no such intrinsic exists the `SPIRV-LLVM-Translator` converts those function calls to `OpExtInst` by demangling the function name and match it against an internal list of names.

Of course all the OpenCL C builtins could be turned into their own intrinsics and the need for translating from function call to builtin could be dropped, but the code already exists and it wouldn't necessarily improve the final SPIR-V in any way.

Anyway, feel free to ask questions if you aren't familiar enough with the situation and problems we are dealing with here and I'm happy to explain those things. And we are entirely open to suggestions on how to improve those things or how to formalize it so it's not just a relied upon implementation detail.

https://github.com/llvm/llvm-project/pull/115699


More information about the cfe-commits mailing list