Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:51:09

0001 #ifndef BOOST_QVM_VEC_TRAITS_GNUC_HPP_INCLUDED
0002 #define BOOST_QVM_VEC_TRAITS_GNUC_HPP_INCLUDED
0003 
0004 // Copyright 2008-2022 Emil Dotchevski and Reverge Studios, Inc.
0005 
0006 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0007 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0008 
0009 #if defined(__GNUC__) && defined(__SSE2__)
0010 
0011 #include <boost/qvm/config.hpp>
0012 #include <boost/qvm/assert.hpp>
0013 #include <boost/qvm/static_assert.hpp>
0014 
0015 namespace boost { namespace qvm {
0016 
0017 namespace
0018 qvm_detail
0019     {
0020     template <class V, class T, int D>
0021     struct
0022     vec_traits_gnuc_impl
0023         {
0024         typedef T scalar_type;
0025         static int const dim=D;
0026 
0027         template <int I>
0028         static
0029         BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0030         scalar_type
0031         read_element( V const & x )
0032             {
0033             BOOST_QVM_STATIC_ASSERT(I>=0);
0034             BOOST_QVM_STATIC_ASSERT(I<dim);
0035             return x[I];
0036             }
0037 
0038         template <int I>
0039         static
0040         BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0041         void
0042         write_element( V & x, scalar_type s )
0043             {
0044             BOOST_QVM_STATIC_ASSERT(I>=0);
0045             BOOST_QVM_STATIC_ASSERT(I<dim);
0046             x[I] = s;
0047             }
0048 
0049         static
0050         BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0051         scalar_type
0052         read_element_idx( int i, V const & x )
0053             {
0054             BOOST_QVM_ASSERT(i>=0);
0055             BOOST_QVM_ASSERT(i<dim);
0056             return x[i];
0057             }
0058 
0059         static
0060         BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0061         void
0062         write_element_idx( int i, V & x, scalar_type s )
0063             {
0064             BOOST_QVM_ASSERT(i>=0);
0065             BOOST_QVM_ASSERT(i<dim);
0066             x[i] = s;
0067             }
0068         };
0069     }
0070 
0071 template <class> struct vec_traits;
0072 template <class> struct is_vec;
0073 
0074 #define BOOST_QVM_GNUC_VEC_TYPE(T,D)\
0075     template <>\
0076     struct\
0077     vec_traits<T __attribute__((vector_size(sizeof(T)*D)))>:\
0078         qvm_detail::vec_traits_gnuc_impl<T __attribute__((vector_size(sizeof(T)*D))),T,D>\
0079         {\
0080         };\
0081     template <>\
0082     struct\
0083     is_vec<T __attribute__((vector_size(sizeof(T)*D)))>\
0084         {\
0085         enum { value = true };\
0086         };
0087 
0088 BOOST_QVM_GNUC_VEC_TYPE(float,2)
0089 BOOST_QVM_GNUC_VEC_TYPE(float,4)
0090 BOOST_QVM_GNUC_VEC_TYPE(double,2)
0091 BOOST_QVM_GNUC_VEC_TYPE(double,4)
0092 
0093 #undef BOOST_QVM_GNUC_VEC_TYPE
0094 
0095 } }
0096 
0097 #endif
0098 
0099 #endif