opus: name the ARM inline-asm gates after the cores they cover

Upstream's OPUS_ARM_INLINE_ASM means any ARM with inline assembly, with
OPUS_ARM_INLINE_EDSP layered on top for ARMv5E.  config.h instead defines
exactly one of them per core, so the names read as broader than they are,
and code added ARM_ARCH tests beside them to pin the scope down.  Renamed
to OPUS_ARM_ASM_ARMV4_ONLY and OPUS_ARM_ASM_ARMV5E_AND_LATER throughout
celt and silk, upstream files included; README.rockbox records it for the
next libopus sync.

No code change: opus.elf disassembly and section sizes are identical
before and after on ARMv4 (e200v1), ARMv5E (Clip+) and ARMv6 (iPod Nano
4G).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Change-Id: I89932d348dedd76748a1bc7b3f2e7de1c5be49c8
This commit is contained in:
Michael Giacomelli 2026-09-23 20:45:02 -04:00 • committed by Solomon Peachy
parent d3893ead3a
commit c47b2e1be2
14 changed files with 28 additions and 23 deletions

View file

@ -13,6 +13,9 @@ Opus:
Celt:
* changed #if FIXED_POINT to #ifdef FIXED_POINT in bands.c
* changed #elif OPUS_ARM_INLINE_EDSP to #elif defined (OPUS_ARM_INLINE_EDSP)
* renamed OPUS_ARM_INLINE_ASM to OPUS_ARM_ASM_ARMV4_ONLY and
OPUS_ARM_INLINE_EDSP to OPUS_ARM_ASM_ARMV5E_AND_LATER throughout celt and
silk, since config.h defines exactly one of them per core
* add #define ABS(a)(((a) < 0) ? - (a) :(a)) to mathops.h
Opus-tools:

View file

@ -90,11 +90,11 @@
do {(res).r = ADD32_ovflw((res).r,(a).r); (res).i = SUB32_ovflw((res).i,(a).i); \
}while(0)
#if defined(OPUS_ARM_INLINE_ASM)
#if defined(OPUS_ARM_ASM_ARMV4_ONLY)
#include "arm/kiss_fft_armv4.h"
#endif
#if defined(OPUS_ARM_INLINE_EDSP)
#if defined(OPUS_ARM_ASM_ARMV5E_AND_LATER)
#include "arm/kiss_fft_armv5e.h"
#endif
#if defined(OPUS_CF_INLINE_ASM)

View file

