28 #ifndef VC_COMMON_TYPES_H_ 29 #define VC_COMMON_TYPES_H_ 31 #ifdef Vc_CHECK_ALIGNMENT 36 #include "../global.h" 37 #include "../traits/type_traits.h" 38 #include "permutation.h" 40 namespace Vc_VERSIONED_NAMESPACE
66 struct VectorSpecialInitializerZero {};
70 struct VectorSpecialInitializerOne {};
74 struct VectorSpecialInitializerIndexesFromZero {};
80 constexpr VectorSpecialInitializerZero
Zero = {};
85 constexpr VectorSpecialInitializerOne
One = {};
95 template<
typename T>
struct MayAliasImpl {
97 #pragma GCC diagnostic push 98 #pragma GCC diagnostic ignored "-Wattributes" 100 typedef T type Vc_MAY_ALIAS;
102 #pragma GCC diagnostic pop 114 template <
typename T>
using MayAlias [[gnu::may_alias]] = T;
116 template <
typename T>
using MayAlias =
typename Detail::MayAliasImpl<T>::type;
119 template <
class To,
class From> MayAlias<To> &aliasing_cast(From &x)
121 return *
reinterpret_cast<MayAlias<To> *
>(&x);
123 template <
class To,
class From>
const MayAlias<To> &aliasing_cast(
const From &x)
125 return *
reinterpret_cast<const MayAlias<To> *
>(&x);
128 template <
class To,
class From> MayAlias<To> *aliasing_cast(From *x)
130 return reinterpret_cast<MayAlias<To> *
>(x);
132 template <
class To,
class From>
const MayAlias<To> *aliasing_cast(
const From *x)
134 return reinterpret_cast<const MayAlias<To> *
>(x);
143 enum class Operator : char {
185 template <
typename T, std::
size_t N>
struct array;
222 #ifndef Vc_CHECK_ALIGNMENT 223 template<
typename _T>
static Vc_ALWAYS_INLINE
void assertCorrectAlignment(
const _T *){}
225 template<
typename _T>
static Vc_ALWAYS_INLINE
void assertCorrectAlignment(
const _T *ptr)
227 const size_t s =
alignof(_T);
228 if((reinterpret_cast<size_t>(ptr) & ((s ^ (s & (s - 1))) - 1)) != 0) {
229 fprintf(stderr,
"A vector with incorrect alignment has just been created. Look at the stacktrace to find the guilty object.\n");
238 template <
typename T, std::
size_t Pieces, std::
size_t Index>
struct Segment;
246 template<
size_t StructSize>
class SuccessiveEntries
251 using size_type = unsigned;
253 using size_type = size_t;
255 const size_type m_first;
258 typedef SuccessiveEntries AsArg;
259 Vc_INTRINSIC SuccessiveEntries(size_type first) : m_first(first) {}
260 Vc_INTRINSIC Vc_PURE size_type operator[](size_type offset)
const 262 return m_first + offset * StructSize;
264 Vc_INTRINSIC Vc_PURE size_type data()
const {
return m_first; }
265 Vc_INTRINSIC Vc_PURE SuccessiveEntries
operator+(
const SuccessiveEntries &rhs)
const 267 return SuccessiveEntries(m_first + rhs.m_first);
269 Vc_INTRINSIC Vc_PURE SuccessiveEntries
operator*(
const SuccessiveEntries &rhs)
const 271 return SuccessiveEntries(m_first * rhs.m_first);
273 Vc_INTRINSIC Vc_PURE SuccessiveEntries
operator<<(size_type x)
const 275 return {m_first << x};
278 friend Vc_INTRINSIC SuccessiveEntries &internal_data(SuccessiveEntries &x)
282 friend Vc_INTRINSIC
const SuccessiveEntries &internal_data(
const SuccessiveEntries &x)
289 template <std::
size_t alignment>
290 Vc_INTRINSIC_L
void *aligned_malloc(std::size_t n) Vc_INTRINSIC_R;
291 Vc_ALWAYS_INLINE_L
void free(
void *p) Vc_ALWAYS_INLINE_R;
296 template <
typename Mask,
typename T,
typename U>
297 using enable_if_mask_converts_implicitly =
298 enable_if<(!std::is_same<Mask, Traits::decay<U>>::value &&
300 Traits::is_implicit_cast_allowed_mask<
301 Traits::entry_type_of<typename Traits::decay<U>::Vector>, T>::value)>;
305 template <
typename T,
typename U>
306 using enable_if_mask_converts_explicitly = enable_if<(
309 !Traits::is_implicit_cast_allowed_mask<
310 Traits::entry_type_of<typename Traits::decay<U>::Vector>, T>::value))>;
315 template <
typename T>
using WidthT = std::integral_constant<std::size_t, sizeof(T)>;
318 template <std::
size_t Bytes>
class MaskBool;
321 template <
typename T,
typename IndexVector,
typename Scale,
bool>
322 class SubscriptOperation;
331 template <
typename T,
typename IndexVector>
struct GatherArguments
333 const IndexVector indexes;
334 const T *
const address;
344 template <
typename T,
typename IndexVector>
struct ScatterArguments
346 const IndexVector indexes;
353 template <
typename I, I Begin, I End,
typename F>
354 Vc_INTRINSIC enable_if<(Begin >= End),
void> unrolled_loop(F &&)
363 template <
typename I, I Begin, I End,
typename F>
364 Vc_INTRINSIC Vc_FLATTEN enable_if<(Begin < End), void> unrolled_loop(F &&f)
367 unrolled_loop<I, Begin + 1, End>(f);
374 template <std::
size_t Size,
typename F> Vc_INTRINSIC
void for_all_vector_entries(F &&f)
376 unrolled_loop<std::size_t, 0u, Size>(std::forward<F>(f));
383 template <
class T, std::
size_t Size = sizeof(T), std::
size_t Alignment = alignof(T)>
384 struct ensure_alignment_equals_sizeof {
385 Vc_ALIGNED_TYPEDEF(Size, T, type);
387 template <
class T, std::
size_t Size>
388 struct ensure_alignment_equals_sizeof<T, Size, Size> {
397 #include "memoryfwd.h" 399 #endif // VC_COMMON_TYPES_H_ signed char schar
signed char shorthand
void free(T *p)
Frees memory that was allocated with Vc::malloc.
unsigned char uchar
unsigned char shorthand
unsigned int uint
unsigned int shorthand
unsigned long long ullong
unsigned long long shorthand
constexpr VectorSpecialInitializerIndexesFromZero IndexesFromZero
The special object Vc::IndexesFromZero can be used to construct Vector objects initialized to values ...
std::ostream & operator<<(std::ostream &out, const Vc::Vector< T, Abi > &v)
Prints the contents of a vector into a stream object.
result_vector_type< L, R > operator*(L &&lhs, R &&rhs)
Applies * component-wise and concurrently.
Identifies any possible SimdMaskArray<T, N> type (independent of const/volatile or reference) ...
long long llong
long long shorthand
result_vector_type< L, R > operator+(L &&lhs, R &&rhs)
Applies + component-wise and concurrently.
unsigned long ulong
unsigned long shorthand
unsigned short ushort
unsigned short shorthand
constexpr VectorSpecialInitializerZero Zero
The special object Vc::Zero can be used to construct Vector and Mask objects initialized to zero/fals...
constexpr VectorSpecialInitializerOne One
The special object Vc::One can be used to construct Vector and Mask objects initialized to one/true...
Identifies any SIMD mask type (independent of implementation or whether it's SimdMaskArray<T, N>).
This is std::array with additional subscript operators supporting gather and scatter operations...