1 | /* Copyright (C) 2013-2014 Povilas Kanapickas <povilas@radix.lt> |
2 | |
3 | Distributed under the Boost Software License, Version 1.0. |
4 | (See accompanying file LICENSE_1_0.txt or copy at |
5 | http://www.boost.org/LICENSE_1_0.txt) |
6 | */ |
7 | |
8 | #ifndef LIBSIMDPP_SIMDPP_CORE_LOAD_H |
9 | #define LIBSIMDPP_SIMDPP_CORE_LOAD_H |
10 | |
11 | #ifndef LIBSIMDPP_SIMD_H |
12 | #error "This file must be included through simd.h" |
13 | #endif |
14 | |
15 | #include <simdpp/types.h> |
16 | #include <simdpp/detail/insn/load.h> |
17 | |
18 | namespace simdpp { |
19 | namespace SIMDPP_ARCH_NAMESPACE { |
20 | |
21 | /** Loads a 128-bit or 256-bit integer, 32-bit or 64-bit float vector |
22 | from an aligned memory location. |
23 | |
24 | @par 128-bit version: |
25 | |
26 | @code |
27 | a[0..127] = *(p) |
28 | @endcode |
29 | @a p must be aligned to 16 bytes. |
30 | |
31 | @par 256-bit version: |
32 | |
33 | @code |
34 | a[0..255] = *(p) |
35 | @endcode |
36 | @a p must be aligned to 32 bytes. |
37 | |
38 | @icost{SSE2-SSE4.1, NEON, ALTIVEC, 2} |
39 | @icost{AVX (integer vectors), 2} |
40 | */ |
41 | // Fixme return empty expression |
42 | template<class T> |
43 | SIMDPP_INL expr_vec_load load(const T* p) |
44 | { |
45 | expr_vec_load r; |
46 | r.a = reinterpret_cast<const char*>(p); |
47 | return r; |
48 | } |
49 | |
50 | template<class V, class T> SIMDPP_INL |
51 | V load(const T* p) |
52 | { |
53 | static_assert(is_vector<V>::value && !is_mask<V>::value, |
54 | "V must be a non-mask vector" ); |
55 | return detail::insn::i_load_any<V>(reinterpret_cast<const char*>(p)); |
56 | } |
57 | |
58 | } // namespace SIMDPP_ARCH_NAMESPACE |
59 | } // namespace simdpp |
60 | |
61 | #endif |
62 | |
63 | |