diff options
author | Erik Schnetter <schnetter@gmail.com> | 2013-09-02 13:49:07 -0400 |
---|---|---|
committer | Erik Schnetter <schnetter@gmail.com> | 2013-09-02 13:49:07 -0400 |
commit | b04d80fa2574227344d67e534ee32f0801352ccd (patch) | |
tree | 5442f369858dd3767a54da474b31b49d1c90d7a6 | |
parent | acae301f6613c57b120769717f11db05f2f7284c (diff) | |
download | vecmathlib-b04d80fa2574227344d67e534ee32f0801352ccd.zip vecmathlib-b04d80fa2574227344d67e534ee32f0801352ccd.tar.gz |
Implement new integer functions for NEON
-rw-r--r-- | vec_neon_float2.h | 38 | ||||
-rw-r--r-- | vec_neon_float4.h | 40 |
2 files changed, 65 insertions, 13 deletions
diff --git a/vec_neon_float2.h b/vec_neon_float2.h index 84d9e4e..b5f874f 100644 --- a/vec_neon_float2.h +++ b/vec_neon_float2.h @@ -206,9 +206,15 @@ namespace vecmathlib { intvec& operator|=(intvec const& x) { return *this=*this|x; } intvec& operator^=(intvec const& x) { return *this=*this^x; } + intvec_t bitifthen(intvec_t x, intvec_t y) const + { + return vbsl_s32(vreinterpret_u32_s32(v), x.v, y.v) + } + - intvec lsr(int_t n) const { return lsr(IV(n)); } + intvec_t lsr(int_t n) const { return lsr(IV(n)); } + intvec_t rotate(int_t n) const; intvec operator>>(int_t n) const { return *this >> IV(n); } intvec operator<<(int_t n) const { return *this << IV(n); } intvec& operator>>=(int_t n) { return *this=*this>>n; } @@ -218,6 +224,7 @@ namespace vecmathlib { { return vreinterpret_s32_u32(vshl_u32(vreinterpret_u32_s32(v), (-n).v)); } + intvec_t rotate(intvec_t n) const; intvec operator>>(intvec n) const { return vshl_s32(v, (-n).v); @@ -229,20 +236,29 @@ namespace vecmathlib { intvec& operator>>=(intvec n) { return *this=*this>>n; } intvec& operator<<=(intvec n) { return *this=*this<<n; } - - - boolvec_t isignbit() const + intvec_t clz() const { return vclz_s32(v); } + intvec_t popcount() const { - //return *this < IV(I(0)); - return intvec(vshr_n_s32(v, FP::bits-1)).as_bool(); + return vpaddl_s16(vpaddl_s8(vcnt_s8(vreinterpret_s8_s32(v)))); } + + boolvec_t operator==(intvec const& x) const { return vceq_s32(v, x.v); } boolvec_t operator!=(intvec const& x) const { return !(*this == x); } boolvec_t operator<(intvec const& x) const { return vclt_s32(v, x.v); } boolvec_t operator<=(intvec const& x) const { return vcle_s32(v, x.v); } boolvec_t operator>(intvec const& x) const { return vcgt_s32(v, x.v); } boolvec_t operator>=(intvec const& x) const { return vcge_s32(v, x.v); } + + intvec_t abs() const { return vabs_s32(v); } + boolvec_t isignbit() const + { + //return *this < IV(I(0)); + return intvec(vshr_n_s32(v, FP::bits-1)).as_bool(); + } + intvec_t max(intvec_t x) const { return vmax_s32(v, x.v); } + intvec_t min(intvec_t x) const { return vmin_s32(v, x.v); } }; @@ -586,6 +602,16 @@ namespace vecmathlib { return vcvt_f32_s32(v); } + inline intvec<float,2> intvec<float,2>::rotate(int_t n) const + { + return MF::vml_rotate(*this, n); + } + + inline intvec<float,2> intvec<float,2>::rotate(intvec_t n) const + { + return MF::vml_rotate(*this, n); + } + } // namespace vecmathlib #endif // #ifndef VEC_NEON_FLOAT2_H diff --git a/vec_neon_float4.h b/vec_neon_float4.h index 122b66a..3944d83 100644 --- a/vec_neon_float4.h +++ b/vec_neon_float4.h @@ -212,18 +212,25 @@ namespace vecmathlib { intvec& operator|=(intvec const& x) { return *this=*this|x; } intvec& operator^=(intvec const& x) { return *this=*this^x; } + intvec_t bitifthen(intvec_t x, intvec_t y) const + { + return vbslq_s32(vreinterpretq_u32_s32(v), x.v, y.v) + } + - intvec lsr(int_t n) const { return lsr(IV(n)); } + intvec_t lsr(int_t n) const { return lsr(IV(n)); } + intvec_t rotate(int_t n) const; intvec operator>>(int_t n) const { return *this >> IV(n); } intvec operator<<(int_t n) const { return *this << IV(n); } intvec& operator>>=(int_t n) { return *this=*this>>n; } intvec& operator<<=(int_t n) { return *this=*this<<n; } - intvec lsr(intvec n) const + intvec_t lsr(intvec_t n) const { return vreinterpretq_s32_u32(vshlq_u32(vreinterpretq_u32_s32(v), (-n).v)); } + intvec_t rotate(intvec_t n) const; intvec operator>>(intvec n) const { return vshlq_s32(v, (-n).v); @@ -235,20 +242,29 @@ namespace vecmathlib { intvec& operator>>=(intvec n) { return *this=*this>>n; } intvec& operator<<=(intvec n) { return *this=*this<<n; } - - - boolvec_t isignbit() const + intvec_t clz() const { return vclzq_s32(v); } + intvec_t popcount() const { - //return *this < IV(I(0)); - return intvec(vshrq_n_s32(v, FP::bits-1)).as_bool(); + return vpaddlq_s16(vpaddlq_s8(vcntq_s8(vreinterpretq_s8_s32(v)))); } + + boolvec_t operator==(intvec const& x) const { return vceqq_s32(v, x.v); } boolvec_t operator!=(intvec const& x) const { return !(*this == x); } boolvec_t operator<(intvec const& x) const { return vcltq_s32(v, x.v); } boolvec_t operator<=(intvec const& x) const { return vcleq_s32(v, x.v); } boolvec_t operator>(intvec const& x) const { return vcgtq_s32(v, x.v); } boolvec_t operator>=(intvec const& x) const { return vcgeq_s32(v, x.v); } + + intvec_t abs() const { return vabsq_s32(v); } + boolvec_t isignbit() const + { + //return *this < IV(I(0)); + return intvec(vshrq_n_s32(v, FP::bits-1)).as_bool(); + } + intvec_t max(intvec_t x) const { return vmaxq_s32(v, x.v); } + intvec_t min(intvec_t x) const { return vminq_s32(v, x.v); } }; @@ -607,6 +623,16 @@ namespace vecmathlib { return vcvtq_f32_s32(v); } + inline intvec<float,4> intvec<float,4>::rotate(int_t n) const + { + return MF::vml_rotate(*this, n); + } + + inline intvec<float,4> intvec<float,4>::rotate(intvec_t n) const + { + return MF::vml_rotate(*this, n); + } + } // namespace vecmathlib #endif // #ifndef VEC_NEON_FLOAT4_H |