gallivm: add cttz wrapper
authorDave Airlie <airlied@redhat.com>
Wed, 20 Nov 2019 01:44:22 +0000 (11:44 +1000)
committerDave Airlie <airlied@redhat.com>
Thu, 28 Nov 2019 04:48:32 +0000 (14:48 +1000)
this will be used to write find_lsb support

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
src/gallium/auxiliary/gallivm/lp_bld_bitarit.c
src/gallium/auxiliary/gallivm/lp_bld_bitarit.h

index 998d3592199450bb9b5c25a98a70721fe6d89d6c..c717b988f27439f722245c416b48cd7f988c97e4 100644 (file)
@@ -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;
+}
index e0f4f4aa3bce964c8cd03aaa5d46eca25a530df4..989ce5ca568e1f09dc9997ee64ff484916f0a4dc 100644 (file)
@@ -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 */