1# SPDX-License-Identifier: Apache-2.0
2
3# Determines what argument to give to -mfpu= based on the
4# KConfig'uration and sets this to GCC_M_FPU
5
6if(CONFIG_FPU)
7
8if("${ARCH}" STREQUAL "arm")
9  if(CONFIG_CPU_AARCH32_CORTEX_R)
10    if(CONFIG_CPU_CORTEX_R4 OR CONFIG_CPU_CORTEX_R5) # VFPv3
11      if(CONFIG_VFP_FEATURE_DOUBLE_PRECISION)
12        set(GCC_M_FPU vfpv3-d16)
13      elseif(CONFIG_VFP_FEATURE_SINGLE_PRECISION)
14        set(GCC_M_FPU vfpv3xd)
15      endif()
16      if(CONFIG_VFP_FEATURE_HALF_PRECISION)
17        set(GCC_M_FPU ${GCC_M_FPU}-fp16)
18      endif()
19    elseif(CONFIG_CPU_CORTEX_R52)
20      if(CONFIG_VFP_FEATURE_DOUBLE_PRECISION)
21        set(GCC_M_FPU neon-fp-armv8)
22      elseif(CONFIG_VFP_FEATURE_SINGLE_PRECISION)
23        set(GCC_M_FPU fpv5-sp-d16)
24      endif()
25    endif()
26  elseif(CONFIG_CPU_CORTEX_M)
27    # Defines a mapping from GCC_M_CPU to FPU
28    if(CONFIG_CPU_HAS_FPU_DOUBLE_PRECISION)
29      set(PRECISION_TOKEN)
30    else()
31      set(PRECISION_TOKEN sp-)
32    endif()
33
34    set(FPU_FOR_cortex-m4           fpv4-${PRECISION_TOKEN}d16)
35    set(FPU_FOR_cortex-m7           fpv5-${PRECISION_TOKEN}d16)
36    set(FPU_FOR_cortex-m33          fpv5-${PRECISION_TOKEN}d16)
37    set(FPU_FOR_cortex-m33+nodsp    fpv5-${PRECISION_TOKEN}d16)
38    set(FPU_FOR_cortex-m55          auto)
39    set(FPU_FOR_cortex-m55+nomve.fp auto)
40    set(FPU_FOR_cortex-m55+nomve    auto)
41    set(FPU_FOR_cortex-m55+nodsp    auto)
42
43    set(GCC_M_FPU ${FPU_FOR_${GCC_M_CPU}})
44  endif()
45endif()
46
47endif() #CONFIG_FPU
48