Skip to content

Commit 6dbdfb3

Browse files
no1wudianchao
authored andcommitted
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>
1 parent f293493 commit 6dbdfb3

File tree

4 files changed

+65
-0
lines changed

4 files changed

+65
-0
lines changed

arch/arm/src/cmake/armv6-m.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,8 @@
2121
# ##############################################################################
2222

2323
add_compile_options(-mcpu=cortex-m0 -mthumb -mfloat-abi=soft)
24+
25+
# LLVM Configuration
26+
set(LLVM_ARCHTYPE thumbv6m)
27+
set(LLVM_ABITYPE eabi)
28+
set(LLVM_CPUTYPE cortex-m0)

arch/arm/src/cmake/armv7-a.cmake

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,28 @@ set(PLATFORM_FLAGS)
2424

2525
if(CONFIG_ARCH_CORTEXA5)
2626
list(APPEND PLATFORM_FLAGS -mcpu=cortex-a5)
27+
set(LLVM_CPUTYPE cortex-a5)
2728
elseif(CONFIG_ARCH_CORTEXA7)
2829
list(APPEND PLATFORM_FLAGS -mcpu=cortex-a7)
30+
set(LLVM_CPUTYPE cortex-a7)
2931
elseif(CONFIG_ARCH_CORTEXA8)
3032
list(APPEND PLATFORM_FLAGS -mcpu=cortex-a8)
33+
set(LLVM_CPUTYPE cortex-a8)
3134
elseif(CONFIG_ARCH_CORTEXA9)
3235
list(APPEND PLATFORM_FLAGS -mcpu=cortex-a9)
36+
set(LLVM_CPUTYPE cortex-a9)
37+
endif()
38+
39+
if(CONFIG_ARM_THUMB)
40+
set(LLVM_ARCHTYPE thumbv7a)
41+
else()
42+
set(LLVM_ARCHTYPE armv7-a)
43+
endif()
44+
45+
if(CONFIG_ARCH_FPU)
46+
set(LLVM_ABITYPE eabihf)
47+
else()
48+
set(LLVM_ABITYPE eabi)
3349
endif()
3450

3551
if(NOT CONFIG_ARM_DPFPU32)

arch/arm/src/cmake/armv7-m.cmake

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,23 @@ else() # gcc
3838
set(TOOLCHAIN_ARCH_FILE armv7-m_gcc)
3939
endif()
4040

41+
# LLVM Configuration
42+
if(CONFIG_ARCH_CORTEXM3)
43+
set(LLVM_ARCHTYPE thumbv7m)
44+
set(LLVM_CPUTYPE cortex-m3)
45+
else()
46+
set(LLVM_ARCHTYPE thumbv7em)
47+
if(CONFIG_ARCH_CORTEXM4)
48+
set(LLVM_CPUTYPE cortex-m4)
49+
elseif(CONFIG_ARCH_CORTEXM7)
50+
set(LLVM_CPUTYPE cortex-m7)
51+
endif()
52+
endif()
53+
54+
if(CONFIG_ARCH_FPU)
55+
set(LLVM_ABITYPE eabihf)
56+
else()
57+
set(LLVM_ABITYPE eabi)
58+
endif()
59+
4160
include(${TOOLCHAIN_ARCH_FILE})

arch/arm/src/cmake/armv8-m.cmake

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,31 @@
2222

2323
set(PLATFORM_FLAGS)
2424

25+
# LLVM Configuration
26+
if(CONFIG_ARCH_CORTEXM23)
27+
set(LLVM_ARCHTYPE thumbv8m.base)
28+
set(LLVM_CPUTYPE cortex-m23)
29+
elseif(CONFIG_ARCH_CORTEXM33)
30+
set(LLVM_ARCHTYPE thumbv8m.main)
31+
set(LLVM_CPUTYPE cortex-m33)
32+
elseif(CONFIG_ARCH_CORTEXM35P)
33+
set(LLVM_ARCHTYPE thumbv8m.main)
34+
set(LLVM_CPUTYPE cortex-m35p)
35+
elseif(CONFIG_ARCH_CORTEXM55)
36+
set(LLVM_ARCHTYPE thumbv8.1m.main)
37+
set(LLVM_CPUTYPE cortex-m55)
38+
elseif(CONFIG_ARCH_CORTEXM85)
39+
set(LLVM_ARCHTYPE thumbv8.1m.main)
40+
set(LLVM_CPUTYPE cortex-m85)
41+
endif()
42+
43+
# Set ABI type based on FPU configuration
44+
if(CONFIG_ARCH_FPU)
45+
set(LLVM_ABITYPE eabihf)
46+
else()
47+
set(LLVM_ABITYPE eabi)
48+
endif()
49+
2550
if(CONFIG_ARM_DSP)
2651
set(EXTCPUFLAGS +dsp)
2752
endif()

0 commit comments

Comments
 (0)