Add all(igentype) builtin

Signed-off-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Tom Stellard <tom@stellard.net>
llvm-svn: 211045
This commit is contained in:
Aaron Watry 2014-06-16 19:53:54 +00:00
parent c164fc384b
commit e167db9238
4 changed files with 47 additions and 0 deletions
libclc/generic
include/clc
clc.h
relational
lib
SOURCES
relational

View File

@ -102,6 +102,7 @@
#include <clc/geometric/normalize.h>
/* 6.11.6 Relational Functions */
#include <clc/relational/all.h>
#include <clc/relational/any.h>
#include <clc/relational/bitselect.h>
#include <clc/relational/isnan.h>

View File

@ -0,0 +1,16 @@
#define _CLC_ALL_DECL(TYPE) \
_CLC_OVERLOAD _CLC_DECL int all(TYPE v);
#define _CLC_VECTOR_ALL_DECL(TYPE) \
_CLC_ALL_DECL(TYPE) \
_CLC_ALL_DECL(TYPE##2) \
_CLC_ALL_DECL(TYPE##3) \
_CLC_ALL_DECL(TYPE##4) \
_CLC_ALL_DECL(TYPE##8) \
_CLC_ALL_DECL(TYPE##16)
_CLC_VECTOR_ALL_DECL(char)
_CLC_VECTOR_ALL_DECL(short)
_CLC_VECTOR_ALL_DECL(int)
_CLC_VECTOR_ALL_DECL(long)

View File

@ -35,6 +35,7 @@ math/mad.cl
math/clc_nextafter.cl
math/nextafter.cl
math/sincos.cl
relational/all.cl
relational/any.cl
relational/isnan.cl
shared/clamp.cl

View File

@ -0,0 +1,29 @@
#include <clc/clc.h>
#define _CLC_ALL(v) (((v) >> ((sizeof(v) * 8) - 1)) & 0x1)
#define _CLC_ALL2(v) (_CLC_ALL((v).s0) & _CLC_ALL((v).s1))
#define _CLC_ALL3(v) (_CLC_ALL2((v)) & _CLC_ALL((v).s2))
#define _CLC_ALL4(v) (_CLC_ALL3((v)) & _CLC_ALL((v).s3))
#define _CLC_ALL8(v) (_CLC_ALL4((v)) & _CLC_ALL((v).s4) & _CLC_ALL((v).s5) \
& _CLC_ALL((v).s6) & _CLC_ALL((v).s7))
#define _CLC_ALL16(v) (_CLC_ALL8((v)) & _CLC_ALL((v).s8) & _CLC_ALL((v).s9) \
& _CLC_ALL((v).sA) & _CLC_ALL((v).sB) \
& _CLC_ALL((v).sC) & _CLC_ALL((v).sD) \
& _CLC_ALL((v).sE) & _CLC_ALL((v).sf))
#define ALL_ID(TYPE) \
_CLC_OVERLOAD _CLC_DEF int all(TYPE v)
#define ALL_VECTORIZE(TYPE) \
ALL_ID(TYPE) { return _CLC_ALL(v); } \
ALL_ID(TYPE##2) { return _CLC_ALL2(v); } \
ALL_ID(TYPE##3) { return _CLC_ALL3(v); } \
ALL_ID(TYPE##4) { return _CLC_ALL4(v); } \
ALL_ID(TYPE##8) { return _CLC_ALL8(v); } \
ALL_ID(TYPE##16) { return _CLC_ALL16(v); }
ALL_VECTORIZE(char)
ALL_VECTORIZE(short)
ALL_VECTORIZE(int)
ALL_VECTORIZE(long)