Mesa (master): gallivm: add popcount intrinsic wrapper

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Nov 28 05:08:20 UTC 2019


Module: Mesa
Branch: master
Commit: 1a608901cc51b186d621d18b4a81907ef7216e01
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=1a608901cc51b186d621d18b4a81907ef7216e01

Author: Dave Airlie <airlied at redhat.com>
Date:   Mon Oct 28 14:21:43 2019 +1000

gallivm: add popcount intrinsic wrapper

Reviewed-by: Roland Scheidegger <sroland at vmware.com>

---

 src/gallium/auxiliary/gallivm/lp_bld_bitarit.c | 14 +++++++++++++-
 src/gallium/auxiliary/gallivm/lp_bld_bitarit.h |  2 ++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_bitarit.c b/src/gallium/auxiliary/gallivm/lp_bld_bitarit.c
index f3fa5f490aa..998d3592199 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_bitarit.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_bitarit.c
@@ -32,7 +32,7 @@
 #include "lp_bld_debug.h"
 #include "lp_bld_const.h"
 #include "lp_bld_bitarit.h"
-
+#include "lp_bld_intr.h"
 
 /**
  * Return (a | b)
@@ -240,3 +240,15 @@ lp_build_shr_imm(struct lp_build_context *bld, LLVMValueRef a, unsigned imm)
    assert(imm < bld->type.width);
    return lp_build_shr(bld, a, b);
 }
+
+LLVMValueRef
+lp_build_popcount(struct lp_build_context *bld, LLVMValueRef a)
+{
+   LLVMBuilderRef builder = bld->gallivm->builder;
+   LLVMValueRef result;
+   char intr_str[256];
+
+   lp_format_intrinsic(intr_str, sizeof(intr_str), "llvm.ctpop", bld->vec_type);
+   result = lp_build_intrinsic_unary(builder, intr_str, bld->vec_type, a);
+   return result;
+}
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_bitarit.h b/src/gallium/auxiliary/gallivm/lp_bld_bitarit.h
index 29f5def9b58..e0f4f4aa3bc 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_bitarit.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_bitarit.h
@@ -71,4 +71,6 @@ lp_build_shr_imm(struct lp_build_context *bld, LLVMValueRef a, unsigned imm);
 LLVMValueRef
 lp_build_not(struct lp_build_context *bld, LLVMValueRef a);
 
+LLVMValueRef
+lp_build_popcount(struct lp_build_context *bld, LLVMValueRef a);
 #endif /* !LP_BLD_ARIT_H */




More information about the mesa-commit mailing list