mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 09:38:07 +02:00
gallivm: added lp_build_sum_vector()
This commit is contained in:
parent
c72a3b4f2f
commit
0b3bb6318e
2 changed files with 35 additions and 0 deletions
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -56,6 +56,10 @@ lp_build_add(struct lp_build_context *bld,
|
|||
LLVMValueRef a,
|
||||
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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue