File indexing completed on 2025-01-18 09:53:31
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef BOOST_UUID_DETAIL_UUID_X86_IPP_INCLUDED_
0014 #define BOOST_UUID_DETAIL_UUID_X86_IPP_INCLUDED_
0015
0016
0017 #if defined(BOOST_UUID_USE_SSE41)
0018 #include <smmintrin.h>
0019 #elif defined(BOOST_UUID_USE_SSE3)
0020 #include <pmmintrin.h>
0021 #else
0022 #include <emmintrin.h>
0023 #endif
0024
0025 #if defined(BOOST_MSVC) && defined(_M_X64) && (BOOST_MSVC < 1900 )
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 #define BOOST_UUID_DETAIL_MSVC_BUG981648
0036 #if BOOST_MSVC >= 1600
0037 extern "C" void _ReadWriteBarrier(void);
0038 #pragma intrinsic(_ReadWriteBarrier)
0039 #endif
0040 #endif
0041
0042 namespace boost {
0043 namespace uuids {
0044 namespace detail {
0045
0046 BOOST_FORCEINLINE __m128i load_unaligned_si128(const uint8_t* p) BOOST_NOEXCEPT
0047 {
0048 #if !defined(BOOST_UUID_DETAIL_MSVC_BUG981648) || defined(BOOST_UUID_USE_AVX)
0049 return _mm_loadu_si128(reinterpret_cast< const __m128i* >(p));
0050 #elif defined(BOOST_MSVC) && BOOST_MSVC >= 1600
0051 __m128i mm = _mm_loadu_si128(reinterpret_cast< const __m128i* >(p));
0052
0053 _ReadWriteBarrier();
0054 return mm;
0055 #else
0056
0057 return _mm_unpacklo_epi64(_mm_loadl_epi64(reinterpret_cast< const __m128i* >(p)), _mm_loadl_epi64(reinterpret_cast< const __m128i* >(p + 8)));
0058 #endif
0059 }
0060
0061 }
0062
0063 inline bool uuid::is_nil() const BOOST_NOEXCEPT
0064 {
0065 __m128i mm = uuids::detail::load_unaligned_si128(data);
0066 #if defined(BOOST_UUID_USE_SSE41)
0067 return _mm_test_all_zeros(mm, mm) != 0;
0068 #else
0069 mm = _mm_cmpeq_epi32(mm, _mm_setzero_si128());
0070 return _mm_movemask_epi8(mm) == 0xFFFF;
0071 #endif
0072 }
0073
0074 inline void uuid::swap(uuid& rhs) BOOST_NOEXCEPT
0075 {
0076 __m128i mm_this = uuids::detail::load_unaligned_si128(data);
0077 __m128i mm_rhs = uuids::detail::load_unaligned_si128(rhs.data);
0078 _mm_storeu_si128(reinterpret_cast< __m128i* >(rhs.data), mm_this);
0079 _mm_storeu_si128(reinterpret_cast< __m128i* >(data), mm_rhs);
0080 }
0081
0082 inline bool operator== (uuid const& lhs, uuid const& rhs) BOOST_NOEXCEPT
0083 {
0084 __m128i mm_left = uuids::detail::load_unaligned_si128(lhs.data);
0085 __m128i mm_right = uuids::detail::load_unaligned_si128(rhs.data);
0086
0087 #if defined(BOOST_UUID_USE_SSE41)
0088 __m128i mm = _mm_xor_si128(mm_left, mm_right);
0089 return _mm_test_all_zeros(mm, mm) != 0;
0090 #else
0091 __m128i mm_cmp = _mm_cmpeq_epi32(mm_left, mm_right);
0092 return _mm_movemask_epi8(mm_cmp) == 0xFFFF;
0093 #endif
0094 }
0095
0096 inline bool operator< (uuid const& lhs, uuid const& rhs) BOOST_NOEXCEPT
0097 {
0098 __m128i mm_left = uuids::detail::load_unaligned_si128(lhs.data);
0099 __m128i mm_right = uuids::detail::load_unaligned_si128(rhs.data);
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115 const __m128i mm_signs_mask = _mm_xor_si128(mm_left, mm_right);
0116
0117 __m128i mm_cmp = _mm_cmpgt_epi8(mm_right, mm_left), mm_rcmp = _mm_cmpgt_epi8(mm_left, mm_right);
0118
0119 mm_cmp = _mm_xor_si128(mm_signs_mask, mm_cmp);
0120 mm_rcmp = _mm_xor_si128(mm_signs_mask, mm_rcmp);
0121
0122 uint32_t cmp = static_cast< uint32_t >(_mm_movemask_epi8(mm_cmp)), rcmp = static_cast< uint32_t >(_mm_movemask_epi8(mm_rcmp));
0123
0124 cmp = (cmp - 1u) ^ cmp;
0125 rcmp = (rcmp - 1u) ^ rcmp;
0126
0127 return cmp < rcmp;
0128 }
0129
0130 }
0131 }
0132
0133 #endif