Guest User

Untitled

a guest
Jan 23rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.28 KB | None | 0 0
  1. @@ -10,22 +10,61 @@
  2. #define BOOST_SIMD_SDK_SIMD_NATIVE_HPP_INCLUDED
  3.  
  4. #include <boost/utility/enable_if.hpp>
  5. #include <boost/dispatch/meta/fusion.hpp>
  6. #include <boost/simd/sdk/simd/category.hpp>
  7. #include <boost/simd/sdk/memory/overload.hpp>
  8. +#include <boost/dispatch/attributes.hpp>
  9. #include <boost/dispatch/error/static_assert.hpp>
  10. #include <boost/simd/sdk/simd/meta/is_vectorizable.hpp>
  11. #include <boost/simd/sdk/simd/details/native/iterator.hpp>
  12.  
  13. namespace boost { namespace simd
  14. {
  15. +#ifdef _MSC_VER
  16. + namespace detail
  17. + {
  18. + #define BOOST_SIMD_AUX_GET( scalar_type, vector_type, union_member ) \
  19. + BOOST_DISPATCH_FORCE_INLINE \
  20. + scalar_type & get( vector_type & vector, unsigned int const index, scalar_type ) { return vector.union_member[ index ]; }
  21. +
  22. + BOOST_SIMD_AUX_GET( float , __m128 , m128_f32 )
  23. + BOOST_SIMD_AUX_GET( unsigned __int64, __m128 , m128_u64 )
  24. + BOOST_SIMD_AUX_GET( __int8 , __m128 , m128_i8 )
  25. + BOOST_SIMD_AUX_GET( __int16 , __m128 , m128_i16 )
  26. + BOOST_SIMD_AUX_GET( __int32 , __m128 , m128_i32 )
  27. + BOOST_SIMD_AUX_GET( __int64 , __m128 , m128_i64 )
  28. + BOOST_SIMD_AUX_GET( unsigned __int8 , __m128 , m128_u8 )
  29. + BOOST_SIMD_AUX_GET( unsigned __int16, __m128 , m128_u16 )
  30. + BOOST_SIMD_AUX_GET( unsigned __int32, __m128 , m128_u32 )
  31. +
  32. + BOOST_SIMD_AUX_GET( __int8 , __m128i, m128i_i8 )
  33. + BOOST_SIMD_AUX_GET( __int16 , __m128i, m128i_i16 )
  34. + BOOST_SIMD_AUX_GET( __int32 , __m128i, m128i_i32 )
  35. + BOOST_SIMD_AUX_GET( __int64 , __m128i, m128i_i64 )
  36. + BOOST_SIMD_AUX_GET( unsigned __int8 , __m128i, m128i_u8 )
  37. + BOOST_SIMD_AUX_GET( unsigned __int16, __m128i, m128i_u16 )
  38. + BOOST_SIMD_AUX_GET( unsigned __int32, __m128i, m128i_u32 )
  39. + BOOST_SIMD_AUX_GET( unsigned __int64, __m128i, m128i_u64 )
  40. +
  41. + BOOST_SIMD_AUX_GET( double , __m128d, m128d_f64 )
  42. +
  43. + #undef BOOST_SIMD_AUX_GET
  44. + }
  45. +#endif // _MSC_VER
  46. +
  47. //////////////////////////////////////////////////////////////////////////////
  48. - /// Platform independant native SIMD type
  49. + /// Platform independent native SIMD type
  50. //////////////////////////////////////////////////////////////////////////////
  51. - template<class Scalar,class Extension> union native
  52. + template<class Scalar,class Extension>
  53. + #ifdef _MSC_VER
  54. + struct
  55. + #else
  56. + union
  57. + #endif // _MSC_ER
  58. + native
  59. {
  60. ////////////////////////////////////////////////////////////////////////////
  61. // native<S,E> is a SIMD type encapsulation
  62. ////////////////////////////////////////////////////////////////////////////
  63. typedef Extension extension_type;
  64. typedef native<Scalar,Extension> this_type;
  65. @@ -53,32 +92,26 @@
  66. ? sizeof(native_type)/sizeof(value_type) : 1};
  67.  
  68. ////////////////////////////////////////////////////////////////////////////
  69. // SIMD register value
  70. ////////////////////////////////////////////////////////////////////////////
  71. native_type data_;
  72. - value_type array[static_size];
  73. + #ifndef _MSC_VER
  74. + value_type array[static_size];
  75. + #endif // _MSC_VER
  76.  
  77. ////////////////////////////////////////////////////////////////////////////
  78. // Assignment operator from same native types
  79. ////////////////////////////////////////////////////////////////////////////
  80. - this_type& operator=(this_type const& s)
  81. - {
  82. - data_ = s.data_;
  83. - return *this;
  84. - }
  85. + this_type& operator=(this_type const& s) { data_ = s.data_; return *this; }
  86.  
  87. ////////////////////////////////////////////////////////////////////////////
  88. // Assignment operator from compatible types
  89. ////////////////////////////////////////////////////////////////////////////
  90. template<class S2>
  91. - this_type& operator=(native<S2, extension_type> const& s)
  92. - {
  93. - data_ = native_type(s.data_);
  94. - return *this;
  95. - }
  96. + this_type& operator=(native<S2, extension_type> const& s) { data_ = native_type(s.data_); return *this; }
  97.  
  98. ////////////////////////////////////////////////////////////////////////////
  99. // Assignment operator from raw SIMD vector types
  100. ////////////////////////////////////////////////////////////////////////////
  101. this_type& operator=(native_type const& s) { data_ = s; return *this;}
  102.  
  103. @@ -93,29 +126,35 @@
  104.  
  105. ////////////////////////////////////////////////////////////////////////////
  106. // Const-array like interface
  107. ////////////////////////////////////////////////////////////////////////////
  108. static std::size_t size() { return static_size; }
  109.  
  110. - reference operator[](int i)
  111. + BOOST_DISPATCH_FORCE_INLINE
  112. + reference operator[]( unsigned int const i )
  113. {
  114. - return array[i];
  115. + #ifdef _MSC_VER
  116. + return detail::get( data_, i, value_type() );
  117. + #else
  118. + return array[ i ];
  119. + #endif // _MSC_VER
  120. }
  121.  
  122. - const_reference operator[](int i) const
  123. + BOOST_DISPATCH_FORCE_INLINE
  124. + const_reference operator[]( unsigned int const i ) const
  125. {
  126. - return array[i];
  127. + return const_cast<native &>( *this ).operator[]( i );
  128. }
  129.  
  130. ////////////////////////////////////////////////////////////////////////////
  131. // Type casting operator for compatibility with intrinsic functions
  132. // The operator() version is here for some variation of Altivec which fails
  133. // to perform the proper automatic type-casting on intrinsic calls.
  134. ////////////////////////////////////////////////////////////////////////////
  135. - operator native_type() const { return data_; }
  136. - native_type operator()() const { return data_; }
  137. + operator native_type const &() const { return data_; }
  138. + native_type const & operator()() const { return data_; }
  139.  
  140. ////////////////////////////////////////////////////////////////////////////
  141. // new/delete operator to force alignment on heap of native values
  142. ////////////////////////////////////////////////////////////////////////////
  143. BOOST_SIMD_MEMORY_OVERLOAD_NEW_DELETE(this_type)
Add Comment
Please, Sign In to add comment