summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2019-11-20 11:44:22 +1000
committerDave Airlie <airlied@redhat.com>2019-11-28 14:48:32 +1000
commit9461f2b5df2f243896748d65d375ed12e1befe04 (patch)
tree875cd3f3579a7735a422a4f00aa31baa000dfb83
parent1a608901cc51b186d621d18b4a81907ef7216e01 (diff)
gallivm: add cttz wrapper
this will be used to write find_lsb support Reviewed-by: Roland Scheidegger <sroland@vmware.com>
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_bitarit.c14
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_bitarit.h3
2 files changed, 17 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_bitarit.c b/src/gallium/auxiliary/gallivm/lp_bld_bitarit.c
index 998d3592199..c717b988f27 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_bitarit.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_bitarit.c
@@ -252,3 +252,17 @@ lp_build_popcount(struct lp_build_context *bld, LLVMValueRef a)
result = lp_build_intrinsic_unary(builder, intr_str, bld->vec_type, a);
return result;
}
+
+LLVMValueRef
+lp_build_cttz(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.cttz", bld->vec_type);
+
+ LLVMValueRef undef_val = LLVMConstNull(LLVMInt1TypeInContext(bld->gallivm->context));
+ result = lp_build_intrinsic_binary(builder, intr_str, bld->vec_type, a, undef_val);
+ return result;
+}
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_bitarit.h b/src/gallium/auxiliary/gallivm/lp_bld_bitarit.h
index e0f4f4aa3bc..989ce5ca568 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_bitarit.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_bitarit.h
@@ -73,4 +73,7 @@ lp_build_not(struct lp_build_context *bld, LLVMValueRef a);
LLVMValueRef
lp_build_popcount(struct lp_build_context *bld, LLVMValueRef a);
+
+LLVMValueRef
+lp_build_cttz(struct lp_build_context *bld, LLVMValueRef a);
#endif /* !LP_BLD_ARIT_H */