// The Construct // // Copyright (C) The Construct Developers, Authors & Contributors // Copyright (C) 2016-2020 Jason Volk // // Permission to use, copy, modify, and/or distribute this software for any // purpose with or without fee is hereby granted, provided that the above // copyright notice and this permission notice is present in all copies. The // full license for this software is available in the LICENSE file. // // This header is not included with the standard include group (ircd.h). // Include this header in specific units as necessary. // #pragma once #define HAVE_IRCD_SIMD_H #include T shl(const T &a) noexcept; template T shr(const T &a) noexcept; template u128x1 shl(const u128x1 &a) noexcept; template u128x1 shr(const u128x1 &a) noexcept; // readable output and debug template string_view str_reg(const mutable_buffer &buf, const T &, const uint &fmt = 0) noexcept; template string_view str_mem(const mutable_buffer &buf, const T &, const uint &fmt = 0) noexcept; } namespace ircd { using simd::shl; using simd::shr; } /// Shuffle control structure. This represents an 8-bit immediate operand; /// note it can only be used if constexprs are allowed in your definition unit. struct ircd::simd::pshuf_imm8 { u8 dst3 : 2; // set src idx for word 3 u8 dst2 : 2; // set src idx for word 2 u8 dst1 : 2; // set src idx for word 1 u8 dst0 : 2; // set src idx for word 0 }; template [[using gnu: always_inline, gnu_inline, artificial]] extern inline ircd::u128x1 ircd::simd::shr(const u128x1 &a) noexcept { static_assert ( b % 8 == 0, "xmmx register only shifts right at bytewise resolution." ); return _mm_bsrli_si128(a, b / 8); } template [[using gnu: always_inline, gnu_inline, artificial]] extern inline ircd::u128x1 ircd::simd::shl(const u128x1 &a) noexcept { static_assert ( b % 8 == 0, "xmmx register only shifts right at bytewise resolution." ); return _mm_bslli_si128(a, b / 8); }