brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.4 KiB · 90311ae Raw
95 lines · plain
1set(LLVM_BLAKE3_FILES2  blake3.c3  blake3_dispatch.c4  blake3_portable.c5  blake3_neon.c6)7 8if (LLVM_DISABLE_ASSEMBLY_FILES)9  set(CAN_USE_ASSEMBLER FALSE)10else()11  set(CAN_USE_ASSEMBLER TRUE)12endif()13 14macro(disable_blake3_x86_simd)15  add_compile_definitions(BLAKE3_NO_AVX512 BLAKE3_NO_AVX2 BLAKE3_NO_SSE41 BLAKE3_NO_SSE2)16endmacro()17 18# The BLAKE3 team recommends using the assembly versions, from the README:19#20# "For each of the x86 SIMD instruction sets, four versions are available:21# three flavors of assembly (Unix, Windows MSVC, and Windows GNU) and one22# version using C intrinsics. The assembly versions are generally23# preferred. They perform better, they perform more consistently across24# different compilers, and they build more quickly."25 26if (CAN_USE_ASSEMBLER)27  if (MSVC)28    check_symbol_exists(_M_X64 "" IS_X64)29    check_symbol_exists(_M_ARM64EC "" IS_ARM64EC)30    if (IS_X64 AND NOT IS_ARM64EC)31      enable_language(ASM_MASM)32      set(LLVM_BLAKE3_ASM_FILES33        blake3_sse2_x86-64_windows_msvc.asm34        blake3_sse41_x86-64_windows_msvc.asm35        blake3_avx2_x86-64_windows_msvc.asm36        blake3_avx512_x86-64_windows_msvc.asm37      )38      list(APPEND LLVM_BLAKE3_FILES ${LLVM_BLAKE3_ASM_FILES})39      # Supress the copyright message.40      set_source_files_properties(${LLVM_BLAKE3_ASM_FILES}41        PROPERTIES COMPILE_OPTIONS "/nologo")42    else()43      disable_blake3_x86_simd()44    endif()45  elseif(WIN32 OR CYGWIN)46    check_symbol_exists(__x86_64__ "" IS_X64)47    if (IS_X64)48      list(APPEND LLVM_BLAKE3_FILES49        blake3_sse2_x86-64_windows_gnu.S50        blake3_sse41_x86-64_windows_gnu.S51        blake3_avx2_x86-64_windows_gnu.S52        blake3_avx512_x86-64_windows_gnu.S53      )54      # Clang before 7 needs -mavx512vl to assemble some instructions.55      set_source_files_properties(blake3_avx512_x86-64_windows_gnu.S56        PROPERTIES COMPILE_OPTIONS "-mavx512vl")57    else()58      disable_blake3_x86_simd()59    endif()60  else()61    check_symbol_exists(__x86_64__ "" IS_X64)62    if (IS_X64 OR CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")63      # In a macOS Universal build (setting CMAKE_OSX_ARCHITECTURES to multiple64      # values), compilation of the source files will target multiple architectures65      # (each source file is internally compiled once for each architecture).66      # To accomodate this configuration we include these assembly files without a67      # CMake check but their source is guarded with architecture "#ifdef" checks.68      list(APPEND LLVM_BLAKE3_FILES69        blake3_sse2_x86-64_unix.S70        blake3_sse41_x86-64_unix.S71        blake3_avx2_x86-64_unix.S72        blake3_avx512_x86-64_unix.S73      )74      # Clang before 7 needs -mavx512vl to assemble some instructions.75      set_source_files_properties(blake3_avx512_x86-64_unix.S76        PROPERTIES COMPILE_OPTIONS "-mavx512vl")77    else()78      disable_blake3_x86_simd()79    endif()80  endif()81else()82  # CAN_USE_ASSEMBLER == FALSE83  disable_blake3_x86_simd()84endif()85 86add_library(LLVMSupportBlake3 OBJECT EXCLUDE_FROM_ALL ${LLVM_BLAKE3_FILES})87set_target_properties(LLVMSupportBlake3 PROPERTIES FOLDER "LLVM/Libraries")88llvm_update_compile_flags(LLVMSupportBlake3)89if(LLVM_BUILD_LLVM_DYLIB OR BUILD_SHARED_LIBS)90  # Since LLVMSupportBlake3 is not defined using llvm_add_library(), we must91  # define LLVM_EXPORTS here so its public interface is annotated with92  # __declspec(dllexport) when building as a DLL on Windows.93  target_compile_definitions(LLVMSupportBlake3 PRIVATE LLVM_EXPORTS)94endif()95