gallivm: add integer and unsigned mod arit functions. (v2)
authorDave Airlie <airlied@redhat.com>
Fri, 17 Feb 2012 19:02:23 +0000 (19:02 +0000)
committerDave Airlie <airlied@redhat.com>
Tue, 28 Feb 2012 10:31:49 +0000 (10:31 +0000)
use a single entry point, as per Jose's suggestion.

Signed-off-by: Dave Airlie <airlied@redhat.com>
src/gallium/auxiliary/gallivm/lp_bld_arit.c
src/gallium/auxiliary/gallivm/lp_bld_arit.h

index d379593030c6b9129b8765059bf43d77e4951dc0..65fc1809913870cce477d2f9be9357f8fb46d624 100644 (file)
@@ -2555,3 +2555,23 @@ lp_build_ilog2(struct lp_build_context *bld,
 
    return ipart;
 }
+
+LLVMValueRef
+lp_build_mod(struct lp_build_context *bld,
+             LLVMValueRef x,
+             LLVMValueRef y)
+{
+   LLVMBuilderRef builder = bld->gallivm->builder;
+   LLVMValueRef res;
+   const struct lp_type type = bld->type;
+
+   assert(type.floating);
+   assert(lp_check_value(type, x));
+   assert(lp_check_value(type, y));
+
+   if (type.sign)
+      res = LLVMBuildSRem(builder, x, y, "");
+   else
+      res = LLVMBuildURem(builder, x, y, "");
+   return res;
+}
index c78b61decf08bb9ba491b5a4b6b8da2bb0d1d003..aeb987ff3524a5a6ef973277428969affdabce5d 100644 (file)
@@ -249,4 +249,9 @@ lp_build_log2_approx(struct lp_build_context *bld,
                      LLVMValueRef *p_floor_log2,
                      LLVMValueRef *p_log2);
 
+LLVMValueRef
+lp_build_mod(struct lp_build_context *bld,
+             LLVMValueRef x,
+             LLVMValueRef y);
+
 #endif /* !LP_BLD_ARIT_H */