load.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* Copyright (C) 2013-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_H
  7. #define LIBSIMDPP_SIMDPP_CORE_LOAD_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.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
  16. from an aligned memory location.
  17. @par 128-bit version:
  18. @code
  19. a[0..127] = *(p)
  20. @endcode
  21. @a p must be aligned to 16 bytes.
  22. @par 256-bit version:
  23. @code
  24. a[0..255] = *(p)
  25. @endcode
  26. @a p must be aligned to 32 bytes.
  27. @icost{SSE2-SSE4.1, NEON, ALTIVEC, 2}
  28. @icost{AVX (integer vectors), 2}
  29. */
  30. // Fixme return empty expression
  31. template<class T>
  32. SIMDPP_INL expr_vec_load load(const T* p)
  33. {
  34. expr_vec_load r;
  35. r.a = reinterpret_cast<const char*>(p);
  36. return r;
  37. }
  38. template<class V, class T> SIMDPP_INL
  39. V load(const T* p)
  40. {
  41. static_assert(is_vector<V>::value && !is_mask<V>::value,
  42. "V must be a non-mask vector");
  43. return detail::insn::i_load_any<V>(reinterpret_cast<const char*>(p));
  44. }
  45. } // namespace SIMDPP_ARCH_NAMESPACE
  46. } // namespace simdpp
  47. #endif