summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2012-02-17 19:02:23 +0000
committerDave Airlie <[email protected]>2012-02-28 10:31:49 +0000
commit4ffc8b9ae46dcdb01adedde3ebb60f0c6a22138b (patch)
tree4d53d5830b6dbad0fe6da161683cfe347d4ba06b /src
parentc3e3df9b184e8c843c1abab29faa3af9e0c826bf (diff)
gallivm: add integer and unsigned mod arit functions. (v2)
use a single entry point, as per Jose's suggestion. Signed-off-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_arit.c20
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_arit.h5
2 files changed, 25 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
index d379593030c..65fc1809913 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
@@ -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;
+}
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.h b/src/gallium/auxiliary/gallivm/lp_bld_arit.h
index c78b61decf0..aeb987ff352 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_arit.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.h
@@ -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 */