Dave, Ideally there should be only one lp_build_mod() which will invoke LLVMBuildSRem or LLVMBuildURem depending on the value of bld->type.sign. The point being that this allows the same code generation logic to seemingly target any type without having to worry too much which target it is targeting.
Jose ----- Original Message ----- > From: Dave Airlie <airl...@redhat.com> > > Signed-off-by: Dave Airlie <airl...@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 > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev > _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev