[compiler-rt][builtins] Support builtins for armv8m.base

This allows building the compiler builtins library for the Armv8-M
Baseline architecture. It can be built in the same way as other
baremetal targets using the appropriate '--target' flag
(e.g. --target=armv8m.base-eabi).

NOTE: As with the other Cortex-M targets, only the builtins library is
supported. There is no support for sanitizers, etc.

The armv8m.base architecture is a superset of armv6m, so adding it to
the cmake files using thumb1_SOURCES is almost enough for it to compile.
Minor changes are needed to divsi3 and udivsi3, because armv8m.base does
have support for div instructions but not mov with an immediate operand.

Reviewed By: MaskRay, peter.smith

Differential Revision: https://reviews.llvm.org/D143297
This commit is contained in:
Frank Dischner 2023-03-14 17:20:54 -07:00 committed by Fangrui Song
parent 4e99891e70
commit ef45c12f9e
4 changed files with 6 additions and 3 deletions

View File

@ -29,7 +29,7 @@ asm(\"cas w0, w1, [x2]\");
")
set(ARM64 aarch64)
set(ARM32 arm armhf armv4t armv5te armv6 armv6m armv7m armv7em armv7 armv7s armv7k armv8m.main armv8.1m.main)
set(ARM32 arm armhf armv4t armv5te armv6 armv6m armv7m armv7em armv7 armv7s armv7k armv8m.base armv8m.main armv8.1m.main)
set(AVR avr)
set(HEXAGON hexagon)
set(X86 i386)

View File

@ -605,6 +605,7 @@ set(arm64_32_SOURCES ${aarch64_SOURCES})
set(armv6m_SOURCES ${thumb1_SOURCES})
set(armv7m_SOURCES ${arm_SOURCES})
set(armv7em_SOURCES ${arm_SOURCES})
set(armv8m.base_SOURCES ${thumb1_SOURCES})
set(armv8m.main_SOURCES ${arm_SOURCES})
set(armv8.1m.main_SOURCES ${arm_SOURCES})

View File

@ -37,7 +37,8 @@ DEFINE_COMPILERRT_FUNCTION(__divsi3)
sdiv r0, r0, r1
bx lr
LOCAL_LABEL(divzero):
mov r0,#0
// Use movs for compatibility with v8-m.base.
movs r0,#0
bx lr
#else
ESTABLISH_FRAME

View File

@ -32,7 +32,8 @@ DEFINE_COMPILERRT_FUNCTION(__udivsi3)
bx lr
LOCAL_LABEL(divby0):
mov r0, #0
// Use movs for compatibility with v8-m.base.
movs r0, #0
# ifdef __ARM_EABI__
b __aeabi_idiv0
# else