summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Watry <awatry@gmail.com>2013-03-23 12:35:27 -0500
committerAaron Watry <awatry@gmail.com>2013-03-23 12:35:27 -0500
commit6ef0b7b0b6d2e5584086b4b9a9243743b2e0538f (patch)
tree4f241fb060751ab4d3932b743dd79a3aa7942154
parentf0309e286c796ea5c5c90dff16e06a84454e9928 (diff)
libclc: Add stub clz builtin
For scalar int/uint, attempt to use the clz llvm builtin.. for all others return 0 until an actual implementation is finished.
-rw-r--r--generic/include/clc/clc.h1
-rw-r--r--generic/include/clc/integer/clz.h2
-rw-r--r--generic/include/clc/integer/clz.inc1
-rw-r--r--generic/lib/SOURCES1
-rw-r--r--generic/lib/integer/clz.cl4
-rw-r--r--generic/lib/integer/clz.inc9
6 files changed, 18 insertions, 0 deletions
diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
index 72f518a..0d7f105 100644
--- a/generic/include/clc/clc.h
+++ b/generic/include/clc/clc.h
@@ -63,6 +63,7 @@
#include <clc/integer/abs.h>
#include <clc/integer/abs_diff.h>
#include <clc/integer/add_sat.h>
+#include <clc/integer/clz.h>
#include <clc/integer/rotate.h>
#include <clc/integer/sub_sat.h>
diff --git a/generic/include/clc/integer/clz.h b/generic/include/clc/integer/clz.h
new file mode 100644
index 0000000..5708eb4
--- /dev/null
+++ b/generic/include/clc/integer/clz.h
@@ -0,0 +1,2 @@
+#define BODY <clc/integer/clz.inc>
+#include <clc/integer/gentype.inc>
diff --git a/generic/include/clc/integer/clz.inc b/generic/include/clc/integer/clz.inc
new file mode 100644
index 0000000..ac73a31
--- /dev/null
+++ b/generic/include/clc/integer/clz.inc
@@ -0,0 +1 @@
+_CLC_OVERLOAD _CLC_DECL GENTYPE clz(GENTYPE x);
diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES
index 495b3e7..5bb3a11 100644
--- a/generic/lib/SOURCES
+++ b/generic/lib/SOURCES
@@ -8,6 +8,7 @@ integer/abs_diff.cl
integer/add_sat.cl
integer/add_sat.ll
integer/add_sat_impl.ll
+integer/clz.cl
integer/rotate.cl
integer/sub_sat.cl
integer/sub_sat.ll
diff --git a/generic/lib/integer/clz.cl b/generic/lib/integer/clz.cl
new file mode 100644
index 0000000..93994a4
--- /dev/null
+++ b/generic/lib/integer/clz.cl
@@ -0,0 +1,4 @@
+#include <clc/clc.h>
+
+#define BODY <clz.inc>
+#include <clc/integer/gentype.inc>
diff --git a/generic/lib/integer/clz.inc b/generic/lib/integer/clz.inc
new file mode 100644
index 0000000..2fa1ad9
--- /dev/null
+++ b/generic/lib/integer/clz.inc
@@ -0,0 +1,9 @@
+_CLC_OVERLOAD _CLC_DEF GENTYPE clz(GENTYPE x) {
+#if (GENTYPE == 'int') || (GENTYPE == 'uint')
+ //Doesn't seem to actually work.
+ return __builtin_clz(x);
+#else
+ //BAh!
+ return 0;
+#endif
+}