gallivm: add integer and unsigned mod arit functions. (v2)

use a single entry point, as per Jose's suggestion.

Signed-off-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
Dave Airlie 2012-02-17 19:02:23 +00:00
parent c3e3df9b18
commit 4ffc8b9ae4
2 changed files with 25 additions and 0 deletions

View 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;
}

View 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 */