arm: add ARM architecture profile detection

Add some logic to detect classic and M-profile cores, and make
this info available to the build system. All existing targets
are classic profile.

Change-Id: I07bfcd418bcaa6297b9bbf889fc189f167147428
This commit is contained in:
Aidan MacDonald 2024-11-14 12:06:27 +00:00 committed by Solomon Peachy
parent 9e79ebf78d
commit 7e8a818d95
2 changed files with 55 additions and 6 deletions

View file

@ -696,7 +696,13 @@ Lyre prototype 1 */
/* define for all cpus from ARM family */
#if ARCH == ARCH_ARM
#define CPU_ARM
#define ARM_ARCH ARCH_VERSION /* ARMv{4,5,6,7} */
#define ARM_ARCH ARCH_VERSION /* ARMv{4,5,6,7} */
#define ARM_PROFILE ARCH_PROFILE /* Classic, Microcontroller */
# if ARM_PROFILE == ARM_PROFILE_MICRO
# define CPU_ARM_MICRO
# elif ARM_PROFILE == ARM_PROFILE_CLASSIC
# define CPU_ARM_CLASSIC
# endif
#endif
#if ARCH == ARCH_MIPS

53
tools/configure vendored
View file

@ -4634,10 +4634,41 @@ if [ -z "$arch" ]; then
arch="arm"
# cpp defines like "#define __ARM_ARCH_4TE__ 1" (where we want to extract the 4)
arch_version="$(echo $cpp_defines | tr ' ' '\012' | grep __ARM_ARCH | sed -e 's,.*\([0-9]\).*,\1,' | grep -v __ARM_ARCH | head -1)"
arch_profile="$(echo "$cpp_defines" | grep 'define __ARM_ARCH_PROFILE' | sed -e 's,.* \([0-9]\+\)$,\1,')"
if test "$gccnum" -ge "800"; then
# GCC8+ can natively emit unified asm syntax
GCCOPTS="$GCCOPTS -masm-syntax-unified"
fi
case "$arch_profile" in
77)
arch_profile=micro
# We have a lot of assembly written for ARM32, which won't
# successfully assemble on a Thumb-only core due to missing
# IT blocks. The recommended practice for portable assembly
# is to add explicit IT blocks nowadays.
#
# This option instructs the assembler to add IT blocks
# automatically as needed, which allows the old assembly to
# compile unchanged (although it might be sub-optimal).
GCCOPTS="$GCCOPTS -Wa,-mimplicit-it=thumb"
# Disable this option -- it only makes sense for cores that
# support both ARM and Thumb instruction sets.
if [ "$ARG_ARM_THUMB" = "1" ]; then
echo "Warning: --thumb option has no effect on ARM M profile cores"
ARG_ARM_THUMB=0
fi
;;
*)
# On classic ARM we expect an empty string, so only warn if it's nonempty
if [ -n "$arch_profile" ]; then
echo "Warning: Cannot determine target ARM profile, assuming classic"
fi
arch_profile=classic
;;
esac
elif [ -n "$(echo $cpp_defines | grep -w __mips__)" ]; then
arch="mips"
arch_version="$(echo $cpp_defines | tr ' ' '\012' | grep _MIPS_ARCH_MIPS | sed -e 's,.*\([0-9][0-9]\).*,\1,' | grep -v _MIPS_ARCH_MIPS)"
@ -4651,7 +4682,11 @@ if [ -z "$arch" ]; then
fi
if [ "$arch" != "none" ]; then
if [ -n "$arch_version" ]; then
echo "Automatically selected arch: $arch (ver $arch_version)"
if [ -n "$arch_profile" ]; then
echo "Automatically selected arch: $arch (ver $arch_version, profile $arch_profile)"
else
echo "Automatically selected arch: $arch (ver $arch_version)"
fi
else
echo "Automatically selected arch: $arch"
fi
@ -4664,10 +4699,13 @@ else
fi
fi
arch="arch_$arch"
Darch="#define ARCH arch_$arch"
if [ -n "$arch_version" ]; then
Darch_version="#define ARCH_VERSION $arch_version"
fi
if [ -n "$arch_profile" ]; then
Darch_profile="#define ARCH_PROFILE $(echo ${arch}_PROFILE_${arch_profile} | tr [a-z] [A-Z])"
fi
if test -n "$ccache"; then
CC="$ccache $CC"
@ -4722,10 +4760,14 @@ cat > autoconf.h.new <<EOF
#define arch_amd64 6
#define ARCH_AMD64 6
#define ARM_PROFILE_CLASSIC 0 /* Classic ARM cores (<= ARMv6) */
#define ARM_PROFILE_MICRO 1 /* ARMv6/ARMv7+ M-profile cores */
/* Define target machine architecture */
#define ARCH ${arch}
/* Optionally define architecture version */
${Darch}
/* Optionally define architecture version and/or profile */
${Darch_version}
${Darch_profile}
/* Define endianess for the target or simulator platform */
#define ${defendian} 1
@ -4843,8 +4885,9 @@ export FLASHFILE=${flash}
export TARGET_ID=${target_id}
export TARGET=-D${target}
export SYSFONT=${sysfont}
export ARCH=${arch}
export ARCH=arch_${arch}
export ARCH_VERSION=${arch_version}
export ARCH_PROFILE=${arch_profile}
export CPU=${t_cpu}
export MANUFACTURER=${t_manufacturer}
export OBJDIR=${pwd}