Skip to content

Commit

Permalink
Allow FPU flag override (#471)
Browse files Browse the repository at this point in the history
Command line to build for vfpv3-d16 ARM Cortex-5:

./build.sh -cross -arm -cmakeargs -DCLR_ARM_FPU_CAPABILITY=0x3 -cmakeargs -DCLR_ARM_FPU_TYPE=vfpv3-d16

Fixes https://github.com/dotnet/coreclr/issues/17043
  • Loading branch information
franksinankaya authored and jkotas committed Dec 4, 2019
1 parent 875a54a commit 0c002cc
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
13 changes: 11 additions & 2 deletions eng/common/cross/toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,17 @@ endif()

if(TARGET_ARCH_NAME MATCHES "^(arm|armel)$")
add_compile_options(-mthumb)
add_compile_options(-mfpu=vfpv3)
if(TARGET_ARCH_NAME STREQUAL "armel")
if (NOT DEFINED CLR_ARM_FPU_TYPE)
set(CLR_ARM_FPU_TYPE vfpv3)
endif(NOT DEFINED CLR_ARM_FPU_TYPE)

add_compile_options(-mfpu=${CLR_ARM_FPU_TYPE})
if (NOT DEFINED CLR_ARM_FPU_CAPABILITY)
set(CLR_ARM_FPU_CAPABILITY 0x7)
endif(NOT DEFINED CLR_ARM_FPU_CAPABILITY)
add_definitions(-DCLR_ARM_FPU_CAPABILITY=${CLR_ARM_FPU_CAPABILITY})

if(TARGET_ARCH_NAME STREQUAL "armel")
add_compile_options(-mfloat-abi=softfp)
if(DEFINED TIZEN_TOOLCHAIN)
add_compile_options(-Wno-deprecated-declarations) # compile-time option
Expand Down
10 changes: 9 additions & 1 deletion src/coreclr/configurecompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -537,10 +537,18 @@ if (CLR_CMAKE_PLATFORM_UNIX)
endif(CLR_CMAKE_PLATFORM_UNIX)

if(CLR_CMAKE_PLATFORM_UNIX_ARM)
if (NOT DEFINED CLR_ARM_FPU_TYPE)
set(CLR_ARM_FPU_TYPE vfpv3)
endif(NOT DEFINED CLR_ARM_FPU_TYPE)

# Because we don't use CMAKE_C_COMPILER/CMAKE_CXX_COMPILER to use clang
# we have to set the triple by adding a compiler argument
add_compile_options(-mthumb)
add_compile_options(-mfpu=vfpv3)
add_compile_options(-mfpu=${CLR_ARM_FPU_TYPE})
if (NOT DEFINED CLR_ARM_FPU_CAPABILITY)
set(CLR_ARM_FPU_CAPABILITY 0x7)
endif(NOT DEFINED CLR_ARM_FPU_CAPABILITY)
add_definitions(-DCLR_ARM_FPU_CAPABILITY=${CLR_ARM_FPU_CAPABILITY})
add_compile_options(-march=armv7-a)
if(ARM_SOFTFP)
add_definitions(-DARM_SOFTFP)
Expand Down
8 changes: 8 additions & 0 deletions src/coreclr/src/pal/src/arch/arm/context2.S
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ LEAF_ENTRY CONTEXT_CaptureContext, _TEXT
itttt ne
addne r0, CONTEXT_D0
vstmiane r0!, {d0-d15}
#if CLR_ARM_FPU_CAPABILITY & 0x4
vstmiane r0!, {d16-d31}
#else
addne r0, r0, #128
#endif
subne r0, CONTEXT_D31

// Make sure sp is restored
Expand Down Expand Up @@ -130,7 +134,11 @@ LOCAL_LABEL(Restore_CONTEXT_FLOATING_POINT):
itttt ne
addne r0, CONTEXT_D0
vldmiane r0!, {d0-d15}
#if CLR_ARM_FPU_CAPABILITY & 0x4
vldmiane r0, {d16-d31}
#else
nopne
#endif
subne r0, CONTEXT_D16

itt ne
Expand Down
11 changes: 10 additions & 1 deletion src/libraries/Native/Unix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,16 @@ elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l)
add_compile_options(-mfloat-abi=softfp)
endif ()
add_compile_options(-mthumb)
add_compile_options(-mfpu=vfpv3)
if (NOT DEFINED CLR_ARM_FPU_TYPE)
set(CLR_ARM_FPU_TYPE vfpv3)
endif(NOT DEFINED CLR_ARM_FPU_TYPE)

add_compile_options(-mfpu=${CLR_ARM_FPU_TYPE})
if (NOT DEFINED CLR_ARM_FPU_CAPABILITY)
set(CLR_ARM_FPU_CAPABILITY 0x7)
endif(NOT DEFINED CLR_ARM_FPU_CAPABILITY)
add_definitions(-DCLR_ARM_FPU_CAPABILITY=${CLR_ARM_FPU_CAPABILITY})

add_compile_options(-march=armv7-a)
elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL arm)
add_definitions(-DBIT32=1)
Expand Down

0 comments on commit 0c002cc

Please sign in to comment.