38 #ifndef included_vector_altivec_h 39 #define included_vector_altivec_h 42 #define _(t,n,ti,fi,tr,fr) \ 43 always_inline t##x##n t##x##n##_splat (t v) \ 44 { return (t##x##n) __builtin_altivec_##fi ((ti) v); } \ 46 always_inline t##x##n t##x##n##_splat_word (t##x##n x, int word_index) \ 47 { return (t##x##n) __builtin_altivec_##fr ((tr) x, word_index); } 49 #define u16x8_splat(i) ((u16x8) __builtin_altivec_vspltish (i)) 50 #define i16x8_splat(i) ((i16x8) __builtin_altivec_vspltish (i)) 51 #define u32x4_splat(i) ((u32x4) __builtin_altivec_vspltisw (i)) 52 #define i32x4_splat(i) ((i32x4) __builtin_altivec_vspltisw (i)) 54 #define u16x8_splat_word(x,i) ((u16x8) __builtin_altivec_vsplth ((i16x8) (x), (i))) 55 #define i16x8_splat_word(x,i) ((i16x8) __builtin_altivec_vsplth ((i16x8) (x), (i))) 56 #define u32x4_splat_word(x,i) ((u32x4) __builtin_altivec_vspltw ((i32x4) (x), (i))) 57 #define i32x4_splat_word(x,i) ((i32x4) __builtin_altivec_vspltw ((i32x4) (x), (i))) 62 #define _(t,ti,lr,f) \ 63 always_inline t t##_##lr (t x, t y) \ 64 { return (t) __builtin_altivec_##f ((ti) x, (ti) y); } \ 66 always_inline t t##_i##lr (t x, int i) \ 69 return t##_##lr (x, j); \ 85 #define _(t,it,lr,f) \ 86 always_inline t t##_word_shift_##lr (t x, int n_words) \ 88 i32x4 n_bits = {0,0,0,n_words * BITS (it)}; \ 89 return (t) __builtin_altivec_##f ((i32x4) x, n_bits); \ 95 _ (i32x4, i32, right, vsro)
96 _ (u16x8,
u16, left, vslo)
98 _ (u16x8, u16, right, vsro)
99 _ (i16x8, i16, right, vsro)
112 #define _(t,it,lh,f) \ 113 always_inline t t##_interleave_##lh (t x, t y) \ 114 { return (t) __builtin_altivec_##f ((it) x, (it) y); } 116 _ (u32x4, i32x4,
lo, vmrglw)
117 _ (i32x4, i32x4,
lo, vmrglw)
118 _ (u16x8, i16x8, lo, vmrglh)
119 _ (i16x8, i16x8, lo, vmrglh)
120 _ (u32x4, i32x4,
hi, vmrghw)
121 _ (i32x4, i32x4, hi, vmrghw)
122 _ (u16x8, i16x8, hi, vmrghh)
123 _ (i16x8, i16x8, hi, vmrghh)
130 always_inline void t##_store_unaligned (t x, t * a) \ 131 { clib_mem_unaligned (a, t) = x; } \ 132 always_inline t t##_load_unaligned (t * a) \ 133 { return clib_mem_unaligned (a, t); } 147 #define _signed_binop(n,m,f,g) \ 149 always_inline u##n##x##m \ 150 u##n##x##m##_##f (u##n##x##m x, u##n##x##m y) \ 151 { return (u##n##x##m) __builtin_altivec_##g ((i##n##x##m) x, (i##n##x##m) y); } \ 154 always_inline i##n##x##m \ 155 i##n##x##m##_##f (i##n##x##m x, i##n##x##m y) \ 156 { return (i##n##x##m) __builtin_altivec_##g ((i##n##x##m) x, (i##n##x##m) y); } 160 _signed_binop (32, 4,
is_equal, vcmpequw)
179 u32x4 tmp = { 0x000f, 0x00f0, 0x0f00, 0xf000, };
always_inline u32x4 u32x4_is_equal(u32x4 x, u32x4 y)
always_inline u32x4 u32x4_is_zero(u32x4 x)
always_inline u32 u32x4_zero_byte_mask(u32x4 x)
always_inline u16x8 u16x8_is_zero(u16x8 x)
add_epi add_epi sub_epi sub_epi adds_epu subs_epu i16x8 y
always_inline uword rotate_left(uword x, uword i)
#define u32x4_word_shift_right(a, n)
always_inline u16x8 u16x8_is_equal(u16x8 x, u16x8 y)
vslo vsro vslo vsro always_inline u32 u32x4_get0(u32x4 x)