summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2008-04-16 20:44:10 +0000
committerMichael Sevakis <jethead71@rockbox.org>2008-04-16 20:44:10 +0000
commitbbb0c3f397b5fb44bd13a3fbc6cf75260deb019f (patch)
tree6b474558f7449970a602da02c3e0d37973a2a0c8
parenta01996436d09eca8ae114e67005d2cac73cae7b3 (diff)
downloadrockbox-bbb0c3f397b5fb44bd13a3fbc6cf75260deb019f.tar.gz
rockbox-bbb0c3f397b5fb44bd13a3fbc6cf75260deb019f.tar.bz2
rockbox-bbb0c3f397b5fb44bd13a3fbc6cf75260deb019f.zip
Optimized byte-swapping macros for ARMv6.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17148 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/target/arm/system-arm.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/firmware/target/arm/system-arm.h b/firmware/target/arm/system-arm.h
index 5627475408..9ab2bfa57b 100644
--- a/firmware/target/arm/system-arm.h
+++ b/firmware/target/arm/system-arm.h
@@ -33,7 +33,14 @@ static inline uint16_t swap16(uint16_t value)
result[ 7..0] = value[15..8];
*/
{
+#if ARM_ARCH >= 6
+ uint32_t retval;
+ asm volatile ("revsh %0, %1" /* xxAB */
+ : "=r"(retval) : "r"((uint32_t)value)); /* xxBA */
+ return retval;
+#else
return (value >> 8) | (value << 8);
+#endif
}
static inline uint32_t swap32(uint32_t value)
@@ -44,6 +51,12 @@ static inline uint32_t swap32(uint32_t value)
result[ 7.. 0] = value[31..24];
*/
{
+#if ARM_ARCH >= 6
+ uint32_t retval;
+ asm volatile ("rev %0, %1" /* ABCD */
+ : "=r"(retval) : "r"(value)); /* DCBA */
+ return retval;
+#else
uint32_t tmp;
asm volatile (
@@ -54,6 +67,7 @@ static inline uint32_t swap32(uint32_t value)
: "+r" (value), "=r" (tmp)
);
return value;
+#endif
}
static inline uint32_t swap_odd_even32(uint32_t value)
@@ -62,6 +76,12 @@ static inline uint32_t swap_odd_even32(uint32_t value)
result[31..24],[15.. 8] = value[23..16],[ 7.. 0]
result[23..16],[ 7.. 0] = value[31..24],[15.. 8]
*/
+#if ARM_ARCH >= 6
+ uint32_t retval;
+ asm volatile ("rev16 %0, %1" /* ABCD */
+ : "=r"(retval) : "r"(value)); /* BADC */
+ return retval;
+#else
uint32_t tmp;
asm volatile ( /* ABCD */
@@ -72,6 +92,7 @@ static inline uint32_t swap_odd_even32(uint32_t value)
: "+r" (value), "=r" (tmp) /* BADC */
);
return value;
+#endif
}
/* Core-level interrupt masking */