1/* Copyright (C) 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_SPLAT_H
9#define LIBSIMDPP_SIMDPP_CORE_LOAD_SPLAT_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_splat.h>
17
18namespace simdpp {
19namespace SIMDPP_ARCH_NAMESPACE {
20
21/** Loads a value from a memory location and broadcasts it to all elements of a
22 vector.
23
24 @code
25 r0 = *p
26 ...
27 rN = *p
28 @endcode
29
30 @a p must have the alignment of the element of the target vector.
31*/
32// FIXME: return empty expression
33template<class T>
34SIMDPP_INL expr_vec_load_splat load_splat(const T* p)
35{
36 return expr_vec_load_splat(reinterpret_cast<const char*>(p));
37}
38
39template<class V, class T> SIMDPP_INL
40V load_splat(const T* p)
41{
42 static_assert(is_vector<V>::value && !is_mask<V>::value,
43 "V must be a non-mask vector");
44 return detail::insn::i_load_splat_any<V>(reinterpret_cast<const char*>(p));
45}
46
47} // namespace SIMDPP_ARCH_NAMESPACE
48} // namespace simdpp
49
50#endif
51
52