Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions compiler-rt/cmake/Modules/CheckAssemblerFlag.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Helper function to find out whether the assembler supports a particular
# command-line flag. You'd like to use the standard check_compiler_flag(), but
# that only supports a fixed list of languages, and ASM isn't one of them. So
# we do it ourselves, by trying to assemble an empty source file.

function(check_assembler_flag outvar flag)
if(NOT DEFINED "${outvar}")
if(NOT CMAKE_REQUIRED_QUIET)
message(CHECK_START "Checking for assembler flag ${flag}")
endif()

# Stop try_compile from attempting to link the result of the assembly, so
# that we don't depend on having a working linker, and also don't have to
# figure out what special symbol like _start needs to be defined in the
# test input.
#
# This change is made within the dynamic scope of this function, so
# CMAKE_TRY_COMPILE_TARGET_TYPE will be restored to its previous value on
# return.
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)

# Try to assemble an empty file with a .S name, using the provided flag.
set(asm_source_file
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckAssemblerFlag.S)
write_file(${asm_source_file} "")
try_compile(${outvar}
${CMAKE_BINARY_DIR}
SOURCES ${asm_source_file}
COMPILE_DEFINITIONS ${flag})

if(NOT CMAKE_REQUIRED_QUIET)
if(${outvar})
message(CHECK_PASS "Accepted")
else()
message(CHECK_FAIL "Not accepted")
endif()
endif()
endif()
endfunction()
47 changes: 47 additions & 0 deletions compiler-rt/lib/builtins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ endif()
include(builtin-config-ix)
include(CMakeDependentOption)
include(CMakePushCheckState)
include(CheckAssemblerFlag)

option(COMPILER_RT_BUILTINS_HIDE_SYMBOLS
"Do not export any symbols from the static library." ON)
Expand Down Expand Up @@ -423,6 +424,40 @@ set(arm_or_thumb2_base_SOURCES
${GENERIC_SOURCES}
)

option(COMPILER_RT_ARM_OPTIMIZED_FP
"On 32-bit Arm, use optimized assembly implementations of FP arithmetic. Likely to increase code size, but be faster." ON)

set(arm_or_thumb2_optimized_fp_SOURCES)
if(COMPILER_RT_ARM_OPTIMIZED_FP AND BUILTIN_SUPPORTED_ARCH MATCHES "arm")
check_assembler_flag(COMPILER_RT_HAS_MIMPLICIT_IT -mimplicit-it=always)
if(COMPILER_RT_HAS_MIMPLICIT_IT)
set(implicit_it_flag -mimplicit-it=always)
else()
check_assembler_flag(
COMPILER_RT_HAS_WA_MIMPLICIT_IT -Wa,-mimplicit-it=always)
if(COMPILER_RT_HAS_WA_MIMPLICIT_IT)
set(implicit_it_flag -Wa,-mimplicit-it=always)
else()
message(WARNING "Don't know how to set the -mimplicit-it=always flag in this assembler; not including Arm optimized implementations")
set(implicit_it_flag "")
endif()
endif()

if(implicit_it_flag)
set(assembly_files
arm/mulsf3.S
arm/divsf3.S)
set_source_files_properties(${assembly_files}
PROPERTIES COMPILE_OPTIONS ${implicit_it_flag})
set(arm_or_thumb2_optimized_fp_SOURCES
${assembly_files}
arm/fnan2.c
arm/fnorm2.c
arm/funder.c
)
endif()
endif()

set(arm_sync_SOURCES
arm/sync_fetch_and_add_4.S
arm/sync_fetch_and_add_8.S
Expand Down Expand Up @@ -456,6 +491,16 @@ set(thumb1_base_SOURCES
${GENERIC_SOURCES}
)

if(COMPILER_RT_ARM_OPTIMIZED_FP)
set(thumb1_base_SOURCES
arm/thumb1/mulsf3.S
arm/fnan2.c
arm/fnorm2.c
arm/funder.c
${thumb1_base_SOURCES}
)
endif()

set(arm_EABI_RT_SOURCES
arm/aeabi_cdcmp.S
arm/aeabi_cdcmpeq_check_nan.c
Expand Down Expand Up @@ -567,6 +612,7 @@ if(MINGW)
arm/aeabi_uldivmod.S
arm/chkstk.S
${arm_or_thumb2_base_SOURCES}
${arm_or_thumb2_optimized_fp_SOURCES}
${arm_sync_SOURCES}
)

Expand All @@ -577,6 +623,7 @@ elseif(NOT WIN32)
# TODO the EABI sources should only be added to EABI targets
set(arm_SOURCES
${arm_or_thumb2_base_SOURCES}
${arm_or_thumb2_optimized_fp_SOURCES}
${arm_sync_SOURCES}
${arm_EABI_SOURCES}
${arm_Thumb1_SOURCES}
Expand Down
Loading
Loading