arch/arm: Add LLVM configuration to CMake

Added LLVM-specific configuration variables to ARM architecture CMake files:
- LLVM_ARCHTYPE for architecture variant (thumbv6m, thumbv7a, etc)
- LLVM_CPUTYPE for CPU target (cortex-m0, cortex-a5, etc)
- LLVM_ABITYPE for ABI (eabi/eabihf)

These changes enable LLVM/Clang toolchain support while maintaining
compatibility with existing GCC configurations. The LLVM variables
are set based on the same architecture/CPU/FPU configurations used
for GCC flags.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
Huang Qi 2025-01-10 14:17:47 +08:00 committed by archer
parent f2934935d0
commit 6dbdfb3cd5
4 changed files with 65 additions and 0 deletions

View file

@ -21,3 +21,8 @@
# ##############################################################################
add_compile_options(-mcpu=cortex-m0 -mthumb -mfloat-abi=soft)
# LLVM Configuration
set(LLVM_ARCHTYPE thumbv6m)
set(LLVM_ABITYPE eabi)
set(LLVM_CPUTYPE cortex-m0)

View file

@ -24,12 +24,28 @@ set(PLATFORM_FLAGS)
if(CONFIG_ARCH_CORTEXA5)
list(APPEND PLATFORM_FLAGS -mcpu=cortex-a5)
set(LLVM_CPUTYPE cortex-a5)
elseif(CONFIG_ARCH_CORTEXA7)
list(APPEND PLATFORM_FLAGS -mcpu=cortex-a7)
set(LLVM_CPUTYPE cortex-a7)
elseif(CONFIG_ARCH_CORTEXA8)
list(APPEND PLATFORM_FLAGS -mcpu=cortex-a8)
set(LLVM_CPUTYPE cortex-a8)
elseif(CONFIG_ARCH_CORTEXA9)
list(APPEND PLATFORM_FLAGS -mcpu=cortex-a9)
set(LLVM_CPUTYPE cortex-a9)
endif()
if(CONFIG_ARM_THUMB)
set(LLVM_ARCHTYPE thumbv7a)
else()
set(LLVM_ARCHTYPE armv7-a)
endif()
if(CONFIG_ARCH_FPU)
set(LLVM_ABITYPE eabihf)
else()
set(LLVM_ABITYPE eabi)
endif()
if(NOT CONFIG_ARM_DPFPU32)

View file

@ -38,4 +38,23 @@ else() # gcc
set(TOOLCHAIN_ARCH_FILE armv7-m_gcc)
endif()
# LLVM Configuration
if(CONFIG_ARCH_CORTEXM3)
set(LLVM_ARCHTYPE thumbv7m)
set(LLVM_CPUTYPE cortex-m3)
else()
set(LLVM_ARCHTYPE thumbv7em)
if(CONFIG_ARCH_CORTEXM4)
set(LLVM_CPUTYPE cortex-m4)
elseif(CONFIG_ARCH_CORTEXM7)
set(LLVM_CPUTYPE cortex-m7)
endif()
endif()
if(CONFIG_ARCH_FPU)
set(LLVM_ABITYPE eabihf)
else()
set(LLVM_ABITYPE eabi)
endif()
include(${TOOLCHAIN_ARCH_FILE})

View file

@ -22,6 +22,31 @@
set(PLATFORM_FLAGS)
# LLVM Configuration
if(CONFIG_ARCH_CORTEXM23)
set(LLVM_ARCHTYPE thumbv8m.base)
set(LLVM_CPUTYPE cortex-m23)
elseif(CONFIG_ARCH_CORTEXM33)
set(LLVM_ARCHTYPE thumbv8m.main)
set(LLVM_CPUTYPE cortex-m33)
elseif(CONFIG_ARCH_CORTEXM35P)
set(LLVM_ARCHTYPE thumbv8m.main)
set(LLVM_CPUTYPE cortex-m35p)
elseif(CONFIG_ARCH_CORTEXM55)
set(LLVM_ARCHTYPE thumbv8.1m.main)
set(LLVM_CPUTYPE cortex-m55)
elseif(CONFIG_ARCH_CORTEXM85)
set(LLVM_ARCHTYPE thumbv8.1m.main)
set(LLVM_CPUTYPE cortex-m85)
endif()
# Set ABI type based on FPU configuration
if(CONFIG_ARCH_FPU)
set(LLVM_ABITYPE eabihf)
else()
set(LLVM_ABITYPE eabi)
endif()
if(CONFIG_ARM_DSP)
set(EXTCPUFLAGS +dsp)
endif()