summaryrefslogtreecommitdiffstats
path: root/libclc/generic/lib/integer
diff options
context:
space:
mode:
authorAaron Watry <awatry@gmail.com>2013-07-19 16:44:37 +0000
committerAaron Watry <awatry@gmail.com>2013-07-19 16:44:37 +0000
commit1769b1fca9c38fd4bb0eae91effdbba89d626723 (patch)
treef543e1b6c68d6bc0b445f1978acbf20dd5496c4f /libclc/generic/lib/integer
parentdd170bd977b3e7aa730e6f247f000206e859d070 (diff)
downloadbcm5719-llvm-1769b1fca9c38fd4bb0eae91effdbba89d626723.tar.gz
bcm5719-llvm-1769b1fca9c38fd4bb0eae91effdbba89d626723.zip
Implement generic upsample()
Reduces all vector upsamples down to its scalar components, so probably not the most efficient thing in the world, but it does what the spec says it needs to do. Another possible implementation would be to convert/cast everything as unsigned if necessary, upsample the input vectors, create the upsampled value, and then cast back to signed if required. Signed-off-by: Aaron Watry <awatry@gmail.com> Reviewed-by: Tom Stellard <thomas.stellard at amd.com> llvm-svn: 186691
Diffstat (limited to 'libclc/generic/lib/integer')
-rw-r--r--libclc/generic/lib/integer/upsample.cl34
1 files changed, 34 insertions, 0 deletions
diff --git a/libclc/generic/lib/integer/upsample.cl b/libclc/generic/lib/integer/upsample.cl
new file mode 100644
index 00000000000..7301cc34aae
--- /dev/null
+++ b/libclc/generic/lib/integer/upsample.cl
@@ -0,0 +1,34 @@
+#include <clc/clc.h>
+
+#define __CLC_UPSAMPLE_IMPL(BGENTYPE, GENTYPE, UGENTYPE, GENSIZE) \
+ _CLC_OVERLOAD _CLC_DECL BGENTYPE upsample(GENTYPE hi, UGENTYPE lo){ \
+ return ((BGENTYPE)hi << GENSIZE) | lo; \
+ } \
+ _CLC_OVERLOAD _CLC_DECL BGENTYPE##2 upsample(GENTYPE##2 hi, UGENTYPE##2 lo){ \
+ return (BGENTYPE##2){upsample(hi.s0, lo.s0), upsample(hi.s1, lo.s1)}; \
+ } \
+ _CLC_OVERLOAD _CLC_DECL BGENTYPE##3 upsample(GENTYPE##3 hi, UGENTYPE##3 lo){ \
+ return (BGENTYPE##3){upsample(hi.s0, lo.s0), upsample(hi.s1, lo.s1), upsample(hi.s2, lo.s2)}; \
+ } \
+ _CLC_OVERLOAD _CLC_DECL BGENTYPE##4 upsample(GENTYPE##4 hi, UGENTYPE##4 lo){ \
+ return (BGENTYPE##4){upsample(hi.lo, lo.lo), upsample(hi.hi, lo.hi)}; \
+ } \
+ _CLC_OVERLOAD _CLC_DECL BGENTYPE##8 upsample(GENTYPE##8 hi, UGENTYPE##8 lo){ \
+ return (BGENTYPE##8){upsample(hi.lo, lo.lo), upsample(hi.hi, lo.hi)}; \
+ } \
+ _CLC_OVERLOAD _CLC_DECL BGENTYPE##16 upsample(GENTYPE##16 hi, UGENTYPE##16 lo){ \
+ return (BGENTYPE##16){upsample(hi.lo, lo.lo), upsample(hi.hi, lo.hi)}; \
+ } \
+
+#define __CLC_UPSAMPLE_TYPES() \
+ __CLC_UPSAMPLE_IMPL(short, char, uchar, 8) \
+ __CLC_UPSAMPLE_IMPL(ushort, uchar, uchar, 8) \
+ __CLC_UPSAMPLE_IMPL(int, short, ushort, 16) \
+ __CLC_UPSAMPLE_IMPL(uint, ushort, ushort, 16) \
+ __CLC_UPSAMPLE_IMPL(long, int, uint, 32) \
+ __CLC_UPSAMPLE_IMPL(ulong, uint, uint, 32) \
+
+__CLC_UPSAMPLE_TYPES()
+
+#undef __CLC_UPSAMPLE_TYPES
+#undef __CLC_UPSAMPLE_IMPL
OpenPOWER on IntegriCloud