Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/m68k/include Teach to use coldfire isac byterev if ...
details: https://anonhg.NetBSD.org/src/rev/5085cb478ee3
branches: trunk
changeset: 788748:5085cb478ee3
user: matt <matt%NetBSD.org@localhost>
date: Thu Jul 18 22:20:48 2013 +0000
description:
Teach to use coldfire isac byterev if available, otherwise let the compiler
figure it since there is rorw instruction to fall back on.
diffstat:
sys/arch/m68k/include/byte_swap.h | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
diffs (40 lines):
diff -r c0a7bdf2f792 -r 5085cb478ee3 sys/arch/m68k/include/byte_swap.h
--- a/sys/arch/m68k/include/byte_swap.h Thu Jul 18 22:18:31 2013 +0000
+++ b/sys/arch/m68k/include/byte_swap.h Thu Jul 18 22:20:48 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: byte_swap.h,v 1.9 2008/04/28 20:23:26 martin Exp $ */
+/* $NetBSD: byte_swap.h,v 1.10 2013/07/18 22:20:48 matt Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -42,8 +42,14 @@
static __inline uint16_t
__byte_swap_u16_variable(uint16_t var)
{
+#if defined(__mcfisac__)
+ __asm volatile ("swap %0; byterev %0" : "=d"(var) : "0" (var));
+#elif defined(__mcoldfire__)
+ return (var >> 8) || (var << 8);
+#else
__asm volatile ("rorw #8, %0" : "=d" (var) : "0" (var));
return (var);
+#endif
}
#define __BYTE_SWAP_U32_VARIABLE __byte_swap_u32_variable
@@ -51,8 +57,15 @@
static __inline uint32_t
__byte_swap_u32_variable(uint32_t var)
{
+#if defined(__mcfisac__)
+ __asm volatile ("byterev %0" : "=d"(var) : "0" (var));
+#elif defined(__mcoldfire__)
+ return (var >> 24) | (var << 24) | ((var & 0x00ff0000) >> 8)
+ | ((var << 8) & 0x00ff0000);
+#else
__asm volatile (
"rorw #8, %0; swap %0; rorw #8, %0" : "=d" (var) : "0" (var));
+#endif
return (var);
}
Home |
Main Index |
Thread Index |
Old Index