Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @@ -10,22 +10,61 @@
- #define BOOST_SIMD_SDK_SIMD_NATIVE_HPP_INCLUDED
- #include <boost/utility/enable_if.hpp>
- #include <boost/dispatch/meta/fusion.hpp>
- #include <boost/simd/sdk/simd/category.hpp>
- #include <boost/simd/sdk/memory/overload.hpp>
- +#include <boost/dispatch/attributes.hpp>
- #include <boost/dispatch/error/static_assert.hpp>
- #include <boost/simd/sdk/simd/meta/is_vectorizable.hpp>
- #include <boost/simd/sdk/simd/details/native/iterator.hpp>
- namespace boost { namespace simd
- {
- +#ifdef _MSC_VER
- + namespace detail
- + {
- + #define BOOST_SIMD_AUX_GET( scalar_type, vector_type, union_member ) \
- + BOOST_DISPATCH_FORCE_INLINE \
- + scalar_type & get( vector_type & vector, unsigned int const index, scalar_type ) { return vector.union_member[ index ]; }
- +
- + BOOST_SIMD_AUX_GET( float , __m128 , m128_f32 )
- + BOOST_SIMD_AUX_GET( unsigned __int64, __m128 , m128_u64 )
- + BOOST_SIMD_AUX_GET( __int8 , __m128 , m128_i8 )
- + BOOST_SIMD_AUX_GET( __int16 , __m128 , m128_i16 )
- + BOOST_SIMD_AUX_GET( __int32 , __m128 , m128_i32 )
- + BOOST_SIMD_AUX_GET( __int64 , __m128 , m128_i64 )
- + BOOST_SIMD_AUX_GET( unsigned __int8 , __m128 , m128_u8 )
- + BOOST_SIMD_AUX_GET( unsigned __int16, __m128 , m128_u16 )
- + BOOST_SIMD_AUX_GET( unsigned __int32, __m128 , m128_u32 )
- +
- + BOOST_SIMD_AUX_GET( __int8 , __m128i, m128i_i8 )
- + BOOST_SIMD_AUX_GET( __int16 , __m128i, m128i_i16 )
- + BOOST_SIMD_AUX_GET( __int32 , __m128i, m128i_i32 )
- + BOOST_SIMD_AUX_GET( __int64 , __m128i, m128i_i64 )
- + BOOST_SIMD_AUX_GET( unsigned __int8 , __m128i, m128i_u8 )
- + BOOST_SIMD_AUX_GET( unsigned __int16, __m128i, m128i_u16 )
- + BOOST_SIMD_AUX_GET( unsigned __int32, __m128i, m128i_u32 )
- + BOOST_SIMD_AUX_GET( unsigned __int64, __m128i, m128i_u64 )
- +
- + BOOST_SIMD_AUX_GET( double , __m128d, m128d_f64 )
- +
- + #undef BOOST_SIMD_AUX_GET
- + }
- +#endif // _MSC_VER
- +
- //////////////////////////////////////////////////////////////////////////////
- - /// Platform independant native SIMD type
- + /// Platform independent native SIMD type
- //////////////////////////////////////////////////////////////////////////////
- - template<class Scalar,class Extension> union native
- + template<class Scalar,class Extension>
- + #ifdef _MSC_VER
- + struct
- + #else
- + union
- + #endif // _MSC_ER
- + native
- {
- ////////////////////////////////////////////////////////////////////////////
- // native<S,E> is a SIMD type encapsulation
- ////////////////////////////////////////////////////////////////////////////
- typedef Extension extension_type;
- typedef native<Scalar,Extension> this_type;
- @@ -53,32 +92,26 @@
- ? sizeof(native_type)/sizeof(value_type) : 1};
- ////////////////////////////////////////////////////////////////////////////
- // SIMD register value
- ////////////////////////////////////////////////////////////////////////////
- native_type data_;
- - value_type array[static_size];
- + #ifndef _MSC_VER
- + value_type array[static_size];
- + #endif // _MSC_VER
- ////////////////////////////////////////////////////////////////////////////
- // Assignment operator from same native types
- ////////////////////////////////////////////////////////////////////////////
- - this_type& operator=(this_type const& s)
- - {
- - data_ = s.data_;
- - return *this;
- - }
- + this_type& operator=(this_type const& s) { data_ = s.data_; return *this; }
- ////////////////////////////////////////////////////////////////////////////
- // Assignment operator from compatible types
- ////////////////////////////////////////////////////////////////////////////
- template<class S2>
- - this_type& operator=(native<S2, extension_type> const& s)
- - {
- - data_ = native_type(s.data_);
- - return *this;
- - }
- + this_type& operator=(native<S2, extension_type> const& s) { data_ = native_type(s.data_); return *this; }
- ////////////////////////////////////////////////////////////////////////////
- // Assignment operator from raw SIMD vector types
- ////////////////////////////////////////////////////////////////////////////
- this_type& operator=(native_type const& s) { data_ = s; return *this;}
- @@ -93,29 +126,35 @@
- ////////////////////////////////////////////////////////////////////////////
- // Const-array like interface
- ////////////////////////////////////////////////////////////////////////////
- static std::size_t size() { return static_size; }
- - reference operator[](int i)
- + BOOST_DISPATCH_FORCE_INLINE
- + reference operator[]( unsigned int const i )
- {
- - return array[i];
- + #ifdef _MSC_VER
- + return detail::get( data_, i, value_type() );
- + #else
- + return array[ i ];
- + #endif // _MSC_VER
- }
- - const_reference operator[](int i) const
- + BOOST_DISPATCH_FORCE_INLINE
- + const_reference operator[]( unsigned int const i ) const
- {
- - return array[i];
- + return const_cast<native &>( *this ).operator[]( i );
- }
- ////////////////////////////////////////////////////////////////////////////
- // Type casting operator for compatibility with intrinsic functions
- // The operator() version is here for some variation of Altivec which fails
- // to perform the proper automatic type-casting on intrinsic calls.
- ////////////////////////////////////////////////////////////////////////////
- - operator native_type() const { return data_; }
- - native_type operator()() const { return data_; }
- + operator native_type const &() const { return data_; }
- + native_type const & operator()() const { return data_; }
- ////////////////////////////////////////////////////////////////////////////
- // new/delete operator to force alignment on heap of native values
- ////////////////////////////////////////////////////////////////////////////
- BOOST_SIMD_MEMORY_OVERLOAD_NEW_DELETE(this_type)
Add Comment
Please, Sign In to add comment