From: Dave Airlie Date: Mon, 28 Oct 2019 04:21:43 +0000 (+1000) Subject: gallivm: add popcount intrinsic wrapper X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1a608901cc51b186d621d18b4a81907ef7216e01;p=mesa.git gallivm: add popcount intrinsic wrapper Reviewed-by: Roland Scheidegger --- 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 */