summaryrefslogtreecommitdiff
path: root/generic/include/clc
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
commit1489907d7e02ecba7a9b57e3dd6236c4246a921c (patch)
treeec8bba90e4ee457e2fcf47e16dfa487754802883 /generic/include/clc
parent2e8fa9fcabb2af14f720cfbdc93b54c050b84e66 (diff)
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> git-svn-id: https://llvm.org/svn/llvm-project/libclc/trunk@186691 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'generic/include/clc')
-rw-r--r--generic/include/clc/clc.h1
-rw-r--r--generic/include/clc/integer/upsample.h25
2 files changed, 26 insertions, 0 deletions
diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
index dfdf747..9a2f443 100644
--- a/generic/include/clc/clc.h
+++ b/generic/include/clc/clc.h
@@ -68,6 +68,7 @@
#include <clc/integer/mul24.h>
#include <clc/integer/rotate.h>
#include <clc/integer/sub_sat.h>
+#include <clc/integer/upsample.h>
/* 6.11.2 and 6.11.3 Shared Integer/Math Functions */
#include <clc/shared/clamp.h>
diff --git a/generic/include/clc/integer/upsample.h b/generic/include/clc/integer/upsample.h
new file mode 100644
index 0000000..127debf
--- /dev/null
+++ b/generic/include/clc/integer/upsample.h
@@ -0,0 +1,25 @@
+#define __CLC_UPSAMPLE_DECL(BGENTYPE, GENTYPE, UGENTYPE) \
+ _CLC_OVERLOAD _CLC_DECL BGENTYPE upsample(GENTYPE hi, UGENTYPE lo);
+
+#define __CLC_UPSAMPLE_VEC(BGENTYPE, GENTYPE, UGENTYPE) \
+ __CLC_UPSAMPLE_DECL(BGENTYPE, GENTYPE, UGENTYPE); \
+ __CLC_UPSAMPLE_DECL(BGENTYPE##2, GENTYPE##2, UGENTYPE##2); \
+ __CLC_UPSAMPLE_DECL(BGENTYPE##3, GENTYPE##3, UGENTYPE##3); \
+ __CLC_UPSAMPLE_DECL(BGENTYPE##4, GENTYPE##4, UGENTYPE##4); \
+ __CLC_UPSAMPLE_DECL(BGENTYPE##8, GENTYPE##8, UGENTYPE##8); \
+ __CLC_UPSAMPLE_DECL(BGENTYPE##16, GENTYPE##16, UGENTYPE##16); \
+
+#define __CLC_UPSAMPLE_TYPES() \
+ __CLC_UPSAMPLE_VEC(short, char, uchar) \
+ __CLC_UPSAMPLE_VEC(ushort, uchar, uchar) \
+ __CLC_UPSAMPLE_VEC(int, short, ushort) \
+ __CLC_UPSAMPLE_VEC(uint, ushort, ushort) \
+ __CLC_UPSAMPLE_VEC(long, int, uint) \
+ __CLC_UPSAMPLE_VEC(ulong, uint, uint) \
+
+__CLC_UPSAMPLE_TYPES()
+
+#undef __CLC_UPSAMPLE_TYPES
+#undef __CLC_UPSAMPLE_DECL
+#undef __CLC_UPSAMPLE_VEC
+