[libclc] [libclc] Add prepare-<triple> targets (PR #146700)
Fraser Cormack via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 3 00:30:24 PDT 2025
================
@@ -356,55 +356,72 @@ function(add_libclc_builtin_set)
set( builtins_link_lib $<TARGET_PROPERTY:${builtins_link_lib_tgt},TARGET_FILE> )
+ # For SPIR-V targets we diverage at this point and generate SPIR-V using the
+ # llvm-spirv tool.
if( ARG_ARCH STREQUAL spirv OR ARG_ARCH STREQUAL spirv64 )
- set( spv_suffix ${ARG_ARCH_SUFFIX}.spv )
- add_custom_command( OUTPUT ${spv_suffix}
- COMMAND ${llvm-spirv_exe} ${spvflags} -o ${spv_suffix} ${builtins_link_lib}
+ set( obj_suffix ${ARG_ARCH_SUFFIX}.spv )
+ add_custom_command( OUTPUT ${obj_suffix}
+ COMMAND ${llvm-spirv_exe} ${spvflags} -o ${obj_suffix} ${builtins_link_lib}
DEPENDS ${llvm-spirv_target} ${builtins_link_lib} ${builtins_link_lib_tgt}
)
- add_custom_target( "prepare-${spv_suffix}" ALL DEPENDS "${spv_suffix}" )
- set_target_properties( "prepare-${spv_suffix}" PROPERTIES FOLDER "libclc/Device IR/Prepare" )
- install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${spv_suffix}
- DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" )
-
- return()
- endif()
+ else()
+ # Non-SPIR-V targets add an extra step to optimize the bytecode
----------------
frasercrmck wrote:
Yes I can look into that as a follow-up. Thanks for the idea.
I'd quite like to avoid using `opt` altogether, to be honest. I wonder if using liboffload's approach of using `clang` with LTO to create a bytecode library would solve this problem somewhat. I started looking into it but got pulled in other directions.
https://github.com/llvm/llvm-project/pull/146700
More information about the cfe-commits
mailing list