summaryrefslogtreecommitdiffstats
path: root/vec_builtin.h
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@gmail.com>2013-11-26 16:57:36 -0500
committerErik Schnetter <schnetter@gmail.com>2013-11-26 16:57:36 -0500
commit80736b6e3754af935d3a86afc9ad9bd0103b5e51 (patch)
tree66a110aeb3ff6a60a503544b14bccd3698bb79eb /vec_builtin.h
parent2ae406aa1d651f65d000ce851d8b2c76fcb0ddc8 (diff)
downloadvecmathlib-80736b6e3754af935d3a86afc9ad9bd0103b5e51.zip
vecmathlib-80736b6e3754af935d3a86afc9ad9bd0103b5e51.tar.gz
vec_builtin is only for Clang
Diffstat (limited to 'vec_builtin.h')
-rw-r--r--vec_builtin.h51
1 files changed, 6 insertions, 45 deletions
diff --git a/vec_builtin.h b/vec_builtin.h
index 4f8ad63..1933468 100644
--- a/vec_builtin.h
+++ b/vec_builtin.h
@@ -18,12 +18,6 @@
-#ifndef __has_builtin
-# define __has_builtin(x) 0 // Compatibility with non-clang compilers
-#endif
-
-
-
namespace vecmathlib {
template<typename T, int N> struct boolbuiltinvec;
@@ -41,8 +35,7 @@ namespace vecmathlib {
static const int size = N;
typedef bool scalar_t;
- // typedef int_t bvector_t __attribute__((__ext_vector_type__(N)));
- typedef int_t bvector_t __attribute__((__vector_size__(N * sizeof(T))));
+ typedef int_t bvector_t __attribute__((__ext_vector_type__(N)));
static const int alignment = sizeof(bvector_t);
static_assert(size * sizeof(real_t) == sizeof(bvector_t),
@@ -137,10 +130,8 @@ namespace vecmathlib {
static const int size = N;
typedef int_t scalar_t;
- // typedef int_t ivector_t __attribute__((__ext_vector_type__(N)));
- // typedef uint_t uvector_t __attribute__((__ext_vector_type__(N)));
- typedef int_t ivector_t __attribute__((__vector_size__(N * sizeof(T))));
- typedef uint_t uvector_t __attribute__((__vector_size__(N * sizeof(T))));
+ typedef int_t ivector_t __attribute__((__ext_vector_type__(N)));
+ typedef uint_t uvector_t __attribute__((__ext_vector_type__(N)));
static const int alignment = sizeof(ivector_t);
static_assert(size * sizeof(real_t) == sizeof(ivector_t),
@@ -327,8 +318,7 @@ namespace vecmathlib {
static const int size = N;
typedef real_t scalar_t;
- // typedef real_t vector_t __attribute__((__ext_vector_type__(N)));
- typedef real_t vector_t __attribute__((__vector_size__(N * sizeof(T))));
+ typedef real_t vector_t __attribute__((__ext_vector_type__(N)));
static const int alignment = sizeof(vector_t);
static_assert(size * sizeof(real_t) == sizeof(vector_t),
@@ -345,37 +335,8 @@ namespace vecmathlib {
}
return name_.c_str();
}
+ void barrier() { volatile vector_t x __attribute__((__unused__)) = v; }
#endif
- void barrier() {
-#if defined __GNUC__ && !defined __clang__ && !defined __ICC
- // GCC crashes when +X is used as constraint
-# if defined __SSE2__
- for (int d=0; d<size; ++d) __asm__("": "+x"(v[d]));
-# elif defined __PPC64__ // maybe also __PPC__
- for (int d=0; d<size; ++d) __asm__("": "+f"(v[d]));
-# elif defined __arm__
- for (int d=0; d<size; ++d) __asm__("": "+w"(v[d]));
-# else
-# error "Floating point barrier undefined on this architecture"
-# endif
-#elif defined __clang__
- for (int d=0; d<size; ++d) {
- real_t tmp = v[d];
- __asm__("": "+X"(tmp));
- v[d] = tmp;
- }
-#elif defined __ICC
- for (int d=0; d<size; ++d) {
- real_t tmp = v[d];
- __asm__("": "+X"(tmp));
- v[d] = tmp;
- }
-#elif defined __IBMCPP__
- for (int d=0; d<size; ++d) __asm__("": "+f"(v[d]));
-#else
-# error "Floating point barrier undefined on this architecture"
-#endif
- }
typedef boolbuiltinvec<real_t, size> boolvec_t;
typedef intbuiltinvec<real_t, size> intvec_t;
@@ -467,7 +428,7 @@ namespace vecmathlib {
static realvec_t loada(const real_t* p)
{
VML_ASSERT(intptr_t(p) % alignment == 0);
-#if defined __gcc__ || __has_builtin(__builtin_assume_aligned)
+#if __has_builtin(__builtin_assume_aligned)
p = (const real_t*)__builtin_assume_aligned(p, sizeof(realvec_t));
#endif
return mkvec(*(const vector_t*)p);
OpenPOWER on IntegriCloud