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