E.V.E
v2023.02.15
 
Loading...
Searching...
No Matches

◆ byte_swap_adjacent

auto eve::byte_swap_adjacent = functor<byte_swap_adjacent_t>
inlineconstexpr

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
// Regular overload
constexpr auto byte_swap_adjacent(integral_value auto x, integral_value auto n) noexcept; // 1
// Lanes masking
constexpr auto byte_swap_adjacent[conditional_expr auto c](integral_value auto x,
integral_value auto n) noexcept; // 2
constexpr auto byte_swap_adjacent[logical_value auto m](integral_value auto x,
integral_value auto n) noexcept; // 2
}
Specifies that a type is a Conditional Expression.
Definition conditional.hpp:28
The concept integral_value<T> is satisfied if and only if T satisfies eve::value and the element type...
Definition value.hpp:51
The concept logical_value<T> is satisfied if and only if T satisfies eve::value and the element type ...
Definition value.hpp:132
constexpr auto byte_swap_adjacent
strict_elementwise_callable object that swap adjacent groups of N bytes.
Definition byte_swap_adjacent.hpp:77
EVE Main Namespace.
Definition abi.hpp:18

Parameters

  • x : argument.
  • n : size of the groups of bytes to be swapped. Must be a power of 2 and less than the half size of the elements of x
  • c: Conditional expression masking the operation.
  • m: Logical value masking the operation.

Return value

  1. Return x with elementwise groups of N bytes swapped.
    • If N is greater to sizeof(x) 0 is returned.
    • If N is equal to sizeof(x) x is returned.
  2. The operation is performed conditionnaly.
Note
Take care that eve::byte_swap_adjacent is NOT the EVE functional equivalent to std::byteswap. eve::byte_reverse IS. As the name does not say, std::byteswap reverse the order of the bytes which is not an adjacent swapping except for 16 bits words.

Example

// revision 2
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
std::cout << "-> byte_swap_adjacent(wu0, 2) = " << eve::byte_swap_adjacent(wu0, 2) << "\n";
std::cout << "-> byte_swap_adjacent[ignore_last(2)](wu0, 2) = " << eve::byte_swap_adjacent[eve::ignore_last(2)](wu0, 2) << "\n";
std::cout << "-> byte_swap_adjacent[wu0 != 2u](wu0, 2) = " << eve::byte_swap_adjacent[wu0 != 2u](wu0, 2) << "\n";
std::cout << "-> byte_swap_adjacent(wu0, 2) = " << eve::byte_swap_adjacent(wu0, 2) << "\n";
}
Conditional expression ignoring the k last lanes from a eve::simd_value.
Definition conditional.hpp:332
Wrapper for SIMD registers.
Definition wide.hpp:86