zephyr/cmake/gcc-m-fpu.cmake
Stephanos Ioannidis 6d4bce81ae cmake: gcc: target_arm: Support advanced floating-point options
This commit updates the Zephyr build system to support specifying
advanced floating-point compilation options derived from the newly
introduced unified floating-point configurations.

The following changes are introduced by this commit:

1. Specify architecture floating-point option to the `-mcpu` flag.
2. Specify floating-point unit (FPU) type using the `-mfpu` flag.

Note that the `-march` flag is not specified separately because the
`-mcpu` flag provides more detailed architecture options and this
makes the `-march` flag redundant.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-05-05 12:03:27 +09:00

42 lines
1.2 KiB
CMake

# SPDX-License-Identifier: Apache-2.0
# Determines what argument to give to -mfpu= based on the
# KConfig'uration and sets this to GCC_M_FPU
if(CONFIG_FPU)
if("${ARCH}" STREQUAL "arm")
if(CONFIG_CPU_AARCH32_CORTEX_R)
if(CONFIG_CPU_CORTEX_R4 OR CONFIG_CPU_CORTEX_R5) # VFPv3
if(CONFIG_VFP_FEATURE_DOUBLE_PRECISION)
set(GCC_M_FPU vfpv3-d16)
elseif(CONFIG_VFP_FEATURE_SINGLE_PRECISION)
set(GCC_M_FPU vfpv3xd)
endif()
if(CONFIG_VFP_FEATURE_HALF_PRECISION)
set(GCC_M_FPU ${GCC_M_FPU}-fp16)
endif()
endif()
elseif(CONFIG_CPU_CORTEX_M)
# Defines a mapping from GCC_M_CPU to FPU
if(CONFIG_CPU_HAS_FPU_DOUBLE_PRECISION)
set(PRECISION_TOKEN)
else()
set(PRECISION_TOKEN sp-)
endif()
set(FPU_FOR_cortex-m4 fpv4-${PRECISION_TOKEN}d16)
set(FPU_FOR_cortex-m7 fpv5-${PRECISION_TOKEN}d16)
set(FPU_FOR_cortex-m33 fpv5-${PRECISION_TOKEN}d16)
set(FPU_FOR_cortex-m33+nodsp fpv5-${PRECISION_TOKEN}d16)
set(FPU_FOR_cortex-m55 auto)
set(FPU_FOR_cortex-m55+nomve.fp auto)
set(FPU_FOR_cortex-m55+nomve auto)
set(FPU_FOR_cortex-m55+nodsp auto)
set(GCC_M_FPU ${FPU_FOR_${GCC_M_CPU}})
endif()
endif()
endif() #CONFIG_FPU