diff options
author | Dave Airlie <[email protected]> | 2019-10-28 14:21:43 +1000 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2019-11-28 14:48:25 +1000 |
commit | 1a608901cc51b186d621d18b4a81907ef7216e01 (patch) | |
tree | e68021b0e8f1df2a77901601b116e3c7f5f6ed21 /src/gallium | |
parent | 3b9950098b14ef6fa30035be9ffc847722a363cb (diff) |
gallivm: add popcount intrinsic wrapper
Reviewed-by: Roland Scheidegger <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_bitarit.c | 14 | ||||
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_bitarit.h | 2 |
2 files changed, 15 insertions, 1 deletions
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 */ |