1# SPDX-License-Identifier: Apache-2.0
2
3set(ARM_C_FLAGS)
4
5list(APPEND ARM_C_FLAGS   -mcpu=${GCC_M_CPU})
6
7if(CONFIG_COMPILER_ISA_THUMB2)
8  list(APPEND ARM_C_FLAGS   -mthumb)
9endif()
10
11list(APPEND ARM_C_FLAGS -mabi=aapcs)
12
13if(CONFIG_FPU)
14  list(APPEND ARM_C_FLAGS   -mfpu=${GCC_M_FPU})
15
16  if(CONFIG_DCLS AND NOT CONFIG_FP_HARDABI)
17    # If the processor is equipped with VFP and configured in DCLS topology,
18    # the FP "hard" ABI must be used in order to facilitate the FP register
19    # initialisation and synchronisation.
20    set(FORCE_FP_HARDABI TRUE)
21  endif()
22
23  if    (CONFIG_FP_HARDABI OR FORCE_FP_HARDABI)
24    list(APPEND ARM_C_FLAGS   -mfloat-abi=hard)
25  elseif(CONFIG_FP_SOFTABI)
26    list(APPEND ARM_C_FLAGS   -mfloat-abi=softfp)
27  endif()
28else()
29  list(APPEND ARM_C_FLAGS   -mfpu=none)
30  # Disable usage of FPU registers
31  list(APPEND ARM_C_FLAGS   -mfloat-abi=soft)
32endif()
33
34if(CONFIG_FP16)
35  # Clang only supports IEEE 754-2008 format for __fp16. It's enabled by
36  # default, so no need to do anything when CONFIG_FP16_IEEE is selected.
37  if(CONFIG_FP16_ALT)
38    message(FATAL_ERROR "Clang doesn't support ARM alternative format for FP16")
39  endif()
40endif()
41list(APPEND TOOLCHAIN_C_FLAGS ${ARM_C_FLAGS})
42list(APPEND TOOLCHAIN_LD_FLAGS NO_SPLIT ${ARM_C_FLAGS})
43