1# SPDX-License-Identifier: Apache-2.0
2list(APPEND TOOLCHAIN_C_FLAGS   -mcpu=${GCC_M_CPU})
3list(APPEND TOOLCHAIN_LD_FLAGS  -mcpu=${GCC_M_CPU})
4
5if(CONFIG_COMPILER_ISA_THUMB2)
6  list(APPEND TOOLCHAIN_C_FLAGS   -mthumb)
7  list(APPEND TOOLCHAIN_LD_FLAGS  -mthumb)
8endif()
9
10list(APPEND TOOLCHAIN_C_FLAGS -mabi=aapcs)
11list(APPEND TOOLCHAIN_LD_FLAGS -mabi=aapcs)
12
13# Defines a mapping from GCC_M_CPU to FPU
14
15if(CONFIG_CPU_HAS_FPU_DOUBLE_PRECISION)
16  set(PRECISION_TOKEN)
17else()
18  set(PRECISION_TOKEN sp-)
19endif()
20
21set(FPU_FOR_cortex-m4           fpv4-${PRECISION_TOKEN}d16)
22set(FPU_FOR_cortex-m7           fpv5-${PRECISION_TOKEN}d16)
23set(FPU_FOR_cortex-m33          fpv5-${PRECISION_TOKEN}d16)
24set(FPU_FOR_cortex-m33+nodsp    fpv5-${PRECISION_TOKEN}d16)
25set(FPU_FOR_cortex-m55          auto)
26set(FPU_FOR_cortex-m55+nomve.fp auto)
27set(FPU_FOR_cortex-m55+nomve    auto)
28set(FPU_FOR_cortex-m55+nodsp    auto)
29
30if(CONFIG_FPU)
31  list(APPEND TOOLCHAIN_C_FLAGS   -mfpu=${FPU_FOR_${GCC_M_CPU}})
32  list(APPEND TOOLCHAIN_LD_FLAGS  -mfpu=${FPU_FOR_${GCC_M_CPU}})
33  if    (CONFIG_FP_SOFTABI)
34    list(APPEND TOOLCHAIN_C_FLAGS   -mfloat-abi=softfp)
35    list(APPEND TOOLCHAIN_LD_FLAGS  -mfloat-abi=softfp)
36  elseif(CONFIG_FP_HARDABI)
37    list(APPEND TOOLCHAIN_C_FLAGS   -mfloat-abi=hard)
38    list(APPEND TOOLCHAIN_LD_FLAGS  -mfloat-abi=hard)
39  endif()
40endif()
41
42if(CONFIG_FP16)
43  if    (CONFIG_FP16_IEEE)
44    list(APPEND TOOLCHAIN_C_FLAGS   -mfp16-format=ieee)
45    list(APPEND TOOLCHAIN_LD_FLAGS  -mfp16-format=ieee)
46  elseif(CONFIG_FP16_ALT)
47    list(APPEND TOOLCHAIN_C_FLAGS   -mfp16-format=alternative)
48    list(APPEND TOOLCHAIN_LD_FLAGS  -mfp16-format=alternative)
49  endif()
50endif()
51