diff options
author | Gabriel Ganne <gabriel.ganne@enea.com> | 2017-11-21 11:33:45 +0100 |
---|---|---|
committer | Damjan Marion <dmarion.lists@gmail.com> | 2017-11-21 14:36:51 +0000 |
commit | 70d44d347a58caef0a4417bdc587a37b0a638783 (patch) | |
tree | 8df0dfb31fb155c62e05947361ad208f19f78df7 /src | |
parent | c62a63dd05bd815cd9ea399140cb6fc50a584132 (diff) |
use REV on aarch64 for endianness swapping (VPP-1067)
Change-Id: I2de52725f40380422ca5019405df36cc05681603
Signed-off-by: Gabriel Ganne <gabriel.ganne@enea.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/vppinfra/byte_order.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/vppinfra/byte_order.h b/src/vppinfra/byte_order.h index b263538c6fe..4cdc06fb329 100644 --- a/src/vppinfra/byte_order.h +++ b/src/vppinfra/byte_order.h @@ -56,6 +56,13 @@ always_inline u16 clib_byte_swap_u16 (u16 x) { +#if defined (__aarch64__) + if (!__builtin_constant_p (x)) + { + __asm__ ("rev16 %w0, %w0":"+r" (x)); + return x; + } +#endif return (x >> 8) | (x << 8); } @@ -74,6 +81,12 @@ clib_byte_swap_u32 (u32 x) asm volatile ("bswap %0":"=r" (x):"0" (x)); return x; } +#elif defined (__aarch64__) + if (!__builtin_constant_p (x)) + { + __asm__ ("rev %w0, %w0":"+r" (x)); + return x; + } #endif return ((x << 24) | ((x & 0xff00) << 8) | ((x >> 8) & 0xff00) | (x >> 24)); } @@ -93,6 +106,12 @@ clib_byte_swap_u64 (u64 x) asm volatile ("bswapq %0":"=r" (x):"0" (x)); return x; } +#elif defined (__aarch64__) + if (!__builtin_constant_p (x)) + { + __asm__ ("rev %0, %0":"+r" (x)); + return x; + } #endif #define _(x,n,i) \ ((((x) >> (8*(i))) & 0xff) << (8*((n)-(i)-1))) |