Skip to content

Commit

Permalink
[Xtensa] Initial porting compiler-rt library for
Browse files Browse the repository at this point in the history
 Xtensa.
  • Loading branch information
andreisfr committed Sep 28, 2023
1 parent 2a920d9 commit bc0d57e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions compiler-rt/cmake/Modules/CompilerRTUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ macro(detect_target_arch)
add_default_target_arch(sparc)
elseif(__WEBASSEMBLY32)
add_default_target_arch(wasm32)
elseif(__XTENSA)
add_default_target_arch(xtensa)
elseif(__WEBASSEMBLY64)
add_default_target_arch(wasm64)
elseif(__VE)
Expand Down
2 changes: 2 additions & 0 deletions compiler-rt/cmake/base-config-ix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ macro(test_targets)
test_target_arch(riscv64 "" "")
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "wasm32")
test_target_arch(wasm32 "" "--target=wasm32-unknown-unknown")
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "xtensa")
test_target_arch(xtensa "" "--target=xtensa")
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "wasm64")
test_target_arch(wasm64 "" "--target=wasm64-unknown-unknown")
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "ve")
Expand Down
3 changes: 2 additions & 1 deletion compiler-rt/cmake/builtin-config-ix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ set(SPARCV9 sparcv9)
set(WASM32 wasm32)
set(WASM64 wasm64)
set(VE ve)
set(XTENSA xtensa)

if(APPLE)
set(ARM64 arm64 arm64e)
Expand All @@ -68,7 +69,7 @@ set(ALL_BUILTIN_SUPPORTED_ARCH
${X86} ${X86_64} ${ARM32} ${ARM64} ${AVR}
${HEXAGON} ${MIPS32} ${MIPS64} ${PPC32} ${PPC64}
${RISCV32} ${RISCV64} ${SPARC} ${SPARCV9}
${WASM32} ${WASM64} ${VE} ${LOONGARCH64})
${WASM32} ${WASM64} ${VE} ${LOONGARCH64} ${XTENSA})

include(CompilerRTUtils)
include(CompilerRTDarwinUtils)
Expand Down
2 changes: 2 additions & 0 deletions compiler-rt/lib/builtins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,8 @@ set(riscv64_SOURCES
set(sparc_SOURCES ${GENERIC_SOURCES} ${GENERIC_TF_SOURCES})
set(sparcv9_SOURCES ${GENERIC_SOURCES} ${GENERIC_TF_SOURCES})

set(xtensa_SOURCES ${GENERIC_SOURCES} ${GENERIC_TF_SOURCES})

set(wasm32_SOURCES
${GENERIC_TF_SOURCES}
${GENERIC_SOURCES}
Expand Down
14 changes: 14 additions & 0 deletions compiler-rt/lib/builtins/crtbegin.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ __asm__(".pushsection .init,\"ax\",@progbits\n\t"
__asm__(".pushsection .init,\"ax\",@progbits\n\t"
"call __do_init\n\t"
".popsection");
#elif defined(__xtensa__)
__asm__(".pushsection .init.literal,\"ax\",@progbits\n\t"
".popsection\n\t"
".pushsection .init,\"ax\",@progbits\n\t"
"movi a8, __do_init\n\t"
"callx8 a8\n\t"
".popsection");
#else
#error "crtbegin without .init_fini array unimplemented for this architecture"
#endif // CRT_HAS_INITFINI_ARRAY
Expand Down Expand Up @@ -130,6 +137,13 @@ __asm__(".pushsection .fini,\"ax\",@progbits\n\t"
__asm__(".pushsection .fini,\"ax\",@progbits\n\t"
"call __do_fini\n\t"
".popsection");
#elif defined(__xtensa__)
__asm__(".pushsection .fini.literal,\"ax\",@progbits\n\t"
".popsection\n\t"
".pushsection .fini,\"ax\",@progbits\n\t"
"movi a8, __do_fini\n\t"
"callx8 a8\n\t"
".popsection");
#else
#error "crtbegin without .init_fini array unimplemented for this architecture"
#endif // CRT_HAS_INIT_FINI_ARRAY

0 comments on commit bc0d57e

Please sign in to comment.