[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / builtins / CMakeLists.txt
blobe3796f840a648eda1213b24859fb86f9de85a6d0
1 set(BUILTINS_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
3 set(BUILTINS_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS} builtins)
4 set(BUILTINS_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/TestCases)
6 # Test cases.
7 configure_lit_site_cfg(
8   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
9   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
12 #Unit tests.
14 include(builtin-config-ix)
16 # Indicate if this is an MSVC environment.
17 pythonize_bool(MSVC)
19 # Indicate if the compiler for the builtins library was MSVC. If the builtins
20 # compiler was clang-cl, we will enable some features that the host compiler
21 # will not, like C99 _Complex and int128.
22 set(BUILTINS_IS_MSVC OFF)
23 if (MSVC AND NOT "${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
24   set(BUILTINS_IS_MSVC ON)
25 endif()
26 pythonize_bool(BUILTINS_IS_MSVC)
28 set(BUILTIN_TEST_ARCH ${BUILTIN_SUPPORTED_ARCH})
29 if(APPLE)
30   darwin_filter_host_archs(BUILTIN_SUPPORTED_ARCH BUILTIN_TEST_ARCH)
31 endif()
33 foreach(arch ${BUILTIN_TEST_ARCH})
34   set(BUILTINS_TEST_TARGET_ARCH ${arch})
35   string(TOLOWER "-${arch}-${OS_NAME}" BUILTINS_TEST_CONFIG_SUFFIX)
36   get_test_cc_for_arch(${arch} BUILTINS_TEST_TARGET_CC BUILTINS_TEST_TARGET_CFLAGS)
37   if (${arch} STREQUAL "armhf")
38     list(APPEND BUILTINS_TEST_TARGET_CFLAGS -fomit-frame-pointer -DCOMPILER_RT_ARMHF_TARGET)
39     string(REPLACE ";" " " BUILTINS_TEST_TARGET_CFLAGS "${BUILTINS_TEST_TARGET_CFLAGS}")
40   endif()
42   if (${arch} STREQUAL "riscv32")
43     list(APPEND BUILTINS_TEST_TARGET_CFLAGS -fforce-enable-int128)
44     string(REPLACE ";" " " BUILTINS_TEST_TARGET_CFLAGS "${BUILTINS_TEST_TARGET_CFLAGS}")
45   endif()
47   # Compute builtins available in library and add them as lit features.
48   if(APPLE)
49     # TODO: Support other Apple platforms.
50     set(BUILTIN_LIB_TARGET_NAME "clang_rt.builtins_${arch}_osx")
51   else()
52     set(BUILTIN_LIB_TARGET_NAME "clang_rt.builtins-${arch}")
53   endif()
54   if (NOT TARGET "${BUILTIN_LIB_TARGET_NAME}")
55     message(FATAL_ERROR "Target ${BUILTIN_LIB_TARGET_NAME} does not exist")
56   endif()
57   get_target_property(BUILTIN_LIB_SOURCES "${BUILTIN_LIB_TARGET_NAME}" SOURCES)
58   list(LENGTH BUILTIN_LIB_SOURCES BUILTIN_LIB_SOURCES_LENGTH)
59   if (BUILTIN_LIB_SOURCES_LENGTH EQUAL 0)
60     message(FATAL_ERROR "Failed to find source files for ${arch} builtin library")
61   endif()
62   set(BUILTINS_LIT_SOURCE_FEATURES "")
63   foreach (file_name ${BUILTIN_LIB_SOURCES})
64     # Strip off any directories and file extensions. This approach means we add
65     # add a single feature if there is a C source file or assembly override
66     # present in the builtin library.
67     # E.g.
68     # "hexagon/udivsi3.S" => "udivsi3"
69     # "udivsi3.c" => "udivsi3"
70     get_filename_component(FILE_NAME_FILTERED "${file_name}" NAME_WE)
71     list(APPEND BUILTINS_LIT_SOURCE_FEATURES "librt_has_${FILE_NAME_FILTERED}")
72   endforeach()
74   string(TOUPPER ${arch} ARCH_UPPER_CASE)
75   set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config)
76   configure_lit_site_cfg(
77     ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in
78     ${CMAKE_CURRENT_BINARY_DIR}/Unit/${CONFIG_NAME}/lit.site.cfg.py
79     )
80   list(APPEND BUILTINS_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit/${CONFIG_NAME})
81 endforeach()
83 # TODO: Add support for running tests on iOS and iOS simulator.
85 add_lit_testsuite(check-builtins "Running the Builtins tests"
86   ${BUILTINS_TESTSUITES}
87   DEPENDS ${BUILTINS_TEST_DEPS})
88 set_target_properties(check-builtins PROPERTIES FOLDER "Compiler-RT Misc")