summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@gmail.com>2013-09-03 02:15:25 +0000
committerErik Schnetter <schnetter@gmail.com>2013-09-03 02:15:25 +0000
commitd9e3a34205c52318fc05faf6daa22394d5a69755 (patch)
treeaa398856f3194e02e302dea32aa765c23d24fe15
parent8245368f1c3d31bffacd6265b5a1ecfd243a0b7e (diff)
downloadvecmathlib-d9e3a34205c52318fc05faf6daa22394d5a69755.zip
vecmathlib-d9e3a34205c52318fc05faf6daa22394d5a69755.tar.gz
Support Altivec with Clang
-rw-r--r--vec_altivec_float4.h37
1 files changed, 34 insertions, 3 deletions
diff --git a/vec_altivec_float4.h b/vec_altivec_float4.h
index 6ee884c..55f3830 100644
--- a/vec_altivec_float4.h
+++ b/vec_altivec_float4.h
@@ -186,7 +186,15 @@ namespace vecmathlib {
intvec operator+() const { return *this; }
- intvec operator-() const { return vec_neg(v); }
+ intvec operator-() const
+ {
+#if defined __xlC_
+ return vec_neg(v);
+#else
+ // vec_neg does not exist in clang
+ return IV(I(0)) - *this;
+#endif
+ }
intvec operator+(intvec x) const { return vec_add(v, x.v); }
intvec operator-(intvec x) const { return vec_sub(v, x.v); }
@@ -408,12 +416,28 @@ namespace vecmathlib {
intvec_t as_int() const { return (__vector signed int) v; }
- intvec_t convert_int() const { return vec_cts(v, 0); }
+ intvec_t convert_int() const
+ {
+#if defined __xlC__
+ return vec_cts(v, 0);
+#else
+ // vec_cts leads to an ICE in clang
+ return MF::vml_convert_int(*this);
+#endif
+ }
realvec operator+() const { return *this; }
- realvec operator-() const { return vec_neg(v); }
+ realvec operator-() const
+ {
+#if defined __xlC_
+ return vec_neg(v);
+#else
+ // vec_neg does not exist in clang
+ return RV(0.0) - *this;
+#endif
+ }
realvec operator+(realvec x) const { return vec_add(v, x.v); }
realvec operator-(realvec x) const { return vec_sub(v, x.v); }
@@ -421,6 +445,7 @@ namespace vecmathlib {
#if defined __xlC__
return vec_mul(v, x.v);
#else
+ // vec_mul does not exist in clang
return vec_madd(v, x.v, RV(0.0).v);
#endif
}
@@ -428,6 +453,7 @@ namespace vecmathlib {
#if defined __xlC__
return vec_div(v, x.v);
#else
+ // vec_div does not exist in clang
return *this * x.rcp();
#endif
}
@@ -601,7 +627,12 @@ namespace vecmathlib {
inline realvec<float,4> intvec<float,4>::convert_float() const
{
+#if defined __xlC__
return vec_ctf(v, 0);
+#else
+ // vec_ctf leads to an ICE in clang
+ return MF::vml_convert_float(*this);
+#endif
}
inline intvec<float,4> intvec<float,4>::popcount() const
OpenPOWER on IntegriCloud