@ -173,9 +173,9 @@ static OPUS_INLINE opus_int16 SAT16(opus_int32 x) {
#ifdef OPUS_ARM_PRESUME_AARCH64_NEON_INTR
#include "arm/fixed_arm64.h"
#elif defined (OPUS_ARM_INLINE_EDSP)
#elif defined (OPUS_ARM_ASM_ARMV5E_AND_LATER)
#include "arm/fixed_armv5e.h"
#elif defined (OPUS_ARM_INLINE_ASM)
#elif defined (OPUS_ARM_ASM_ARMV4_ONLY)
#include "arm/fixed_armv4.h"
#elif defined (BFIN_ASM)
#include "fixed_bfin.h"

View file

@ -35,14 +35,14 @@
#if defined(FIXED_POINT) && !defined(OPUS_ARM_NO_BANDS_ASM)
# if defined(OPUS_ARM_INLINE_ASM) && (ARM_ARCH == 4)
# if defined(OPUS_ARM_ASM_ARMV4_ONLY) && (ARM_ARCH == 4)
# define OVERRIDE_DENORM_BAND
void denorm_band_armv4(celt_sig *f, const celt_norm *x, int n, int g,
int shift);
# define DENORM_BAND denorm_band_armv4
# elif defined(OPUS_ARM_INLINE_EDSP) && (ARM_ARCH >= 5)
# elif defined(OPUS_ARM_ASM_ARMV5E_AND_LATER) && (ARM_ARCH >= 5)
# define OVERRIDE_DENORM_BAND
void denorm_band_armv5e(celt_sig *f, const celt_norm *x, int n, int g,

View file

@ -38,7 +38,7 @@
#if defined(FIXED_POINT) && !defined(CUSTOM_MODES) \
&& !defined(OPUS_ARM_NO_COMB_ASM)
# if defined(OPUS_ARM_INLINE_ASM) && (ARM_ARCH == 4)
# if defined(OPUS_ARM_ASM_ARMV4_ONLY) && (ARM_ARCH == 4)
# define OVERRIDE_COMB_FILTER_CONST
void comb_filter_const_armv4(opus_val32 *y, opus_val32 *x, int T, int N,
@ -61,7 +61,7 @@ void deemph_stereo_armv4(celt_sig *x0, celt_sig *x1, opus_val16 *pcm, int N,
# define deemphasis_stereo_simple(in, pcm, N, coef0, mem) \
deemph_stereo_armv4((in)[0], (in)[1], (pcm), (N), (coef0), (mem))
# elif defined(OPUS_ARM_INLINE_EDSP) && (ARM_ARCH >= 5)
# elif defined(OPUS_ARM_ASM_ARMV5E_AND_LATER) && (ARM_ARCH >= 5)
# define OVERRIDE_COMB_FILTER_CONST
void comb_filter_const_armv5e(opus_val32 *y, opus_val32 *x, int T, int N,

View file

@ -34,7 +34,7 @@
Building with OPUS_ARM_NO_MDCT_ASM selects the C loops instead, which is
how the two are compared. */
#if defined(OPUS_ARM_INLINE_ASM) && defined(FIXED_POINT) \
#if defined(OPUS_ARM_ASM_ARMV4_ONLY) && defined(FIXED_POINT) \
&& !defined(OPUS_ARM_NO_MDCT_ASM)
#define OVERRIDE_MDCT_PREROT

View file

@ -38,7 +38,7 @@
Building with OPUS_ARM_NO_MDCT_ASM selects the C loops instead, which is
how the two are compared. */
#if defined(OPUS_ARM_INLINE_EDSP) && defined(FIXED_POINT) \
#if defined(OPUS_ARM_ASM_ARMV5E_AND_LATER) && defined(FIXED_POINT) \
&& (ARM_ARCH >= 5) && !defined(OPUS_ARM_NO_MDCT_ASM)
#define OVERRIDE_MDCT_PREROT

View file

@ -11,13 +11,13 @@
#if defined(FIXED_POINT) && defined(OPUS_PFA)
#if defined(OPUS_ARM_INLINE_EDSP)
#if defined(OPUS_ARM_ASM_ARMV5E_AND_LATER)
#define OVERRIDE_PFA_FFT15
void pfa_fft15_armv5e(const kiss_fft_cpx *in, kiss_fft_cpx *out, int ostride);
#define PFA_FFT15(in, out, ostride) pfa_fft15_armv5e(in, out, ostride)
#elif defined(OPUS_ARM_INLINE_ASM)
#elif defined(OPUS_ARM_ASM_ARMV4_ONLY)
#define OVERRIDE_PFA_FFT15
void pfa_fft15_armv4(const kiss_fft_cpx *in, kiss_fft_cpx *out, int ostride);

View file

@ -74,7 +74,7 @@ extern void (*const DUAL_INNER_PROD_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *x,
5.5 after. ARMv4 is deliberately left alone: without the packed
multiplies the extraction would cost exactly what the saved loads buy.
Escape hatch OPUS_ARM_NO_PITCH_ASM. */
# if defined(OPUS_ARM_INLINE_EDSP) && defined(FIXED_POINT) \
# if defined(OPUS_ARM_ASM_ARMV5E_AND_LATER) && defined(FIXED_POINT) \
&& !defined(OVERRIDE_DUAL_INNER_PROD) && !defined(OPUS_ARM_NO_PITCH_ASM)
void dual_inner_prod_armv5e(const opus_val16 *x, const opus_val16 *y01,
const opus_val16 *y02, int N, opus_val32 *xy1, opus_val32 *xy2);

View file

@ -36,7 +36,7 @@
Shares OPUS_ARM_NO_BANDS_ASM with arm/bands_arm.h as the escape hatch. */
#if defined(FIXED_POINT) && !defined(OPUS_ARM_NO_BANDS_ASM) \
&& defined(OPUS_ARM_INLINE_EDSP) && (ARM_ARCH >= 5)
&& defined(OPUS_ARM_ASM_ARMV5E_AND_LATER) && (ARM_ARCH >= 5)
#define OVERRIDE_vq_exp_rotation1
void exp_rotation1_armv5e(celt_norm *X, int len, int stride, opus_val16 c,
@ -52,7 +52,7 @@ void normres_scale_armv5e(celt_norm *X, const int *iy, int N, int g,
#define NORMRES_SCALE normres_scale_armv5e
#elif defined(FIXED_POINT) && !defined(OPUS_ARM_NO_BANDS_ASM) \
&& defined(OPUS_ARM_INLINE_ASM) && (ARM_ARCH == 4)
&& defined(OPUS_ARM_ASM_ARMV4_ONLY) && (ARM_ARCH == 4)
#define OVERRIDE_vq_exp_rotation1
void exp_rotation1_armv4(celt_norm *X, int len, int stride, opus_val16 c,

View file

@ -64,7 +64,7 @@ static __inline int ec_bsr(unsigned long _x){
# include "dsplib.h"
# define EC_CLZ0 (31)
# define EC_CLZ(_x) (_lnorm(_x))
#elif defined(OPUS_ARM_INLINE_ASM) && !defined(OPUS_ARM_NO_ILOG_INLINE)
#elif defined(OPUS_ARM_ASM_ARMV4_ONLY) && !defined(OPUS_ARM_NO_ILOG_INLINE)
/*ARMv4 has no CLZ instruction, so __builtin_clz compiles to a call to
libgcc's __clzsi2. Leave EC_CLZ undefined and inline EC_ILOG below.*/
#elif __GNUC_PREREQ(3,4)
@ -83,7 +83,7 @@ static __inline int ec_bsr(unsigned long _x){
The majority of the time we can never pass it zero.
When we need to, it can be special cased.*/
# define EC_ILOG(_x) (EC_CLZ0-EC_CLZ(_x))
#elif defined(OPUS_ARM_INLINE_ASM) && !defined(OPUS_ARM_NO_ILOG_INLINE)
#elif defined(OPUS_ARM_ASM_ARMV4_ONLY) && !defined(OPUS_ARM_NO_ILOG_INLINE)
/*Fifteen branchless instructions, no memory access. The libgcc call it
replaces costs about half again once the call, its table load and the
caller's register saves are counted. Compares against 0x10000, 0x100 and

View file

@ -78,10 +78,12 @@
#if defined(CPU_ARM)
#define OPUS_ARM_ASM
/* Upstream's OPUS_ARM_INLINE_ASM and OPUS_ARM_INLINE_EDSP, renamed: upstream
layers EDSP on top of ASM, but here exactly one is defined per core. */
#if ARM_ARCH == 4
#define OPUS_ARM_INLINE_ASM
#define OPUS_ARM_ASM_ARMV4_ONLY
#elif ARM_ARCH > 4
#define OPUS_ARM_INLINE_EDSP
#define OPUS_ARM_ASM_ARMV5E_AND_LATER
#if (ARCH_PROFILE == ARM_PROFILE_MICRO)
#define OPUS_ARM_NO_FFT_ASM
#define OPUS_ARM_NO_MDCT_ASM

View file

@ -621,11 +621,11 @@ static OPUS_INLINE opus_int64 silk_max_64(opus_int64 a, opus_int64 b)
#include "MacroCount.h"
#include "MacroDebug.h"
#ifdef OPUS_ARM_INLINE_ASM
#ifdef OPUS_ARM_ASM_ARMV4_ONLY
#include "arm/SigProc_FIX_armv4.h"
#endif
#ifdef OPUS_ARM_INLINE_EDSP
#ifdef OPUS_ARM_ASM_ARMV5E_AND_LATER
#include "arm/SigProc_FIX_armv5e.h"
#endif

View file

@ -135,11 +135,11 @@ static OPUS_INLINE opus_int32 silk_CLZ32(opus_int32 in32)
(*((Matrix_base_adr) + ((row)+(M)*(column))))
#endif
#ifdef OPUS_ARM_INLINE_ASM
#ifdef OPUS_ARM_ASM_ARMV4_ONLY
#include "arm/macros_armv4.h"
#endif
#ifdef OPUS_ARM_INLINE_EDSP
#ifdef OPUS_ARM_ASM_ARMV5E_AND_LATER
#include "arm/macros_armv5e.h"
#endif