Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-6]: src/sys/arch/arm/include Pull up following revision(s) (reque...
details: https://anonhg.NetBSD.org/src/rev/a178dca1fd90
branches: netbsd-6
changeset: 774596:a178dca1fd90
user: riz <riz%NetBSD.org@localhost>
date: Thu Sep 13 20:28:15 2012 +0000
description:
Pull up following revision(s) (requested by martin in ticket #542):
sys/arch/arm/include/byte_swap.h: revision 1.12
Disable arm32 __asm for _byte_swap_u16_variable since gcc4.5 produces
decent code for it. Fixes PR/46898.
diffstat:
sys/arch/arm/include/byte_swap.h | 40 +++++++++++++++++++++++++---------------
1 files changed, 25 insertions(+), 15 deletions(-)
diffs (69 lines):
diff -r 6fa1bcf72ae7 -r a178dca1fd90 sys/arch/arm/include/byte_swap.h
--- a/sys/arch/arm/include/byte_swap.h Thu Sep 13 20:20:15 2012 +0000
+++ b/sys/arch/arm/include/byte_swap.h Thu Sep 13 20:28:15 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: byte_swap.h,v 1.8 2008/04/28 20:23:14 martin Exp $ */
+/* $NetBSD: byte_swap.h,v 1.8.40.1 2012/09/13 20:28:15 riz Exp $ */
/*-
* Copyright (c) 1997, 1999, 2002 The NetBSD Foundation, Inc.
@@ -40,16 +40,20 @@
static __inline uint32_t
__byte_swap_u32_variable(uint32_t v)
{
+ uint32_t t1;
+
#ifdef _ARM_ARCH_6
- __asm("rev\t%0, %1" : "=r" (v) : "0" (v));
-#else
- uint32_t t1;
+ if (!__builtin_constant_p(v)) {
+ __asm("rev\t%0, %1" : "=r" (v) : "0" (v));
+ return v;
+ }
+#endif
t1 = v ^ ((v << 16) | (v >> 16));
t1 &= 0xff00ffffU;
v = (v >> 8) | (v << 24);
v ^= (t1 >> 8);
-#endif
+
return (v);
}
@@ -59,18 +63,24 @@
{
#ifdef _ARM_ARCH_6
- __asm("rev16\t%0, %1" : "=r" (v) : "0" (v));
-#elif !defined(__thumb__)
- __asm volatile(
- "mov %0, %1, ror #8\n"
- "orr %0, %0, %0, lsr #16\n"
- "bic %0, %0, %0, lsl #16"
- : "=r" (v)
- : "0" (v));
-#else
+ if (!__builtin_constant_p(v)) {
+ __asm("rev16\t%0, %1" : "=r" (v) : "0" (v));
+ return v;
+ }
+#elif !defined(__thumb__) && 0 /* gcc produces decent code for this */
+ if (!__builtin_constant_p(v)) {
+ uint32_t v0 = v;
+ __asm volatile(
+ "mov %0, %1, ror #8\n"
+ "orr %0, %0, %0, lsr #16\n"
+ "bic %0, %0, %0, lsl #16"
+ : "=&r" (v0)
+ : "0" (v0));
+ return v0;
+ }
+#endif
v &= 0xffff;
v = (v >> 8) | (v << 8);
-#endif
return (v);
}
Home |
Main Index |
Thread Index |
Old Index