1 /* 2 * Distributed under the Boost Software License, Version 1.0. 3 * (See accompanying file LICENSE_1_0.txt or copy at 4 * http://www.boost.org/LICENSE_1_0.txt) 5 * 6 * Copyright (c) 2020 Andrey Semashev 7 */ 8 /*! 9 * \file x86_vector_tools.hpp 10 * 11 * This file contains common tools for x86 vectorization 12 */ 13 14 #ifndef BOOST_ATOMIC_X86_VECTOR_TOOLS_HPP_INCLUDED_ 15 #define BOOST_ATOMIC_X86_VECTOR_TOOLS_HPP_INCLUDED_ 16 17 #include <boost/predef/architecture/x86.h> 18 #include <boost/atomic/detail/int_sizes.hpp> 19 20 #if BOOST_ARCH_X86 && defined(BOOST_ATOMIC_DETAIL_SIZEOF_POINTER) && (BOOST_ATOMIC_DETAIL_SIZEOF_POINTER == 8) 21 22 #include <emmintrin.h> 23 #include <boost/cstdint.hpp> 24 #include <boost/atomic/detail/intptr.hpp> 25 #include <boost/atomic/detail/config.hpp> 26 27 #include <boost/atomic/detail/header.hpp> 28 29 namespace boost { 30 namespace atomics { 31 namespace detail { 32 mm_set1_epiptr(uintptr_t ptr)33BOOST_FORCEINLINE __m128i mm_set1_epiptr(uintptr_t ptr) 34 { 35 #if !defined(_MSC_VER) || _MSC_VER >= 1900 36 return _mm_set1_epi64x(ptr); 37 #else 38 // MSVC up until 14.0 doesn't provide _mm_set1_epi64x 39 uint32_t lo = static_cast< uint32_t >(ptr), hi = static_cast< uint32_t >(ptr >> 32); 40 return _mm_set_epi32(hi, lo, hi, lo); 41 #endif 42 } 43 44 } // namespace detail 45 } // namespace atomics 46 } // namespace boost 47 48 #include <boost/atomic/detail/footer.hpp> 49 50 #endif // BOOST_ARCH_X86 && defined(BOOST_ATOMIC_DETAIL_SIZEOF_POINTER) && (BOOST_ATOMIC_DETAIL_SIZEOF_POINTER == 8) 51 52 #endif // BOOST_ATOMIC_X86_VECTOR_TOOLS_HPP_INCLUDED_ 53