2008-10-03 08:54:34 +00:00
|
|
|
/*
|
|
|
|
|
|
|
|
libdemac - A Monkey's Audio decoder
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
|
|
|
|
Copyright (C) Dave Chapman 2007
|
|
|
|
|
|
|
|
ARMv6 vector math copyright (C) 2008 Jens Arnold
|
|
|
|
|
|
|
|
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 program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
|
|
|
|
|
2010-03-03 20:52:02 +00:00
|
|
|
*/
|
2008-10-03 08:54:34 +00:00
|
|
|
|
2010-02-08 21:59:24 +00:00
|
|
|
#define FUSED_VECTOR_MATH
|
|
|
|
|
|
|
|
#if ORDER > 16
|
2010-03-03 20:52:02 +00:00
|
|
|
#define REPEAT_BLOCK(x) x x x
|
2010-02-08 21:59:24 +00:00
|
|
|
#else
|
2010-03-03 20:52:02 +00:00
|
|
|
#define REPEAT_BLOCK(x) x
|
2010-02-08 21:59:24 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Calculate scalarproduct, then add a 2nd vector (fused for performance)
|
|
|
|
* This version fetches data as 32 bit words, and *requires* v1 to be
|
|
|
|
* 32 bit aligned. It also requires that f2 and s2 are either both 32 bit
|
|
|
|
* aligned or both unaligned. If either condition isn't met, it will either
|
|
|
|
* result in a data abort or incorrect results. */
|
|
|
|
static inline int32_t vector_sp_add(int16_t* v1, int16_t* f2, int16_t* s2)
|
2008-10-03 08:54:34 +00:00
|
|
|
{
|
2010-02-08 21:59:24 +00:00
|
|
|
int res;
|
2008-11-19 21:31:33 +00:00
|
|
|
#if ORDER > 32
|
|
|
|
int cnt = ORDER>>5;
|
|
|
|
#endif
|
|
|
|
|
2010-02-08 21:59:24 +00:00
|
|
|
asm volatile (
|
|
|
|
#if ORDER > 32
|
|
|
|
"mov %[res], #0 \n"
|
|
|
|
#endif
|
|
|
|
"tst %[f2], #2 \n"
|
|
|
|
"beq 20f \n"
|
|
|
|
|
|
|
|
"10: \n"
|
|
|
|
"ldrh r3, [%[f2]], #2 \n"
|
|
|
|
"ldrh r6, [%[s2]], #2 \n"
|
|
|
|
"ldmia %[f2]!, {r2,r4} \n"
|
|
|
|
"mov r3, r3, lsl #16 \n"
|
|
|
|
"mov r6, r6, lsl #16 \n"
|
|
|
|
|
|
|
|
"1: \n"
|
|
|
|
"ldmia %[s2]!, {r5,r7} \n"
|
|
|
|
"pkhtb r3, r3, r2 \n"
|
|
|
|
"pkhtb r2, r2, r4 \n"
|
|
|
|
"ldrd r0, [%[v1]] \n"
|
|
|
|
"mov r5, r5, ror #16 \n"
|
|
|
|
"pkhtb r6, r5, r6, asr #16 \n"
|
|
|
|
"pkhbt r5, r5, r7, lsl #16 \n"
|
|
|
|
#if ORDER > 32
|
|
|
|
"smladx %[res], r0, r3, %[res] \n"
|
2008-11-19 21:31:33 +00:00
|
|
|
#else
|
2010-02-08 21:59:24 +00:00
|
|
|
"smuadx %[res], r0, r3 \n"
|
2008-10-03 08:54:34 +00:00
|
|
|
#endif
|
2010-02-08 21:59:24 +00:00
|
|
|
"smladx %[res], r1, r2, %[res] \n"
|
|
|
|
"ldmia %[f2]!, {r2,r3} \n"
|
|
|
|
"sadd16 r0, r0, r6 \n"
|
|
|
|
"sadd16 r1, r1, r5 \n"
|
|
|
|
"strd r0, [%[v1]], #8 \n"
|
|
|
|
|
2010-03-03 20:52:02 +00:00
|
|
|
REPEAT_BLOCK(
|
2010-02-08 21:59:24 +00:00
|
|
|
"ldmia %[s2]!, {r5,r6} \n"
|
|
|
|
"pkhtb r4, r4, r2 \n"
|
|
|
|
"pkhtb r2, r2, r3 \n"
|
|
|
|
"ldrd r0, [%[v1]] \n"
|
|
|
|
"mov r5, r5, ror #16 \n"
|
|
|
|
"pkhtb r7, r5, r7, asr #16 \n"
|
|
|
|
"pkhbt r5, r5, r6, lsl #16 \n"
|
|
|
|
"smladx %[res], r0, r4, %[res] \n"
|
|
|
|
"smladx %[res], r1, r2, %[res] \n"
|
|
|
|
"ldmia %[f2]!, {r2,r4} \n"
|
|
|
|
"sadd16 r0, r0, r7 \n"
|
|
|
|
"sadd16 r1, r1, r5 \n"
|
|
|
|
"strd r0, [%[v1]], #8 \n"
|
|
|
|
"ldmia %[s2]!, {r5,r7} \n"
|
|
|
|
"pkhtb r3, r3, r2 \n"
|
|
|
|
"pkhtb r2, r2, r4 \n"
|
|
|
|
"ldrd r0, [%[v1]] \n"
|
|
|
|
"mov r5, r5, ror #16 \n"
|
|
|
|
"pkhtb r6, r5, r6, asr #16 \n"
|
|
|
|
"pkhbt r5, r5, r7, lsl #16 \n"
|
|
|
|
"smladx %[res], r0, r3, %[res] \n"
|
|
|
|
"smladx %[res], r1, r2, %[res] \n"
|
|
|
|
"ldmia %[f2]!, {r2,r3} \n"
|
|
|
|
"sadd16 r0, r0, r6 \n"
|
|
|
|
"sadd16 r1, r1, r5 \n"
|
|
|
|
"strd r0, [%[v1]], #8 \n"
|
2010-03-03 20:52:02 +00:00
|
|
|
)
|
2010-02-08 21:59:24 +00:00
|
|
|
|
|
|
|
"ldmia %[s2]!, {r5,r6} \n"
|
|
|
|
"pkhtb r4, r4, r2 \n"
|
|
|
|
"pkhtb r2, r2, r3 \n"
|
|
|
|
"ldrd r0, [%[v1]] \n"
|
|
|
|
"mov r5, r5, ror #16 \n"
|
|
|
|
"pkhtb r7, r5, r7, asr #16 \n"
|
|
|
|
"pkhbt r5, r5, r6, lsl #16 \n"
|
|
|
|
"smladx %[res], r0, r4, %[res] \n"
|
|
|
|
"smladx %[res], r1, r2, %[res] \n"
|
|
|
|
#if ORDER > 32
|
|
|
|
"subs %[cnt], %[cnt], #1 \n"
|
|
|
|
"ldmneia %[f2]!, {r2,r4} \n"
|
|
|
|
"sadd16 r0, r0, r7 \n"
|
|
|
|
"sadd16 r1, r1, r5 \n"
|
|
|
|
"strd r0, [%[v1]], #8 \n"
|
|
|
|
"bne 1b \n"
|
|
|
|
#else
|
|
|
|
"sadd16 r0, r0, r7 \n"
|
|
|
|
"sadd16 r1, r1, r5 \n"
|
|
|
|
"strd r0, [%[v1]], #8 \n"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
"b 99f \n"
|
|
|
|
|
|
|
|
"20: \n"
|
|
|
|
"ldrd r4, [%[f2]], #8 \n"
|
|
|
|
"ldrd r0, [%[v1]] \n"
|
2008-10-03 08:54:34 +00:00
|
|
|
|
2008-11-19 21:31:33 +00:00
|
|
|
#if ORDER > 32
|
2010-02-08 21:59:24 +00:00
|
|
|
"1: \n"
|
|
|
|
"smlad %[res], r0, r4, %[res] \n"
|
|
|
|
#else
|
|
|
|
"smuad %[res], r0, r4 \n"
|
2008-10-03 08:54:34 +00:00
|
|
|
#endif
|
2010-02-08 21:59:24 +00:00
|
|
|
"ldrd r6, [%[s2]], #8 \n"
|
|
|
|
"smlad %[res], r1, r5, %[res] \n"
|
|
|
|
"ldrd r4, [%[f2]], #8 \n"
|
|
|
|
"ldrd r2, [%[v1], #8] \n"
|
|
|
|
"sadd16 r0, r0, r6 \n"
|
|
|
|
"sadd16 r1, r1, r7 \n"
|
|
|
|
"strd r0, [%[v1]], #8 \n"
|
|
|
|
|
2010-03-03 20:52:02 +00:00
|
|
|
REPEAT_BLOCK(
|
2010-02-08 21:59:24 +00:00
|
|
|
"smlad %[res], r2, r4, %[res] \n"
|
|
|
|
"ldrd r6, [%[s2]], #8 \n"
|
|
|
|
"smlad %[res], r3, r5, %[res] \n"
|
|
|
|
"ldrd r4, [%[f2]], #8 \n"
|
|
|
|
"ldrd r0, [%[v1], #8] \n"
|
|
|
|
"sadd16 r2, r2, r6 \n"
|
|
|
|
"sadd16 r3, r3, r7 \n"
|
|
|
|
"strd r2, [%[v1]], #8 \n"
|
|
|
|
"smlad %[res], r0, r4, %[res] \n"
|
|
|
|
"ldrd r6, [%[s2]], #8 \n"
|
|
|
|
"smlad %[res], r1, r5, %[res] \n"
|
|
|
|
"ldrd r4, [%[f2]], #8 \n"
|
|
|
|
"ldrd r2, [%[v1], #8] \n"
|
|
|
|
"sadd16 r0, r0, r6 \n"
|
|
|
|
"sadd16 r1, r1, r7 \n"
|
|
|
|
"strd r0, [%[v1]], #8 \n"
|
2010-03-03 20:52:02 +00:00
|
|
|
)
|
2010-02-08 21:59:24 +00:00
|
|
|
|
|
|
|
"smlad %[res], r2, r4, %[res] \n"
|
|
|
|
"ldrd r6, [%[s2]], #8 \n"
|
|
|
|
"smlad %[res], r3, r5, %[res] \n"
|
2008-11-19 21:31:33 +00:00
|
|
|
#if ORDER > 32
|
2010-02-08 21:59:24 +00:00
|
|
|
"subs %[cnt], %[cnt], #1 \n"
|
|
|
|
"ldrned r4, [%[f2]], #8 \n"
|
|
|
|
"ldrned r0, [%[v1], #8] \n"
|
|
|
|
"sadd16 r2, r2, r6 \n"
|
|
|
|
"sadd16 r3, r3, r7 \n"
|
|
|
|
"strd r2, [%[v1]], #8 \n"
|
|
|
|
"bne 1b \n"
|
|
|
|
#else
|
|
|
|
"sadd16 r2, r2, r6 \n"
|
|
|
|
"sadd16 r3, r3, r7 \n"
|
|
|
|
"strd r2, [%[v1]], #8 \n"
|
2008-10-03 08:54:34 +00:00
|
|
|
#endif
|
|
|
|
|
2010-02-08 21:59:24 +00:00
|
|
|
"99: \n"
|
2008-10-03 08:54:34 +00:00
|
|
|
: /* outputs */
|
2008-11-19 21:31:33 +00:00
|
|
|
#if ORDER > 32
|
2008-10-03 08:54:34 +00:00
|
|
|
[cnt]"+r"(cnt),
|
|
|
|
#endif
|
|
|
|
[v1] "+r"(v1),
|
2010-02-08 21:59:24 +00:00
|
|
|
[f2] "+r"(f2),
|
|
|
|
[s2] "+r"(s2),
|
|
|
|
[res]"=r"(res)
|
2008-10-03 08:54:34 +00:00
|
|
|
: /* inputs */
|
|
|
|
: /* clobbers */
|
|
|
|
"r0", "r1", "r2", "r3", "r4",
|
2010-05-29 15:00:10 +00:00
|
|
|
"r5", "r6", "r7", "cc", "memory"
|
2008-10-03 08:54:34 +00:00
|
|
|
);
|
2010-02-08 21:59:24 +00:00
|
|
|
return res;
|
2008-10-03 08:54:34 +00:00
|
|
|
}
|
|
|
|
|
2010-02-08 21:59:24 +00:00
|
|
|
/* Calculate scalarproduct, then subtract a 2nd vector (fused for performance)
|
|
|
|
* This version fetches data as 32 bit words, and *requires* v1 to be
|
|
|
|
* 32 bit aligned. It also requires that f2 and s2 are either both 32 bit
|
|
|
|
* aligned or both unaligned. If either condition isn't met, it will either
|
|
|
|
* result in a data abort or incorrect results. */
|
|
|
|
static inline int32_t vector_sp_sub(int16_t* v1, int16_t* f2, int16_t* s2)
|
2008-10-03 08:54:34 +00:00
|
|
|
{
|
2010-02-08 21:59:24 +00:00
|
|
|
int res;
|
2008-11-19 21:31:33 +00:00
|
|
|
#if ORDER > 32
|
|
|
|
int cnt = ORDER>>5;
|
2008-10-03 08:54:34 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
asm volatile (
|
2008-11-19 21:31:33 +00:00
|
|
|
#if ORDER > 32
|
2010-02-08 21:59:24 +00:00
|
|
|
"mov %[res], #0 \n"
|
|
|
|
#endif
|
|
|
|
"tst %[f2], #2 \n"
|
|
|
|
"beq 20f \n"
|
|
|
|
|
|
|
|
"10: \n"
|
|
|
|
"ldrh r3, [%[f2]], #2 \n"
|
|
|
|
"ldrh r6, [%[s2]], #2 \n"
|
|
|
|
"ldmia %[f2]!, {r2,r4} \n"
|
|
|
|
"mov r3, r3, lsl #16 \n"
|
|
|
|
"mov r6, r6, lsl #16 \n"
|
|
|
|
|
|
|
|
"1: \n"
|
|
|
|
"ldmia %[s2]!, {r5,r7} \n"
|
|
|
|
"pkhtb r3, r3, r2 \n"
|
|
|
|
"pkhtb r2, r2, r4 \n"
|
|
|
|
"ldrd r0, [%[v1]] \n"
|
|
|
|
"mov r5, r5, ror #16 \n"
|
|
|
|
"pkhtb r6, r5, r6, asr #16 \n"
|
|
|
|
"pkhbt r5, r5, r7, lsl #16 \n"
|
|
|
|
#if ORDER > 32
|
|
|
|
"smladx %[res], r0, r3, %[res] \n"
|
|
|
|
#else
|
|
|
|
"smuadx %[res], r0, r3 \n"
|
|
|
|
#endif
|
|
|
|
"smladx %[res], r1, r2, %[res] \n"
|
|
|
|
"ldmia %[f2]!, {r2,r3} \n"
|
|
|
|
"ssub16 r0, r0, r6 \n"
|
|
|
|
"ssub16 r1, r1, r5 \n"
|
|
|
|
"strd r0, [%[v1]], #8 \n"
|
|
|
|
|
2010-03-03 20:52:02 +00:00
|
|
|
REPEAT_BLOCK(
|
2010-02-08 21:59:24 +00:00
|
|
|
"ldmia %[s2]!, {r5,r6} \n"
|
|
|
|
"pkhtb r4, r4, r2 \n"
|
|
|
|
"pkhtb r2, r2, r3 \n"
|
|
|
|
"ldrd r0, [%[v1]] \n"
|
|
|
|
"mov r5, r5, ror #16 \n"
|
|
|
|
"pkhtb r7, r5, r7, asr #16 \n"
|
|
|
|
"pkhbt r5, r5, r6, lsl #16 \n"
|
|
|
|
"smladx %[res], r0, r4, %[res] \n"
|
|
|
|
"smladx %[res], r1, r2, %[res] \n"
|
|
|
|
"ldmia %[f2]!, {r2,r4} \n"
|
|
|
|
"ssub16 r0, r0, r7 \n"
|
|
|
|
"ssub16 r1, r1, r5 \n"
|
|
|
|
"strd r0, [%[v1]], #8 \n"
|
|
|
|
"ldmia %[s2]!, {r5,r7} \n"
|
|
|
|
"pkhtb r3, r3, r2 \n"
|
|
|
|
"pkhtb r2, r2, r4 \n"
|
|
|
|
"ldrd r0, [%[v1]] \n"
|
|
|
|
"mov r5, r5, ror #16 \n"
|
|
|
|
"pkhtb r6, r5, r6, asr #16 \n"
|
|
|
|
"pkhbt r5, r5, r7, lsl #16 \n"
|
|
|
|
"smladx %[res], r0, r3, %[res] \n"
|
|
|
|
"smladx %[res], r1, r2, %[res] \n"
|
|
|
|
"ldmia %[f2]!, {r2,r3} \n"
|
|
|
|
"ssub16 r0, r0, r6 \n"
|
|
|
|
"ssub16 r1, r1, r5 \n"
|
|
|
|
"strd r0, [%[v1]], #8 \n"
|
2010-03-03 20:52:02 +00:00
|
|
|
)
|
2010-02-08 21:59:24 +00:00
|
|
|
|
|
|
|
"ldmia %[s2]!, {r5,r6} \n"
|
|
|
|
"pkhtb r4, r4, r2 \n"
|
|
|
|
"pkhtb r2, r2, r3 \n"
|
|
|
|
"ldrd r0, [%[v1]] \n"
|
|
|
|
"mov r5, r5, ror #16 \n"
|
|
|
|
"pkhtb r7, r5, r7, asr #16 \n"
|
|
|
|
"pkhbt r5, r5, r6, lsl #16 \n"
|
|
|
|
"smladx %[res], r0, r4, %[res] \n"
|
|
|
|
"smladx %[res], r1, r2, %[res] \n"
|
|
|
|
#if ORDER > 32
|
|
|
|
"subs %[cnt], %[cnt], #1 \n"
|
|
|
|
"ldmneia %[f2]!, {r2,r4} \n"
|
|
|
|
"ssub16 r0, r0, r7 \n"
|
|
|
|
"ssub16 r1, r1, r5 \n"
|
|
|
|
"strd r0, [%[v1]], #8 \n"
|
|
|
|
"bne 1b \n"
|
|
|
|
#else
|
|
|
|
"ssub16 r0, r0, r7 \n"
|
|
|
|
"ssub16 r1, r1, r5 \n"
|
|
|
|
"strd r0, [%[v1]], #8 \n"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
"b 99f \n"
|
|
|
|
|
|
|
|
"20: \n"
|
|
|
|
"ldrd r4, [%[f2]], #8 \n"
|
|
|
|
"ldrd r0, [%[v1]] \n"
|
|
|
|
|
|
|
|
#if ORDER > 32
|
|
|
|
"1: \n"
|
|
|
|
"smlad %[res], r0, r4, %[res] \n"
|
|
|
|
#else
|
|
|
|
"smuad %[res], r0, r4 \n"
|
2008-10-03 08:54:34 +00:00
|
|
|
#endif
|
2010-02-08 21:59:24 +00:00
|
|
|
"ldrd r6, [%[s2]], #8 \n"
|
|
|
|
"smlad %[res], r1, r5, %[res] \n"
|
|
|
|
"ldrd r4, [%[f2]], #8 \n"
|
|
|
|
"ldrd r2, [%[v1], #8] \n"
|
|
|
|
"ssub16 r0, r0, r6 \n"
|
|
|
|
"ssub16 r1, r1, r7 \n"
|
|
|
|
"strd r0, [%[v1]], #8 \n"
|
|
|
|
|
2010-03-03 20:52:02 +00:00
|
|
|
REPEAT_BLOCK(
|
2010-02-08 21:59:24 +00:00
|
|
|
"smlad %[res], r2, r4, %[res] \n"
|
|
|
|
"ldrd r6, [%[s2]], #8 \n"
|
|
|
|
"smlad %[res], r3, r5, %[res] \n"
|
|
|
|
"ldrd r4, [%[f2]], #8 \n"
|
|
|
|
"ldrd r0, [%[v1], #8] \n"
|
|
|
|
"ssub16 r2, r2, r6 \n"
|
|
|
|
"ssub16 r3, r3, r7 \n"
|
|
|
|
"strd r2, [%[v1]], #8 \n"
|
|
|
|
"smlad %[res], r0, r4, %[res] \n"
|
|
|
|
"ldrd r6, [%[s2]], #8 \n"
|
|
|
|
"smlad %[res], r1, r5, %[res] \n"
|
|
|
|
"ldrd r4, [%[f2]], #8 \n"
|
|
|
|
"ldrd r2, [%[v1], #8] \n"
|
|
|
|
"ssub16 r0, r0, r6 \n"
|
|
|
|
"ssub16 r1, r1, r7 \n"
|
|
|
|
"strd r0, [%[v1]], #8 \n"
|
2010-03-03 20:52:02 +00:00
|
|
|
)
|
2010-02-08 21:59:24 +00:00
|
|
|
|
|
|
|
"smlad %[res], r2, r4, %[res] \n"
|
|
|
|
"ldrd r6, [%[s2]], #8 \n"
|
|
|
|
"smlad %[res], r3, r5, %[res] \n"
|
2008-11-19 21:31:33 +00:00
|
|
|
#if ORDER > 32
|
2010-02-08 21:59:24 +00:00
|
|
|
"subs %[cnt], %[cnt], #1 \n"
|
|
|
|
"ldrned r4, [%[f2]], #8 \n"
|
|
|
|
"ldrned r0, [%[v1], #8] \n"
|
|
|
|
"ssub16 r2, r2, r6 \n"
|
|
|
|
"ssub16 r3, r3, r7 \n"
|
|
|
|
"strd r2, [%[v1]], #8 \n"
|
|
|
|
"bne 1b \n"
|
|
|
|
#else
|
|
|
|
"ssub16 r2, r2, r6 \n"
|
|
|
|
"ssub16 r3, r3, r7 \n"
|
|
|
|
"strd r2, [%[v1]], #8 \n"
|
2008-10-03 08:54:34 +00:00
|
|
|
#endif
|
|
|
|
|
2010-02-08 21:59:24 +00:00
|
|
|
"99: \n"
|
2008-10-03 08:54:34 +00:00
|
|
|
: /* outputs */
|
2008-11-19 21:31:33 +00:00
|
|
|
#if ORDER > 32
|
2008-10-03 08:54:34 +00:00
|
|
|
[cnt]"+r"(cnt),
|
|
|
|
#endif
|
|
|
|
[v1] "+r"(v1),
|
2010-02-08 21:59:24 +00:00
|
|
|
[f2] "+r"(f2),
|
|
|
|
[s2] "+r"(s2),
|
|
|
|
[res]"=r"(res)
|
2008-10-03 08:54:34 +00:00
|
|
|
: /* inputs */
|
|
|
|
: /* clobbers */
|
|
|
|
"r0", "r1", "r2", "r3", "r4",
|
2010-05-29 15:00:10 +00:00
|
|
|
"r5", "r6", "r7", "cc", "memory"
|
2008-10-03 08:54:34 +00:00
|
|
|
);
|
2010-02-08 21:59:24 +00:00
|
|
|
return res;
|
2008-10-03 08:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* This version fetches data as 32 bit words, and *requires* v1 to be
|
|
|
|
* 32 bit aligned, otherwise it will result either in a data abort, or
|
2008-10-03 09:33:36 +00:00
|
|
|
* incorrect results (if ARM aligncheck is disabled). */
|
2008-10-03 08:54:34 +00:00
|
|
|
static inline int32_t scalarproduct(int16_t* v1, int16_t* v2)
|
|
|
|
{
|
2008-11-19 21:31:33 +00:00
|
|
|
int res;
|
|
|
|
#if ORDER > 32
|
|
|
|
int cnt = ORDER>>5;
|
|
|
|
#endif
|
|
|
|
|
2008-10-03 08:54:34 +00:00
|
|
|
asm volatile (
|
2008-11-19 21:31:33 +00:00
|
|
|
#if ORDER > 32
|
|
|
|
"mov %[res], #0 \n"
|
|
|
|
#endif
|
2008-10-03 08:54:34 +00:00
|
|
|
"tst %[v2], #2 \n"
|
|
|
|
"beq 20f \n"
|
|
|
|
|
|
|
|
"10: \n"
|
2008-11-24 18:40:43 +00:00
|
|
|
"bic %[v2], %[v2], #2 \n"
|
|
|
|
"ldmia %[v2]!, {r5-r7} \n"
|
2010-02-08 21:59:24 +00:00
|
|
|
"ldrd r0, [%[v1]], #8 \n"
|
|
|
|
|
2008-10-03 08:54:34 +00:00
|
|
|
"1: \n"
|
2010-02-08 21:59:24 +00:00
|
|
|
"pkhtb r3, r5, r6 \n"
|
|
|
|
"ldrd r4, [%[v2]], #8 \n"
|
2008-11-24 18:40:43 +00:00
|
|
|
#if ORDER > 32
|
2010-02-08 21:59:24 +00:00
|
|
|
"smladx %[res], r0, r3, %[res] \n"
|
2008-11-19 21:31:33 +00:00
|
|
|
#else
|
2010-02-08 21:59:24 +00:00
|
|
|
"smuadx %[res], r0, r3 \n"
|
2008-11-19 21:31:33 +00:00
|
|
|
#endif
|
2010-03-03 20:52:02 +00:00
|
|
|
REPEAT_BLOCK(
|
2010-02-08 21:59:24 +00:00
|
|
|
"pkhtb r0, r6, r7 \n"
|
|
|
|
"ldrd r2, [%[v1]], #8 \n"
|
|
|
|
"smladx %[res], r1, r0, %[res] \n"
|
|
|
|
"pkhtb r1, r7, r4 \n"
|
|
|
|
"ldrd r6, [%[v2]], #8 \n"
|
|
|
|
"smladx %[res], r2, r1, %[res] \n"
|
|
|
|
"pkhtb r2, r4, r5 \n"
|
|
|
|
"ldrd r0, [%[v1]], #8 \n"
|
|
|
|
"smladx %[res], r3, r2, %[res] \n"
|
|
|
|
"pkhtb r3, r5, r6 \n"
|
|
|
|
"ldrd r4, [%[v2]], #8 \n"
|
|
|
|
"smladx %[res], r0, r3, %[res] \n"
|
2010-03-03 20:52:02 +00:00
|
|
|
)
|
|
|
|
|
2010-02-08 21:59:24 +00:00
|
|
|
"pkhtb r0, r6, r7 \n"
|
|
|
|
"ldrd r2, [%[v1]], #8 \n"
|
|
|
|
"smladx %[res], r1, r0, %[res] \n"
|
|
|
|
"pkhtb r1, r7, r4 \n"
|
2008-11-19 21:31:33 +00:00
|
|
|
#if ORDER > 32
|
2008-10-03 10:09:57 +00:00
|
|
|
"subs %[cnt], %[cnt], #1 \n"
|
2010-02-08 21:59:24 +00:00
|
|
|
"ldrned r6, [%[v2]], #8 \n"
|
|
|
|
"smladx %[res], r2, r1, %[res] \n"
|
|
|
|
"pkhtb r2, r4, r5 \n"
|
|
|
|
"ldrned r0, [%[v1]], #8 \n"
|
|
|
|
"smladx %[res], r3, r2, %[res] \n"
|
2008-10-03 10:09:57 +00:00
|
|
|
"bne 1b \n"
|
2008-10-03 12:30:18 +00:00
|
|
|
#else
|
2010-02-08 21:59:24 +00:00
|
|
|
"pkhtb r4, r4, r5 \n"
|
|
|
|
"smladx %[res], r2, r1, %[res] \n"
|
|
|
|
"smladx %[res], r3, r4, %[res] \n"
|
2008-10-03 08:54:34 +00:00
|
|
|
#endif
|
|
|
|
|
2010-02-08 21:59:24 +00:00
|
|
|
"b 99f \n"
|
2010-03-03 20:52:02 +00:00
|
|
|
|
2008-10-03 08:54:34 +00:00
|
|
|
"20: \n"
|
2010-02-08 21:59:24 +00:00
|
|
|
"ldrd r0, [%[v1]], #8 \n"
|
2008-10-07 19:40:17 +00:00
|
|
|
"ldmia %[v2]!, {r5-r7} \n"
|
2010-02-08 21:59:24 +00:00
|
|
|
|
2008-10-03 08:54:34 +00:00
|
|
|
"1: \n"
|
2010-02-08 21:59:24 +00:00
|
|
|
"ldrd r2, [%[v1]], #8 \n"
|
2008-11-19 21:31:33 +00:00
|
|
|
#if ORDER > 32
|
2008-10-07 19:40:17 +00:00
|
|
|
"smlad %[res], r0, r5, %[res] \n"
|
2008-11-19 21:31:33 +00:00
|
|
|
#else
|
|
|
|
"smuad %[res], r0, r5 \n"
|
|
|
|
#endif
|
2010-03-03 20:52:02 +00:00
|
|
|
REPEAT_BLOCK(
|
2010-02-08 21:59:24 +00:00
|
|
|
"ldrd r4, [%[v2]], #8 \n"
|
2008-10-07 19:40:17 +00:00
|
|
|
"smlad %[res], r1, r6, %[res] \n"
|
2010-02-08 21:59:24 +00:00
|
|
|
"ldrd r0, [%[v1]], #8 \n"
|
2008-10-07 19:40:17 +00:00
|
|
|
"smlad %[res], r2, r7, %[res] \n"
|
2010-02-08 21:59:24 +00:00
|
|
|
"ldrd r6, [%[v2]], #8 \n"
|
2008-10-07 19:40:17 +00:00
|
|
|
"smlad %[res], r3, r4, %[res] \n"
|
2010-02-08 21:59:24 +00:00
|
|
|
"ldrd r2, [%[v1]], #8 \n"
|
2008-10-07 19:40:17 +00:00
|
|
|
"smlad %[res], r0, r5, %[res] \n"
|
2010-03-03 20:52:02 +00:00
|
|
|
)
|
2008-11-19 21:31:33 +00:00
|
|
|
|
|
|
|
#if ORDER > 32
|
2010-02-08 21:59:24 +00:00
|
|
|
"ldrd r4, [%[v2]], #8 \n"
|
|
|
|
"smlad %[res], r1, r6, %[res] \n"
|
2008-10-03 08:54:34 +00:00
|
|
|
"subs %[cnt], %[cnt], #1 \n"
|
2010-02-08 21:59:24 +00:00
|
|
|
"ldrned r0, [%[v1]], #8 \n"
|
2008-10-07 19:40:17 +00:00
|
|
|
"smlad %[res], r2, r7, %[res] \n"
|
2010-02-08 21:59:24 +00:00
|
|
|
"ldrned r6, [%[v2]], #8 \n"
|
2008-10-07 19:40:17 +00:00
|
|
|
"smlad %[res], r3, r4, %[res] \n"
|
2008-10-03 12:30:18 +00:00
|
|
|
"bne 1b \n"
|
|
|
|
#else
|
2010-02-08 21:59:24 +00:00
|
|
|
"ldr r4, [%[v2]], #4 \n"
|
|
|
|
"smlad %[res], r1, r6, %[res] \n"
|
2008-10-07 19:40:17 +00:00
|
|
|
"smlad %[res], r2, r7, %[res] \n"
|
|
|
|
"smlad %[res], r3, r4, %[res] \n"
|
2008-10-03 08:54:34 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
"99: \n"
|
|
|
|
: /* outputs */
|
2008-11-19 21:31:33 +00:00
|
|
|
#if ORDER > 32
|
2008-10-03 08:54:34 +00:00
|
|
|
[cnt]"+r"(cnt),
|
|
|
|
#endif
|
|
|
|
[v1] "+r"(v1),
|
|
|
|
[v2] "+r"(v2),
|
2008-11-19 21:31:33 +00:00
|
|
|
[res]"=r"(res)
|
2008-10-03 08:54:34 +00:00
|
|
|
: /* inputs */
|
|
|
|
: /* clobbers */
|
2010-02-08 21:59:24 +00:00
|
|
|
"r0", "r1", "r2", "r3",
|
2010-05-29 15:00:10 +00:00
|
|
|
"r4", "r5", "r6", "r7", "cc", "memory"
|
2008-10-03 08:54:34 +00:00
|
|
|
);
|
|
|
|
return res;
|
|
|
|
}
|