[Libclc-dev] [PATCH 1/3] popcount: Provide function implementation rather than intrinsic redirect
Jan Vesely via Libclc-dev
libclc-dev at lists.llvm.org
Sat Mar 3 13:44:41 PST 2018
amdgcn will need to override this
Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
---
generic/include/clc/integer/popcount.h | 11 +++++------
generic/include/clc/integer/unary.inc | 1 +
generic/include/integer/popcount.h | 3 +++
generic/include/{clc => }/integer/unary_intrin.inc | 0
generic/lib/SOURCES | 1 +
generic/lib/clc_unary.inc | 3 +++
generic/lib/integer/popcount.cl | 8 ++++++++
7 files changed, 21 insertions(+), 6 deletions(-)
create mode 100644 generic/include/clc/integer/unary.inc
create mode 100644 generic/include/integer/popcount.h
rename generic/include/{clc => }/integer/unary_intrin.inc (100%)
create mode 100644 generic/lib/clc_unary.inc
create mode 100644 generic/lib/integer/popcount.cl
diff --git a/generic/include/clc/integer/popcount.h b/generic/include/clc/integer/popcount.h
index 99e4021..23335f4 100644
--- a/generic/include/clc/integer/popcount.h
+++ b/generic/include/clc/integer/popcount.h
@@ -1,6 +1,5 @@
-#undef popcount
-#define popcount __clc_popcount
-
-#define __CLC_FUNCTION __clc_popcount
-#define __CLC_INTRINSIC "llvm.ctpop"
-#include <clc/integer/unary_intrin.inc>
+#define __CLC_FUNCTION popcount
+#define __CLC_BODY <clc/integer/unary.inc>
+#include <clc/integer/gentype.inc>
+#undef __CLC_FUNCTION
+#undef __CLC_BODY
diff --git a/generic/include/clc/integer/unary.inc b/generic/include/clc/integer/unary.inc
new file mode 100644
index 0000000..9858d90
--- /dev/null
+++ b/generic/include/clc/integer/unary.inc
@@ -0,0 +1 @@
+_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION(__CLC_GENTYPE x);
diff --git a/generic/include/integer/popcount.h b/generic/include/integer/popcount.h
new file mode 100644
index 0000000..00c7537
--- /dev/null
+++ b/generic/include/integer/popcount.h
@@ -0,0 +1,3 @@
+#define __CLC_FUNCTION __clc_native_popcount
+#define __CLC_INTRINSIC "llvm.ctpop"
+#include <integer/unary_intrin.inc>
diff --git a/generic/include/clc/integer/unary_intrin.inc b/generic/include/integer/unary_intrin.inc
similarity index 100%
rename from generic/include/clc/integer/unary_intrin.inc
rename to generic/include/integer/unary_intrin.inc
diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES
index 13fe4fa..923f0c7 100644
--- a/generic/lib/SOURCES
+++ b/generic/lib/SOURCES
@@ -70,6 +70,7 @@ integer/mad24.cl
integer/mad_sat.cl
integer/mul24.cl
integer/mul_hi.cl
+integer/popcount.cl
integer/rhadd.cl
integer/rotate.cl
integer/sub_sat.cl
diff --git a/generic/lib/clc_unary.inc b/generic/lib/clc_unary.inc
new file mode 100644
index 0000000..6c2782d
--- /dev/null
+++ b/generic/lib/clc_unary.inc
@@ -0,0 +1,3 @@
+_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __CLC_FUNC(__CLC_GENTYPE x) {
+ return __CLC_IMPL_FUNC(x);
+}
diff --git a/generic/lib/integer/popcount.cl b/generic/lib/integer/popcount.cl
new file mode 100644
index 0000000..ca83b1a
--- /dev/null
+++ b/generic/lib/integer/popcount.cl
@@ -0,0 +1,8 @@
+#include <clc/clc.h>
+#include <integer/popcount.h>
+
+#define __CLC_FUNC popcount
+#define __CLC_IMPL_FUNC __clc_native_popcount
+
+#define __CLC_BODY "../clc_unary.inc"
+#include <clc/integer/gentype.inc>
--
2.14.3
More information about the Libclc-dev
mailing list