[Mesa-dev] [PATCH 3/3] gallivm: add integer and unsigned mod arit functions.

Dave Airlie airlied at gmail.com
Fri Feb 17 11:02:23 PST 2012


From: Dave Airlie <airlied at redhat.com>

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 src/gallium/auxiliary/gallivm/lp_bld_arit.c |   28 +++++++++++++++++++++++++++
 src/gallium/auxiliary/gallivm/lp_bld_arit.h |   10 +++++++++
 2 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
index 1b97722..ed4b0b3 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
@@ -2591,3 +2591,31 @@ 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;
+   assert(lp_check_value(bld->type, x));
+   assert(lp_check_value(bld->type, y));
+
+   res = LLVMBuildSRem(builder, x, y, "");
+   return res;
+}
+
+LLVMValueRef
+lp_build_umod(struct lp_build_context *bld,
+              LLVMValueRef x,
+              LLVMValueRef y)
+{
+   LLVMBuilderRef builder = bld->gallivm->builder;
+   LLVMValueRef res;
+   assert(lp_check_value(bld->type, x));
+   assert(lp_check_value(bld->type, y));
+
+   res = LLVMBuildURem(builder, x, y, "");
+   return res;
+}
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.h b/src/gallium/auxiliary/gallivm/lp_bld_arit.h
index 0c753b7..a09bd84 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_arit.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.h
@@ -253,4 +253,14 @@ 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);
+
+LLVMValueRef
+lp_build_umod(struct lp_build_context *bld,
+              LLVMValueRef x,
+              LLVMValueRef y);
+
 #endif /* !LP_BLD_ARIT_H */
-- 
1.7.7.6



More information about the mesa-dev mailing list