arm: Profile/variation detection improvements

* Detection of 64-bit Arm v8-a
 * Proper detection of integer division support
   * always on v7-m, v8-a, v9-a, v8-m.main
   * sometimes on v7-a, v7-r, v8-r
   * never on v8-m.base v6-m, v6 and older "classic"
   * tl;dr: Rely on toolchain preprocessor definition

For the most part these additional variations won't acutally work
for native target builds, but sane -A detection is needed for
"local" builds now. -R detection is left out as it's not likely
to matter.

Change-Id: I8f6a52edc4d14490fc00e2f487406eca701eef02
This commit is contained in:
Solomon Peachy 2025-12-04 20:20:35 -05:00
parent 6d39bf5e48
commit afe128f4cc
4 changed files with 30 additions and 90 deletions

View file

@ -711,21 +711,18 @@ 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_PROFILE ARCH_PROFILE /* Classic, Microcontroller */
#define ARM_ARCH ARCH_VERSION /* ARMv{4,5,6,7,8,9} */
#define ARM_PROFILE ARCH_PROFILE /* Classic, Microcontroller, Application [,Realtime] */
# if ARM_PROFILE == ARM_PROFILE_MICRO
# define CPU_ARM_MICRO
# if (ARM_ARCH >= 7)
# define ARM_HAVE_HW_DIV
# endif
# elif ARM_PROFILE == ARM_PROFILE_CLASSIC
# define CPU_ARM_CLASSIC
# elif ARM_PROFILE == ARM_PROFILE_APPLICATION
# define CPU_ARM_APPLICATION
# if defined(__ARM_FEATURE_IDIV) // Some v7-a, all v8-a
# endif
#if defined(__ARM_FEATURE_IDIV)
# define ARM_HAVE_HW_DIV
# endif
# endif
#endif
# if (CONFIG_PLATFORM & PLATFORM_NATIVE) && !defined(ARM_HAVE_HW_DIV)
# define ARM_NEED_DIV0
# endif

View file

@ -40,8 +40,6 @@
# include "avr32/bswap.h"
#elif ARCH_BFIN
# include "bfin/bswap.h"
#elif ARCH_SH4
# include "sh4/bswap.h"
#elif ARCH_X86
# include "x86/bswap.h"
#endif

31
tools/configure vendored
View file

@ -4760,11 +4760,30 @@ if [ -z "$arch" ]; then
;;
*)
# 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
if [ -z "$arch_profile" ]; then
arch_profile=classic
else
echo "Error: Unsupported target ARM profile ($arch_profile)"
exit 1
fi
;;
esac
elif [ -n "$(echo $cpp_defines | grep -w __aarch64__)" ]; then
arch="arm64"
# cpp defines like "#define __ARM_ARCH_8A__ 1" (where we want to extract the 8)
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
65) # Cortex-A
arch_profile=application
;;
*)
echo "Error: Unsupported target AARCH64 profile ($arch_profile)"
exit 1
;;
esac
elif [ -n "$(echo $cpp_defines | grep -w __mips__)" ]; then
@ -4840,8 +4859,8 @@ cat > autoconf.h.new <<EOF
#define arch_none 0
#define ARCH_NONE 0
#define arch_sh 1
#define ARCH_SH 1
#define arch_arm64 1
#define ARCH_ARM64 1
#define arch_m68k 2
#define ARCH_M68K 2

View file

@ -1,74 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id:$
*
* Copyright (C) 2012 by Andrew Ryabinin
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef __BUILD_AUTOCONF_H
#define __BUILD_AUTOCONF_H
/* lower case names match the what's exported in the Makefile
* upper case name looks nicer in the code */
#define arch_none 0
#define ARCH_NONE 0
#define arch_sh 1
#define ARCH_SH 1
#define arch_m68k 2
#define ARCH_M68K 2
#define arch_arm 3
#define ARCH_ARM 3
#define arch_mips 4
#define ARCH_MIPS 4
#define arch_x86 5
#define ARCH_X86 5
#define arch_amd64 6
#define ARCH_AMD64 6
/* Define target machine architecture */
#define ARCH arch_arm
/* Optionally define architecture version */
#define ARCH_VERSION 5
/* Define endianess for the target or simulator platform */
#define ROCKBOX_LITTLE_ENDIAN 1
/* Define this if you build rockbox to support the logf logging and display */
#undef ROCKBOX_HAS_LOGF
/* Define this if you want logf to output to the serial port */
#undef LOGF_SERIAL
/* Define this to record a chart with timings for the stages of boot */
#undef DO_BOOTCHART
/* the threading backend we use */
#define ASSEMBLER_THREADS
/* root of Rockbox */
#define ROCKBOX_DIR "/.rockbox"
#define ROCKBOX_SHARE_PATH ""
#define ROCKBOX_BINARY_PATH ""
#define ROCKBOX_LIBRARY_PATH ""
#endif /* __BUILD_AUTOCONF_H */