summaryrefslogtreecommitdiffstats
path: root/libclc/generic/lib/shared
diff options
context:
space:
mode:
authorJan Vesely <jan.vesely@rutgers.edu>2016-08-17 20:02:11 +0000
committerJan Vesely <jan.vesely@rutgers.edu>2016-08-17 20:02:11 +0000
commitad8672727cc7dac8d169cd7b10ea348ba5bcf449 (patch)
treebbb75b73d2ce5c00cfda2e5a6a832a945301e5ca /libclc/generic/lib/shared
parent8b58bdfe6fee0f9e32fbf4ee78427806338e4f1b (diff)
downloadbcm5719-llvm-ad8672727cc7dac8d169cd7b10ea348ba5bcf449.tar.gz
bcm5719-llvm-ad8672727cc7dac8d169cd7b10ea348ba5bcf449.zip
Implement vstore_half{,n}
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu> llvm-svn: 278962
Diffstat (limited to 'libclc/generic/lib/shared')
-rw-r--r--libclc/generic/lib/shared/vstore.cl32
-rw-r--r--libclc/generic/lib/shared/vstore_half.inc10
2 files changed, 42 insertions, 0 deletions
diff --git a/libclc/generic/lib/shared/vstore.cl b/libclc/generic/lib/shared/vstore.cl
index 4777b7ea76a..ebc9446262f 100644
--- a/libclc/generic/lib/shared/vstore.cl
+++ b/libclc/generic/lib/shared/vstore.cl
@@ -50,3 +50,35 @@ VSTORE_TYPES()
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
VSTORE_ADDR_SPACES(double)
#endif
+
+/* vstore_half are legal even without cl_khr_fp16 */
+
+#define VEC_STORE1(val) mem[offset++] = val;
+#define VEC_STORE2(val) \
+ VEC_STORE1(val.lo) \
+ VEC_STORE1(val.hi)
+#define VEC_STORE3(val) \
+ VEC_STORE1(val.s0) \
+ VEC_STORE1(val.s1) \
+ VEC_STORE1(val.s2)
+#define VEC_STORE4(val) \
+ VEC_STORE2(val.lo) \
+ VEC_STORE2(val.hi)
+#define VEC_STORE8(val) \
+ VEC_STORE4(val.lo) \
+ VEC_STORE4(val.hi)
+#define VEC_STORE16(val) \
+ VEC_STORE8(val.lo) \
+ VEC_STORE8(val.hi)
+
+#define __FUNC(SUFFIX, VEC_SIZE, TYPE, AS) \
+ _CLC_OVERLOAD _CLC_DEF void vstore_half##SUFFIX(TYPE vec, size_t offset, AS half *mem) { \
+ offset *= VEC_SIZE; \
+ VEC_STORE##VEC_SIZE(vec) \
+ }
+
+#define FUNC(SUFFIX, VEC_SIZE, TYPE, AS) __FUNC(SUFFIX, VEC_SIZE, TYPE, AS)
+
+#define __CLC_BODY "vstore_half.inc"
+#include <clc/math/gentype.inc>
+
diff --git a/libclc/generic/lib/shared/vstore_half.inc b/libclc/generic/lib/shared/vstore_half.inc
new file mode 100644
index 00000000000..8ed03a0808a
--- /dev/null
+++ b/libclc/generic/lib/shared/vstore_half.inc
@@ -0,0 +1,10 @@
+
+#ifdef __CLC_VECSIZE
+ FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_GENTYPE, __private);
+ FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_GENTYPE, __local);
+ FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_GENTYPE, __global);
+#else
+ FUNC(, 1, __CLC_GENTYPE, __private);
+ FUNC(, 1, __CLC_GENTYPE, __local);
+ FUNC(, 1, __CLC_GENTYPE, __global);
+#endif
OpenPOWER on IntegriCloud