From 49fa8770b0adce84246d5db3feec09db02eeeaee Mon Sep 17 00:00:00 2001 From: Seth Shelnutt Date: Mon, 16 Jul 2012 11:55:12 -0400 Subject: libFDK in libaac: Add conditional definition to switch arm asm for devices that don't support thumb2. Tested on heroc with armv6j. Change-Id: If93892e920097ac7bdfa3f15d2ad1ee6d04bdcc6 --- libFDK/include/arm/clz_arm.h | 10 +++++++++- libFDK/include/arm/cplx_mul.h | 19 ++++++++++++++++--- libFDK/include/arm/fixmadd_arm.h | 20 ++++++++++++++++---- libFDK/include/arm/fixmul_arm.h | 14 ++++++++++++-- libFDK/src/arm/qmf_arm.cpp | 33 +++++++++++++++++++++++++-------- 5 files changed, 78 insertions(+), 18 deletions(-) diff --git a/libFDK/include/arm/clz_arm.h b/libFDK/include/arm/clz_arm.h index b33b800..7b9d614 100644 --- a/libFDK/include/arm/clz_arm.h +++ b/libFDK/include/arm/clz_arm.h @@ -92,6 +92,14 @@ amm-info@iis.fraunhofer.de #if defined(__GNUC__) && defined(__ARM_ARCH_5TE__) /* cppp replaced: elif */ /* ARM gcc*/ +#if defined(__thumb__) && !defined(__thumb2__) +# define __SWITCH_TO_ARM \ + ".align\n" \ + ".arm\n" + +#else +# define __SWITCH_TO_ARM /* nothing */ +#endif #define FUNCTION_fixnormz_D #define FUNCTION_fixnorm_D @@ -99,7 +107,7 @@ amm-info@iis.fraunhofer.de inline INT fixnormz_D(LONG value) { INT result; - asm("clz %0, %1 ": "=r"(result) : "r"(value) ); + asm(__SWITCH_TO_ARM "clz %0, %1 ": "=r"(result) : "r"(value) ); return result; } diff --git a/libFDK/include/arm/cplx_mul.h b/libFDK/include/arm/cplx_mul.h index 2416f98..5d11e3d 100644 --- a/libFDK/include/arm/cplx_mul.h +++ b/libFDK/include/arm/cplx_mul.h @@ -97,6 +97,15 @@ amm-info@iis.fraunhofer.de //#define FUNCTION_cplxMult_32x16X2 #endif +#if defined(__thumb__) && !defined(__thumb2__) +# define __SWITCH_TO_ARM \ + ".align\n" \ + ".arm\n" + +#else +# define __SWITCH_TO_ARM /* nothing */ +#endif + #define FUNCTION_cplxMultDiv2_32x32X2 //#define FUNCTION_cplxMult_32x32X2 @@ -110,7 +119,8 @@ inline void cplxMultDiv2( FIXP_DBL *c_Re, LONG tmp1,tmp2; const LONG w = wpk.w; - asm("smulwt %0, %3, %4;\n" + asm(__SWITCH_TO_ARM + "smulwt %0, %3, %4;\n" "rsb %1,%0,#0;\n" "smlawb %0, %2, %4, %1;\n" "smulwt %1, %2, %4;\n" @@ -134,7 +144,8 @@ inline void cplxMultDiv2( FIXP_DBL *c_Re, { LONG tmp1, tmp2; - asm("smulwb %0, %3, %5;\n" /* %7 = -a_Im * b_Im */ + asm(__SWITCH_TO_ARM + "smulwb %0, %3, %5;\n" /* %7 = -a_Im * b_Im */ "rsb %1,%0,#0;\n" "smlawb %0, %2, %4, %1;\n" /* tmp1 = a_Re * b_Re - a_Im * b_Im */ "smulwb %1, %2, %5;\n" /* %7 = a_Re * b_Im */ @@ -158,7 +169,8 @@ inline void cplxMultAddDiv2( FIXP_DBL *c_Re, { LONG tmp1, tmp2; - asm("smulwb %0, %3, %5;\n" + asm(__SWITCH_TO_ARM + "smulwb %0, %3, %5;\n" "rsb %1,%0,#0;\n" "smlawb %0, %2, %4, %1;\n" "smulwb %1, %2, %5;\n" @@ -185,6 +197,7 @@ inline void cplxMultDiv2( FIXP_DBL *c_Re, #ifdef __ARM_ARCH_6__ asm( + __SWITCH_TO_ARM "smmul %0, %2, %4;\n" /* tmp1 = a_Re * b_Re */ "smmls %0, %3, %5, %0;\n" /* tmp1 -= a_Im * b_Im */ "smmul %1, %2, %5;\n" /* tmp2 = a_Re * b_Im */ diff --git a/libFDK/include/arm/fixmadd_arm.h b/libFDK/include/arm/fixmadd_arm.h index e12d211..cfa1f71 100644 --- a/libFDK/include/arm/fixmadd_arm.h +++ b/libFDK/include/arm/fixmadd_arm.h @@ -96,11 +96,20 @@ amm-info@iis.fraunhofer.de /* ARM GNU GCC */ #define FUNCTION_fixmadddiv2_DD + #if defined(__thumb__) && !defined(__thumb2__) + # define __SWITCH_TO_ARM \ + ".align\n" \ + ".arm\n" + + #else + # define __SWITCH_TO_ARM /* nothing */ + #endif #ifdef __ARM_ARCH_6__ inline FIXP_DBL fixmadddiv2_DD (FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b) { INT result; - asm ("smmla %0, %1, %2, %3;\n" + asm (__SWITCH_TO_ARM + "smmla %0, %1, %2, %3;\n" : "=r" (result) : "r" (a), "r" (b), "r"(x) ); return result ; @@ -108,7 +117,8 @@ amm-info@iis.fraunhofer.de #define FUNCTION_fixmsubdiv2_DD inline FIXP_DBL fixmsubdiv2_DD (FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b) { INT result; - asm ("smmls %0, %1, %2, %3;\n" + asm (__SWITCH_TO_ARM + "smmls %0, %1, %2, %3;\n" : "=r" (result) : "r" (a), "r" (b), "r"(x) ); return result ; @@ -116,7 +126,8 @@ amm-info@iis.fraunhofer.de #else /* __ARM_ARCH_6__ */ inline FIXP_DBL fixmadddiv2_DD (FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b) { INT discard, result = x; - asm ("smlal %0, %1, %2, %3;\n" + asm (__SWITCH_TO_ARM + "smlal %0, %1, %2, %3;\n" : "=r" (discard), "+r" (result) : "r" (a), "r" (b) ); return result ; @@ -129,7 +140,8 @@ amm-info@iis.fraunhofer.de inline FIXP_DBL fixmadddiv2_DS (FIXP_DBL x, const FIXP_DBL a, const FIXP_SGL b) { INT result; - asm("smlawb %0, %1, %2, %3 " + asm(__SWITCH_TO_ARM + "smlawb %0, %1, %2, %3 " : "=r" (result) : "r" (a), "r" (b), "r" (x) ); return result ; diff --git a/libFDK/include/arm/fixmul_arm.h b/libFDK/include/arm/fixmul_arm.h index d42d677..a0e77ca 100644 --- a/libFDK/include/arm/fixmul_arm.h +++ b/libFDK/include/arm/fixmul_arm.h @@ -93,6 +93,15 @@ amm-info@iis.fraunhofer.de #if defined(__GNUC__) && defined(__arm__) /* cppp replaced: elif */ /* ARM with GNU compiler */ +#if defined(__thumb__) && !defined(__thumb2__) +# define __SWITCH_TO_ARM \ + ".align\n" \ + ".arm\n" + +#else +# define __SWITCH_TO_ARM /* nothing */ +#endif + #define FUNCTION_fixmuldiv2_DD #define FUNCTION_fixmuldiv2BitExact_DD @@ -110,7 +119,7 @@ amm-info@iis.fraunhofer.de inline INT fixmuldiv2_DD (const INT a, const INT b) { INT result ; - __asm__ ("smmul %0, %1, %2" : "=r" (result) + __asm__ (__SWITCH_TO_ARM "smmul %0, %1, %2" : "=r" (result) : "r" (a), "r" (b)) ; return result ; } @@ -129,7 +138,8 @@ inline INT fixmuldiv2_DD (const INT a, const INT b) inline INT fixmuldiv2_SD (const SHORT a, const INT b) { INT result ; - __asm__ ("smulwb %0, %1, %2" + __asm__ (__SWITCH_TO_ARM + "smulwb %0, %1, %2" : "=r" (result) : "r" (b), "r" (a)) ; return result ; diff --git a/libFDK/src/arm/qmf_arm.cpp b/libFDK/src/arm/qmf_arm.cpp index 39795d7..5aedce7 100644 --- a/libFDK/src/arm/qmf_arm.cpp +++ b/libFDK/src/arm/qmf_arm.cpp @@ -119,6 +119,15 @@ qmfForwardModulationLP_odd( HANDLE_QMF_FILTER_BANK anaQmf, /*!< Handle of Qmf An #if defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_5TE__) +#if defined(__thumb__) && !defined(__thumb2__) +# define __SWITCH_TO_ARM \ + ".align\n" \ + ".arm\n" + +#else +# define __SWITCH_TO_ARM /* nothing */ +#endif + #if (SAMPLE_BITS == 16) #define FUNCTION_qmfAnaPrototypeFirSlot #endif @@ -130,7 +139,8 @@ qmfForwardModulationLP_odd( HANDLE_QMF_FILTER_BANK anaQmf, /*!< Handle of Qmf An inline INT SMULBB (const SHORT a, const LONG b) { INT result ; - __asm__ ("smulbb %0, %1, %2" + __asm__ (__SWITCH_TO_ARM + "smulbb %0, %1, %2" : "=r" (result) : "r" (a), "r" (b)) ; return result ; @@ -138,7 +148,8 @@ inline INT SMULBB (const SHORT a, const LONG b) inline INT SMULBT (const SHORT a, const LONG b) { INT result ; - __asm__ ("smulbt %0, %1, %2" + __asm__ (__SWITCH_TO_ARM + "smulbt %0, %1, %2" : "=r" (result) : "r" (a), "r" (b)) ; return result ; @@ -147,7 +158,8 @@ inline INT SMULBT (const SHORT a, const LONG b) inline INT SMLABB(const LONG accu, const SHORT a, const LONG b) { INT result ; - __asm__ ("smlabb %0, %1, %2,%3" + __asm__ (__SWITCH_TO_ARM + "smlabb %0, %1, %2,%3" : "=r" (result) : "r" (a), "r" (b), "r" (accu)) ; return result; @@ -155,7 +167,8 @@ inline INT SMLABB(const LONG accu, const SHORT a, const LONG b) inline INT SMLABT(const LONG accu, const SHORT a, const LONG b) { INT result ; - __asm__ ("smlabt %0, %1, %2,%3" + __asm__ (__SWITCH_TO_ARM + "smlabt %0, %1, %2,%3" : "=r" (result) : "r" (a), "r" (b), "r" (accu)) ; return result; @@ -424,7 +437,8 @@ void qmfAnaPrototypeFirSlot( FIXP_QMF *analysisBuffer, inline INT SMULWB (const LONG a, const LONG b) { INT result ; - __asm__ ("smulwb %0, %1, %2" + __asm__ (__SWITCH_TO_ARM + "smulwb %0, %1, %2" : "=r" (result) : "r" (a), "r" (b)) ; @@ -433,7 +447,8 @@ inline INT SMULWB (const LONG a, const LONG b) inline INT SMULWT (const LONG a, const LONG b) { INT result ; - __asm__ ("smulwt %0, %1, %2" + __asm__ (__SWITCH_TO_ARM + "smulwt %0, %1, %2" : "=r" (result) : "r" (a), "r" (b)) ; @@ -443,7 +458,8 @@ inline INT SMULWT (const LONG a, const LONG b) inline INT SMLAWB(const LONG accu, const LONG a, const LONG b) { INT result; - asm("smlawb %0, %1, %2, %3 " + asm(__SWITCH_TO_ARM + "smlawb %0, %1, %2, %3 " : "=r" (result) : "r" (a), "r" (b), "r" (accu) ); return result ; @@ -452,7 +468,8 @@ inline INT SMLAWB(const LONG accu, const LONG a, const LONG b) inline INT SMLAWT(const LONG accu, const LONG a, const LONG b) { INT result; - asm("smlawt %0, %1, %2, %3 " + asm(__SWITCH_TO_ARM + "smlawt %0, %1, %2, %3 " : "=r" (result) : "r" (a), "r" (b), "r" (accu) ); return result ; -- cgit v1.2.3