native
0.0.1
Vectors, masks and wide register packs for C++26
Main Page
Related Pages
Topics
Modules
Namespaces
Concepts
Classes
Files
File List
File Members
Loading...
Searching...
No Matches
register_order.h
1
// SPDX-License-Identifier: BSD-2-Clause OR Apache-2.0
2
#pragma once
3
#include "native/config.h"
4
#include "
native/attributes.h
"
5
#if NATIVE_HOST_NEON
6
#include <arm_neon.h>
7
#endif
8
#if NATIVE_HOST_NEON || defined(NATIVE_DOXYGEN)
9
namespace
native
{
10
namespace
detail {
11
// At a Clang inline-assembly boundary on big-endian AArch64,
12
// 128-bit vector-to-byte asm coercion requires reversing all bytes,
13
// including each element's bytes. Its 64-bit coercion already has native
14
// register order. Apply the same involution on inputs and outputs.
15
template
<
class
T>
16
native_inline
T arm_register_order(T x)
noexcept
{
17
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
18
if
constexpr
(
sizeof
(T) == 8) {
19
return
x;
20
}
else
{
21
auto
bytes = __builtin_bit_cast(uint8x16_t, x);
22
return
__builtin_bit_cast(T, __builtin_shufflevector(bytes, bytes,
23
15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0));
24
}
25
#else
26
return
x;
27
#endif
28
}
29
}
30
}
31
#endif
attributes.h
Compiler attributes for host code, with shader-safe shared modifiers.
native_inline
#define native_inline
inline [[always_inline]]
Definition
attributes.h:212
native
Architecture-tagged vectors, register packs and supporting value types. Native arithmetic follows its...
Definition
native.arm.aes.ccm:10
src
native
arm
detail
register_order.h
Generated by
1.18.0