diff options
Diffstat (limited to 'src/gallium/auxiliary')
| -rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_arit.c | 31 | ||||
| -rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_arit.h | 4 | 
2 files changed, 35 insertions, 0 deletions
| diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c index f55d2b6d15..90c84c6a4e 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c @@ -232,6 +232,37 @@ lp_build_add(struct lp_build_context *bld,  } +/** Return the sum of the elements of a */ +LLVMValueRef +lp_build_sum_vector(struct lp_build_context *bld, +                    LLVMValueRef a) +{ +   const struct lp_type type = bld->type; +   LLVMValueRef index, res; +   int i; + +   if (a == bld->zero) +      return bld->zero; +   if (a == bld->undef) +      return bld->undef; +   assert(type.length > 1); + +   assert(!bld->type.norm); + +   index = LLVMConstInt(LLVMInt32Type(), 0, 0); +   res = LLVMBuildExtractElement(bld->builder, a, index, ""); + +   for (i = 1; i < type.length; i++) { +      index = LLVMConstInt(LLVMInt32Type(), i, 0); +      res = LLVMBuildAdd(bld->builder, res, +                         LLVMBuildExtractElement(bld->builder, a, index, ""), +                         ""); +   } + +   return res; +} + +  /**   * Generate a - b   */ diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.h b/src/gallium/auxiliary/gallivm/lp_bld_arit.h index f14b01e05f..7a10fe1220 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.h @@ -57,6 +57,10 @@ lp_build_add(struct lp_build_context *bld,               LLVMValueRef b);  LLVMValueRef +lp_build_sum_vector(struct lp_build_context *bld, +                    LLVMValueRef a); + +LLVMValueRef  lp_build_sub(struct lp_build_context *bld,               LLVMValueRef a,               LLVMValueRef b); | 
