load_splat.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* Copyright (C) 2014 Povilas Kanapickas <[email protected]>
  2. Distributed under the Boost Software License, Version 1.0.
  3. (See accompanying file LICENSE_1_0.txt or copy at
  4. http://www.boost.org/LICENSE_1_0.txt)
  5. */
  6. #ifndef LIBSIMDPP_SIMDPP_CORE_LOAD_SPLAT_H
  7. #define LIBSIMDPP_SIMDPP_CORE_LOAD_SPLAT_H
  8. #ifndef LIBSIMDPP_SIMD_H
  9. #error "This file must be included through simd.h"
  10. #endif
  11. #include <simdpp/types.h>
  12. #include <simdpp/detail/insn/load_splat.h>
  13. namespace simdpp {
  14. namespace SIMDPP_ARCH_NAMESPACE {
  15. /** Loads a value from a memory location and broadcasts it to all elements of a
  16. vector.
  17. @code
  18. r0 = *p
  19. ...
  20. rN = *p
  21. @endcode
  22. @a p must have the alignment of the element of the target vector.
  23. */
  24. // FIXME: return empty expression
  25. template<class T>
  26. SIMDPP_INL expr_vec_load_splat load_splat(const T* p)
  27. {
  28. return expr_vec_load_splat(reinterpret_cast<const char*>(p));
  29. }
  30. template<class V, class T> SIMDPP_INL
  31. V load_splat(const T* p)
  32. {
  33. static_assert(is_vector<V>::value && !is_mask<V>::value,
  34. "V must be a non-mask vector");
  35. return detail::insn::i_load_splat_any<V>(reinterpret_cast<const char*>(p));
  36. }
  37. } // namespace SIMDPP_ARCH_NAMESPACE
  38. } // namespace simdpp
  39. #endif