load_u.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* Copyright (C) 2013 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_U_H
  7. #define LIBSIMDPP_SIMDPP_CORE_LOAD_U_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_u.h>
  13. namespace simdpp {
  14. namespace SIMDPP_ARCH_NAMESPACE {
  15. /** Loads a 128-bit or 256-bit integer, 32-bit or 64-bit float vector from an
  16. unaligned memory location.
  17. @par 128-bit version:
  18. @code
  19. a[0..127] = *(p)
  20. @endcode
  21. @a p must be aligned to the element size. If @a p is aligned to 16 bytes
  22. only the referenced 16 byte block is accessed. Otherwise, memory within the
  23. smallest 16-byte aligned 32-byte block may be accessed.
  24. @icost{ALTIVEC, 4}
  25. @par 256-bit version:
  26. @code
  27. a[0..255] = *(p)
  28. @endcode
  29. @a p must be aligned to 32 bytes.
  30. @icost{SSE2-SSE4.1, NEON, 2}
  31. @icost{ALTIVEC, 6}
  32. @a p must be aligned to the element size. If @a p is aligned to 32 bytes
  33. only the referenced 16 byte block is accessed. Otherwise, memory within the
  34. smallest 32-byte aligned 64-byte block may be accessed.
  35. */
  36. // Fixme return empty expression
  37. template<class T>
  38. SIMDPP_INL expr_vec_load_u load_u(const T* p)
  39. {
  40. return { reinterpret_cast<const char*>(p) };
  41. }
  42. template<class V, class T> SIMDPP_INL
  43. V load_u(const T* p)
  44. {
  45. static_assert(is_vector<V>::value && !is_mask<V>::value,
  46. "V must be a non-mask vector");
  47. return detail::insn::i_load_u_any<V>(reinterpret_cast<const char*>(p));
  48. }
  49. } // namespace SIMDPP_ARCH_NAMESPACE
  50. } // namespace simdpp
  51. #endif