/* Copyright (C) 2011-2014 Povilas Kanapickas Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ #ifndef LIBSIMDPP_SIMD_INSERT_H #define LIBSIMDPP_SIMD_INSERT_H #ifndef LIBSIMDPP_SIMD_H #error "This file must be included through simd.h" #endif #include #include namespace simdpp { namespace SIMDPP_ARCH_NAMESPACE { /** Inserts an element into a vector at the position identified by @a id. @code r0 = (id == 0) ? x : a0 ... rN = (id == N) ? x : aN @endcode This function may have very high latency. It is expected that the argument comes from a general-purpose register. */ template SIMDPP_INL uint8 insert(const uint8& a, uint8_t x) { static_assert(id < N, "index out of bounds"); return detail::insn::i_insert(a, x); } template SIMDPP_INL int8 insert(const int8& a, int8_t x) { static_assert(id < N, "index out of bounds"); return (int8) detail::insn::i_insert((uint8) a, (uint8_t)x); } template SIMDPP_INL uint16 insert(const uint16& a, uint16_t x) { static_assert(id < N, "index out of bounds"); return detail::insn::i_insert(a, x); } template SIMDPP_INL int16 insert(const int16& a, int16_t x) { static_assert(id < N, "index out of bounds"); return (int16) detail::insn::i_insert((uint16) a, (uint16_t)x); } template SIMDPP_INL uint32 insert(const uint32& a, uint32_t x) { static_assert(id < N, "index out of bounds"); return detail::insn::i_insert(a, x); } template SIMDPP_INL int32 insert(const int32& a, int32_t x) { static_assert(id < N, "index out of bounds"); return (int32) detail::insn::i_insert((uint32)a, (uint32_t)x); } template SIMDPP_INL uint64 insert(const uint64& a, uint64_t x) { static_assert(id < N, "index out of bounds"); return detail::insn::i_insert(a, x); } template SIMDPP_INL int64 insert(const int64& a, int64_t x) { static_assert(id < N, "index out of bounds"); return (int64) detail::insn::i_insert((uint64)a, (uint64_t)x); } template SIMDPP_INL float32 insert(const float32& a, float x) { static_assert(id < N, "index out of bounds"); return detail::insn::i_insert(a, x); } template SIMDPP_INL float64 insert(const float64& a, double x) { static_assert(id < N, "index out of bounds"); return detail::insn::i_insert(a, x); } } // namespace SIMDPP_ARCH_NAMESPACE } // namespace simdpp #endif