1/* Copyright (C) 2017 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_DETAIL_INSN_CONV_FLOAT_TO_INT8_H
9#define LIBSIMDPP_SIMDPP_DETAIL_INSN_CONV_FLOAT_TO_INT8_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/conv_float_to_int32.h>
17#include <simdpp/detail/insn/conv_shrink_to_int8.h>
18
19namespace simdpp {
20namespace SIMDPP_ARCH_NAMESPACE {
21namespace detail {
22namespace insn {
23
24
25template<unsigned N> SIMDPP_INL
26uint8<N> i_to_uint8(const float32<N>& a)
27{
28 return i_to_uint8((uint32<N>) i_to_int32(a));
29}
30
31template<unsigned N> SIMDPP_INL
32uint8<N> i_to_uint8(const float64<N>& a)
33{
34 return i_to_uint8((uint32<N>) i_to_int32(a));
35}
36
37template<unsigned N> SIMDPP_INL
38int8<N> i_to_int8(const float32<N>& a)
39{
40 return (int8<N>) i_to_uint8((uint32<N>) i_to_int32(a));
41}
42
43template<unsigned N> SIMDPP_INL
44int8<N> i_to_int8(const float64<N>& a)
45{
46 return (int8<N>) i_to_uint8((uint32<N>) i_to_int32(a));
47}
48
49
50} // namespace insn
51} // namespace detail
52} // namespace SIMDPP_ARCH_NAMESPACE
53} // namespace simdpp
54
55#endif
56
57
58