#ifndef _VECTOR_H #define _VECTOR_H #ifdef __cplusplus extern "C" { #endif #include #include #include #include #include #include #define _VECTOR_SIZE 16 // Vector128 int 8 typedef uint8_t v8_u128n __attribute__((vector_size(_VECTOR_SIZE))); typedef int8_t v8_i128n __attribute__((vector_size(_VECTOR_SIZE))); // Vector128 int 16 typedef uint16_t v16_u128n __attribute__((vector_size(_VECTOR_SIZE))); typedef int16_t v16_i128n __attribute__((vector_size(_VECTOR_SIZE))); // Vector128 int 32 typedef uint32_t v32_u128n __attribute__((vector_size(_VECTOR_SIZE))); typedef int32_t v32_i128n __attribute__((vector_size(_VECTOR_SIZE))); // Vector128 int 64 typedef uint64_t v64_u128n __attribute__((vector_size(_VECTOR_SIZE))); typedef int64_t v64_i128n __attribute__((vector_size(_VECTOR_SIZE))); typedef union v128 { // Intrinsics __m128i mm; // long int __m128d mmd; // double __m128 mmf; // float //XXX: Should we have the halfs // Vectorised integers union { v8_u128n u8; v8_i128n i8; v16_u128n u16; v16_i128n i16; v32_u128n u32; v32_i128n i32; v64_u128n u64; v64_i128n i64; } as; // Native 128 bit integers unsigned __int128 u128; signed __int128 i128; // Raw bytes uint8_t bytes[_VECTOR_SIZE]; } v128_t; #ifdef __cplusplus } static_assert(sizeof(union v128)==_VECTOR_SIZE, "invalid vector size"); static_assert(alignof(union v128)==alignof(__m128i), "invalid vector alignment"); #else _Static_assert(sizeof(union v128)==_VECTOR_SIZE, "invalid vector size"); _Static_assert(_Alignof(union v128)==_Alignof(__m128i), "invalid vector alignment"); #endif #endif /* _VECTOR_H */