Skip to content

Commit

Permalink
Move self_shl & self_shr to their respective callable version
Browse files Browse the repository at this point in the history
  • Loading branch information
SadiinsoSnowfall authored Sep 24, 2024
1 parent 0d06cf8 commit ef84833
Show file tree
Hide file tree
Showing 46 changed files with 868 additions and 1,087 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ jobs:
## Mac OS X Targets
##################################################################################################
macosx:
runs-on: [macos-12]
runs-on: [macos-13]
strategy:
fail-fast: false
matrix:
Expand Down
43 changes: 22 additions & 21 deletions include/eve/arch/cpu/wide.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <eve/conditional.hpp>
#include <eve/detail/abi.hpp>
#include <eve/detail/function/combine.hpp>
#include <eve/detail/function/compounds.hpp>
#include <eve/detail/function/fill.hpp>
#include <eve/detail/function/friends.hpp>
#include <eve/detail/function/load.hpp>
Expand Down Expand Up @@ -732,75 +731,77 @@ namespace eve
//! @brief Performs the compound left-shift on all the eve::wide lanes and assign
//! the result to current one.
template<integral_value S>
friend EVE_FORCEINLINE auto& operator<<=(wide& w, S s) noexcept
friend EVE_FORCEINLINE wide& operator<<=(wide& w, S s) noexcept
#if !defined(EVE_DOXYGEN_INVOKED)
requires(!kumi::product_type<Type>)
#endif
{
return detail::self_shl(w, s);
w = shl(w, s);
return w;
}

//! @brief Performs the compound left-shift on all the eve::wide lanes with a constant and assign
//! the result to current one.
template<std::ptrdiff_t V>
friend EVE_FORCEINLINE auto& operator<<=(wide& w, index_t<V> const& s) noexcept
friend EVE_FORCEINLINE wide& operator<<=(wide& w, index_t<V> const& s) noexcept
#if !defined(EVE_DOXYGEN_INVOKED)
requires(!kumi::product_type<Type>)
#endif
{
return detail::self_shl(w, s);
w = shl(w, s);
return w;
}

//! @brief Performs the left-shift between all lanes of a eve::wide and an integral scalar.
template<integral_value S> friend EVE_FORCEINLINE auto operator<<(wide v, S s) noexcept
template<integral_value S>
friend EVE_FORCEINLINE wide operator<<(wide w, S s) noexcept
{
auto that = v;
return that <<= s;
return shl(w, s);
}

//! @brief Performs the left-shift between all lanes of a eve::wide and an integral constant.
template<std::ptrdiff_t V>
friend EVE_FORCEINLINE auto operator<<(wide v, index_t<V> const& s) noexcept
friend EVE_FORCEINLINE wide operator<<(wide w, index_t<V> const& s) noexcept
{
auto that = v;
return that <<= s;
return shl(w, s);
}

//! @brief Performs the compound right-shift on all the eve::wide lanes and assign
//! the result to current one.
template<integral_value S>
friend EVE_FORCEINLINE auto& operator>>=(wide& w, S s) noexcept
friend EVE_FORCEINLINE wide& operator>>=(wide& w, S s) noexcept
#if !defined(EVE_DOXYGEN_INVOKED)
requires(!kumi::product_type<Type>)
#endif
{
return detail::self_shr(w, s);
w = shr(w, s);
return w;
}

//! @brief Performs the compound right-shift on all the eve::wide lanes and assign
//! the result to current one.
template<std::ptrdiff_t V>
friend EVE_FORCEINLINE auto& operator>>=(wide& w, index_t<V> const& s) noexcept
friend EVE_FORCEINLINE wide& operator>>=(wide& w, index_t<V> const& s) noexcept
#if !defined(EVE_DOXYGEN_INVOKED)
requires(!kumi::product_type<Type>)
#endif
{
return detail::self_shr(w, s);
w = shr(w, s);
return w;
}

//! @brief Performs the right-shift between all lanes of a eve::wide and an integral scalar.
template<integral_value S> friend EVE_FORCEINLINE auto operator>>(wide v, S s) noexcept
template<integral_value S>
friend EVE_FORCEINLINE wide operator>>(wide w, S s) noexcept
{
auto that = v;
return that >>= s;
return shr(w, s);
}

//! @brief Performs the right-shift between all lanes of a eve::wide and an integral constant.
template<std::ptrdiff_t V>
friend EVE_FORCEINLINE auto operator>>(wide v, index_t<V> const& s) noexcept
friend EVE_FORCEINLINE auto operator>>(wide w, index_t<V> const& s) noexcept
{
auto that = v;
return that >>= s;
return shr(w, s);
}

//==============================================================================================
Expand Down
37 changes: 20 additions & 17 deletions include/eve/detail/assert_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,24 @@

#include <eve/detail/meta.hpp>
#include <eve/module/core/regular/all.hpp>
#include <eve/module/core/regular/if_else.hpp>
#include <type_traits>

namespace eve::detail
{
template<typename A0, callable_options O, eve::value A1>
constexpr EVE_FORCEINLINE bool assert_shift(O const& opts, A1 t) noexcept
{
using v1_t = element_type_t<A1>;
constexpr v1_t Mx = sizeof(element_type_t<A0>) * 8;
auto m = opts[condition_key];

auto wt = if_else(m, as_wide_as_t<A1, A0>{t}, v1_t{0});
return eve::all((wt < Mx) && (wt >= 0));
}

template<typename A0, eve::value A1>
constexpr EVE_FORCEINLINE bool assert_good_shift(A1 const &t) noexcept
constexpr EVE_FORCEINLINE bool assert_relative_shift(A1 t) noexcept
{
using v1_t = element_type_t<A1>;
constexpr v1_t Mx = sizeof(element_type_t<A0>) * 8;
Expand All @@ -29,31 +41,22 @@ namespace eve::detail
}
}

template< typename A0, callable_options O, eve::value A1>
constexpr EVE_FORCEINLINE bool assert_good_shift(O const& opts, A1 t) noexcept
template<typename A0, callable_options O, eve::value A1>
constexpr EVE_FORCEINLINE bool assert_relative_shift(O const& opts, A1 t) noexcept
{
using v1_t = element_type_t<A1>;
constexpr v1_t Mx = sizeof(element_type_t<A0>) * 8;

auto m = opts[condition_key];
t = if_else(m, t, 0);


auto wt = if_else(m, as_wide_as_t<A1, A0>{t}, v1_t{0});

if constexpr(std::is_unsigned_v<element_type_t<A1>>)
{
return eve::all( t < Mx );
return eve::all( wt < Mx );
}
else
{
return eve::all( (t < Mx) && (t > -Mx) );
return eve::all( (wt < Mx) && (wt > -Mx) );
}
}

template<typename A0, typename U, U V>
constexpr EVE_FORCEINLINE bool assert_good_shift(std::integral_constant<U,V> const &t) noexcept
{
constexpr U Mx = sizeof(element_type_t<A0>) * 8;

if constexpr(std::is_unsigned_v<U>) return t < Mx;
else return (t < Mx) && (t > -Mx);
}
}
27 changes: 0 additions & 27 deletions include/eve/detail/function/compounds.hpp

This file was deleted.

136 changes: 0 additions & 136 deletions include/eve/detail/function/simd/arm/neon/bit_compounds.hpp

This file was deleted.

Loading

0 comments on commit ef84833

Please sign in to comment.