16 #ifndef __IPSDKUTIL_INSTRUCTIONSET_DETAIL_BOOLMASKCAST_H__ 17 #define __IPSDKUTIL_INSTRUCTIONSET_DETAIL_BOOLMASKCAST_H__ 19 #include <boost/core/enable_if.hpp> 20 #include <boost/type_traits/is_same.hpp> 21 #include <boost/mpl/and.hpp> 22 #include <boost/mpl/less.hpp> 23 #include <boost/mpl/greater.hpp> 24 #include <boost/mpl/equal_to.hpp> 25 #include <boost/mpl/sizeof.hpp> 26 #include <boost/mpl/plus.hpp> 27 #include <boost/mpl/not.hpp> 46 template <eInstructionSet::domain IS,
47 typename TIn,
typename TOut,
48 typename Enable =
void>
53 template <eInstructionSet::domain IS,
54 typename TIn,
typename TOut>
56 typename
boost::enable_if<typename boost::is_same<TIn, TOut>::type>::type>
58 static IPSDK_FORCEINLINE
void 66 template <eInstructionSet::domain IS,
67 typename TIn,
typename TOut>
68 struct BoolMaskCast<IS, TIn, TOut,
69 typename
boost::enable_if<typename boost::mpl::and_<typename boost::is_integral<TIn>::type,
70 typename boost::is_integral<TOut>::type,
71 typename boost::mpl::not_<typename boost::is_same<TIn, TOut>::type>::type,
72 typename boost::mpl::equal_to<boost::mpl::sizeof_<TIn>,
73 boost::mpl::sizeof_<TOut> >::type>::type>::type>
75 static const ipUInt8 g_shiftFactor = 8 * (
sizeof(TIn) -
sizeof(TOut));
77 static IPSDK_FORCEINLINE
void 85 template <eInstructionSet::domain IS,
87 struct BoolMaskCast<IS,
ipReal32, TOut,
88 typename
boost::enable_if<typename boost::is_integral<TOut>::type>::type>
90 static IPSDK_FORCEINLINE
void 91 act(
const BasePack<IS2PackType<IS>::_packType,
ipReal32>& in,
92 BasePack<IS2PackType<IS>::_packType, TOut>& out)
94 BasePack<IS2PackType<IS>::_packType,
ipUInt32> cvt;
95 bitwiseCast<IS>(in, cvt);
96 BoolMaskCast<IS, ipUInt32, TOut>::act(cvt, out);
100 template <eInstructionSet::domain IS,
102 struct BoolMaskCast<IS, TIn,
ipReal32,
103 typename
boost::enable_if<typename boost::is_integral<TIn>::type>::type>
105 static IPSDK_FORCEINLINE
void 106 act(
const BasePack<IS2PackType<IS>::_packType, TIn>& in,
107 BasePack<IS2PackType<IS>::_packType,
ipReal32>& out)
109 BasePack<IS2PackType<IS>::_packType,
ipUInt32> cvt;
110 BoolMaskCast<IS, TIn, ipUInt32>::act(in, cvt);
111 bitwiseCast<IS>(cvt, out);
115 template <eInstructionSet::domain IS,
116 typename TIn,
typename TOut>
117 struct BoolMaskCast<IS, TIn, TOut,
118 typename
boost::enable_if<typename boost::mpl::and_<typename boost::is_integral<TIn>::type,
119 typename boost::is_integral<TOut>::type,
120 typename boost::mpl::greater<boost::mpl::sizeof_<TIn>,
121 boost::mpl::sizeof_<TOut> >::type>::type>::type>
123 static const ipUInt8 g_shiftFactor = 8 * (
sizeof(TIn) -
sizeof(TOut));
125 static IPSDK_FORCEINLINE
void 126 act(
const BasePack<IS2PackType<IS>::_packType, TIn>& in,
127 BasePack<IS2PackType<IS>::_packType, TOut>& out)
129 BasePack<IS2PackType<IS>::_packType, TIn> tmp;
130 assign<IS>(tmp,
static_cast<TIn
>(AllBits<TOut>::value));
131 bitwiseAnd<IS>(in, tmp, tmp);
136 template <eInstructionSet::domain IS,
137 typename TIn,
typename TOut>
138 struct BoolMaskCast<IS, TIn, TOut,
139 typename
boost::enable_if<typename boost::mpl::and_<typename boost::is_integral<TIn>::type,
140 typename boost::is_integral<TOut>::type,
141 typename boost::mpl::equal_to<boost::mpl::plus<boost::mpl::sizeof_<TIn>, boost::mpl::int_<1> >,
142 boost::mpl::sizeof_<TOut> >::type>::type>::type>
144 static IPSDK_FORCEINLINE
void 145 act(
const BasePack<IS2PackType<IS>::_packType, TIn>& in,
146 BasePack<IS2PackType<IS>::_packType, TOut>& out)
149 shiftLeft<IS>(out, 8, out);
150 bitwiseOr<IS>(out, in, out);
154 template <eInstructionSet::domain IS,
155 typename TIn,
typename TOut>
156 struct BoolMaskCast<IS, TIn, TOut,
157 typename
boost::enable_if<typename boost::mpl::and_<typename boost::is_integral<TIn>::type,
158 typename boost::is_integral<TOut>::type,
159 typename boost::mpl::equal_to<boost::mpl::plus<boost::mpl::sizeof_<TIn>, boost::mpl::int_<2> >,
160 boost::mpl::sizeof_<TOut> >::type>::type>::type>
162 static IPSDK_FORCEINLINE
void 163 act(
const BasePack<IS2PackType<IS>::_packType, TIn>& in,
164 BasePack<IS2PackType<IS>::_packType, TOut>& out)
167 shiftLeft<IS>(out, 8, out);
168 bitwiseOr<IS>(out, in, out);
169 shiftLeft<IS>(out, 8, out);
170 bitwiseOr<IS>(out, in, out);
182 #endif // __IPSDKUTIL_INSTRUCTIONSET_DETAIL_BOOLMASKCAST_H__ Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
cast function; casts a Pack<instructionSet, TIn> to a Pack<instructionSet, TOut>
Definition: BoolMaskCast.h:49
bitwiseCast function; casts a Pack<instructionSet, TIn> to a Pack<instructionSet, TOut>...
Definition: DataItemNodeHdrMacrosDetails.h:48
uint8_t ipUInt8
Base types definition.
Definition: BaseTypes.h:49
Definition: PackTypes.h:56
float ipReal32
Base types definition.
Definition: BaseTypes.h:56
uint32_t ipUInt32
Base types definition.
Definition: BaseTypes.h:53
structure containing intrinsic registers used to store vectorized data
Definition: BasePackDecl.h:29