diff options
author | Marat Dukhan <maratek@gmail.com> | 2017-02-17 02:57:08 -0500 |
---|---|---|
committer | Marat Dukhan <maratek@gmail.com> | 2017-02-17 02:57:11 -0500 |
commit | 0e58925daeaf88a305b3bb04b18e17831a5b2f78 (patch) | |
tree | fd7a4163db2aa73e532b8f4180969095e3842809 /include | |
parent | 0525a85327e82935fb2333d9f18e520f52fa4154 (diff) | |
download | psimd-0e58925daeaf88a305b3bb04b18e17831a5b2f78.tar.gz |
Vector-pair data types and casts
Diffstat (limited to 'include')
-rw-r--r-- | include/psimd.h | 68 |
1 files changed, 64 insertions, 4 deletions
diff --git a/include/psimd.h b/include/psimd.h index 63b5e98..b0fb7df 100644 --- a/include/psimd.h +++ b/include/psimd.h @@ -54,13 +54,73 @@ #define PSIMD_HAVE_U64 0 #define PSIMD_HAVE_S64 0 - typedef float psimd_f32 __attribute__((vector_size(16), aligned(4))); - typedef uint8_t psimd_u8 __attribute__((vector_size(16), aligned(1))); typedef int8_t psimd_s8 __attribute__((vector_size(16), aligned(1))); - typedef uint16_t psimd_u16 __attribute__((vector_size(16), aligned(2))); + typedef uint8_t psimd_u8 __attribute__((vector_size(16), aligned(1))); typedef int16_t psimd_s16 __attribute__((vector_size(16), aligned(2))); - typedef uint32_t psimd_u32 __attribute__((vector_size(16), aligned(4))); + typedef uint16_t psimd_u16 __attribute__((vector_size(16), aligned(2))); typedef int32_t psimd_s32 __attribute__((vector_size(16), aligned(4))); + typedef uint32_t psimd_u32 __attribute__((vector_size(16), aligned(4))); + typedef float psimd_f32 __attribute__((vector_size(16), aligned(4))); + + typedef struct { + psimd_s8 lo; + psimd_s8 hi; + } psimd_s8x2; + + typedef struct { + psimd_u8 lo; + psimd_u8 hi; + } psimd_u8x2; + + typedef struct { + psimd_s16 lo; + psimd_s16 hi; + } psimd_s16x2; + + typedef struct { + psimd_u16 lo; + psimd_u16 hi; + } psimd_u16x2; + + typedef struct { + psimd_s32 lo; + psimd_s32 hi; + } psimd_s32x2; + + typedef struct { + psimd_u32 lo; + psimd_u32 hi; + } psimd_u32x2; + + typedef struct { + psimd_f32 lo; + psimd_f32 hi; + } psimd_f32x2; + + /* Bit casts */ + PSIMD_INTRINSIC psimd_u32x2 psimd_cast_s32x2_u32x2(psimd_s32x2 v) { + return (psimd_u32x2) { .lo = (psimd_u32) v.lo, .hi = (psimd_u32) v.hi }; + } + + PSIMD_INTRINSIC psimd_f32x2 psimd_cast_s32x2_f32x2(psimd_s32x2 v) { + return (psimd_f32x2) { .lo = (psimd_f32) v.lo, .hi = (psimd_f32) v.hi }; + } + + PSIMD_INTRINSIC psimd_s32x2 psimd_cast_u32x2_s32x2(psimd_u32x2 v) { + return (psimd_s32x2) { .lo = (psimd_s32) v.lo, .hi = (psimd_s32) v.hi }; + } + + PSIMD_INTRINSIC psimd_f32x2 psimd_cast_u32x2_f32x2(psimd_u32x2 v) { + return (psimd_f32x2) { .lo = (psimd_f32) v.lo, .hi = (psimd_f32) v.hi }; + } + + PSIMD_INTRINSIC psimd_s32x2 psimd_cast_f32x2_s32x2(psimd_f32x2 v) { + return (psimd_s32x2) { .lo = (psimd_s32) v.lo, .hi = (psimd_s32) v.hi }; + } + + PSIMD_INTRINSIC psimd_u32x2 psimd_cast_f32x2_u32x2(psimd_f32x2 v) { + return (psimd_u32x2) { .lo = (psimd_u32) v.lo, .hi = (psimd_u32) v.hi }; + } /* Zero-initialization */ PSIMD_INTRINSIC psimd_s8 psimd_zero_s8(void) { |