The field was redundant. Use the gallivm->builder value instead.
LLVMValueRef a,
LLVMValueRef b)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
const char *intrinsic = NULL;
LLVMValueRef cond;
}
if(intrinsic)
- return lp_build_intrinsic_binary(bld->builder, intrinsic, lp_build_vec_type(bld->gallivm, bld->type), a, b);
+ return lp_build_intrinsic_binary(builder, intrinsic, lp_build_vec_type(bld->gallivm, bld->type), a, b);
cond = lp_build_cmp(bld, PIPE_FUNC_LESS, a, b);
return lp_build_select(bld, cond, a, b);
LLVMValueRef a,
LLVMValueRef b)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
const char *intrinsic = NULL;
LLVMValueRef cond;
}
if(intrinsic)
- return lp_build_intrinsic_binary(bld->builder, intrinsic, lp_build_vec_type(bld->gallivm, bld->type), a, b);
+ return lp_build_intrinsic_binary(builder, intrinsic, lp_build_vec_type(bld->gallivm, bld->type), a, b);
cond = lp_build_cmp(bld, PIPE_FUNC_GREATER, a, b);
return lp_build_select(bld, cond, a, b);
lp_build_comp(struct lp_build_context *bld,
LLVMValueRef a)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
assert(lp_check_value(type, a));
if(LLVMIsConstant(a))
return LLVMConstNot(a);
else
- return LLVMBuildNot(bld->builder, a, "");
+ return LLVMBuildNot(builder, a, "");
}
if(LLVMIsConstant(a))
return LLVMConstSub(bld->one, a);
else
if (type.floating)
- return LLVMBuildFSub(bld->builder, bld->one, a, "");
+ return LLVMBuildFSub(builder, bld->one, a, "");
else
- return LLVMBuildSub(bld->builder, bld->one, a, "");
+ return LLVMBuildSub(builder, bld->one, a, "");
}
LLVMValueRef a,
LLVMValueRef b)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
LLVMValueRef res;
}
if(intrinsic)
- return lp_build_intrinsic_binary(bld->builder, intrinsic, lp_build_vec_type(bld->gallivm, bld->type), a, b);
+ return lp_build_intrinsic_binary(builder, intrinsic, lp_build_vec_type(bld->gallivm, bld->type), a, b);
}
if(LLVMIsConstant(a) && LLVMIsConstant(b))
res = LLVMConstAdd(a, b);
else
if (type.floating)
- res = LLVMBuildFAdd(bld->builder, a, b, "");
+ res = LLVMBuildFAdd(builder, a, b, "");
else
- res = LLVMBuildAdd(bld->builder, a, b, "");
+ res = LLVMBuildAdd(builder, a, b, "");
/* clamp to ceiling of 1.0 */
if(bld->type.norm && (bld->type.floating || bld->type.fixed))
lp_build_sum_vector(struct lp_build_context *bld,
LLVMValueRef a)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
LLVMValueRef index, res;
unsigned i;
assert(!bld->type.norm);
index = lp_build_const_int32(bld->gallivm, 0);
- res = LLVMBuildExtractElement(bld->builder, a, index, "");
+ res = LLVMBuildExtractElement(builder, a, index, "");
for (i = 1; i < type.length; i++) {
index = lp_build_const_int32(bld->gallivm, i);
if (type.floating)
- res = LLVMBuildFAdd(bld->builder, res,
- LLVMBuildExtractElement(bld->builder,
+ res = LLVMBuildFAdd(builder, res,
+ LLVMBuildExtractElement(builder,
a, index, ""),
"");
else
- res = LLVMBuildAdd(bld->builder, res,
- LLVMBuildExtractElement(bld->builder,
+ res = LLVMBuildAdd(builder, res,
+ LLVMBuildExtractElement(builder,
a, index, ""),
"");
}
LLVMValueRef a,
LLVMValueRef b)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
LLVMValueRef res;
}
if(intrinsic)
- return lp_build_intrinsic_binary(bld->builder, intrinsic, lp_build_vec_type(bld->gallivm, bld->type), a, b);
+ return lp_build_intrinsic_binary(builder, intrinsic, lp_build_vec_type(bld->gallivm, bld->type), a, b);
}
if(LLVMIsConstant(a) && LLVMIsConstant(b))
res = LLVMConstSub(a, b);
else
if (type.floating)
- res = LLVMBuildFSub(bld->builder, a, b, "");
+ res = LLVMBuildFSub(builder, a, b, "");
else
- res = LLVMBuildSub(bld->builder, a, b, "");
+ res = LLVMBuildSub(builder, a, b, "");
if(bld->type.norm && (bld->type.floating || bld->type.fixed))
res = lp_build_max_simple(bld, res, bld->zero);
LLVMValueRef a,
LLVMValueRef b)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
LLVMValueRef shift;
LLVMValueRef res;
}
else {
if (type.floating)
- res = LLVMBuildFMul(bld->builder, a, b, "");
+ res = LLVMBuildFMul(builder, a, b, "");
else
- res = LLVMBuildMul(bld->builder, a, b, "");
+ res = LLVMBuildMul(builder, a, b, "");
if(shift) {
if(type.sign)
- res = LLVMBuildAShr(bld->builder, res, shift, "");
+ res = LLVMBuildAShr(builder, res, shift, "");
else
- res = LLVMBuildLShr(bld->builder, res, shift, "");
+ res = LLVMBuildLShr(builder, res, shift, "");
}
}
LLVMValueRef a,
int b)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
LLVMValueRef factor;
assert(lp_check_value(bld->type, a));
*/
unsigned mantissa = lp_mantissa(bld->type);
factor = lp_build_const_int_vec(bld->gallivm, bld->type, (unsigned long long)shift << mantissa);
- a = LLVMBuildBitCast(bld->builder, a, lp_build_int_vec_type(bld->type), "");
- a = LLVMBuildAdd(bld->builder, a, factor, "");
- a = LLVMBuildBitCast(bld->builder, a, lp_build_vec_type(bld->gallivm, bld->type), "");
+ a = LLVMBuildBitCast(builder, a, lp_build_int_vec_type(bld->type), "");
+ a = LLVMBuildAdd(builder, a, factor, "");
+ a = LLVMBuildBitCast(builder, a, lp_build_vec_type(bld->gallivm, bld->type), "");
return a;
#endif
}
else {
factor = lp_build_const_vec(bld->gallivm, bld->type, shift);
- return LLVMBuildShl(bld->builder, a, factor, "");
+ return LLVMBuildShl(builder, a, factor, "");
}
}
LLVMValueRef a,
LLVMValueRef b)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
assert(lp_check_value(type, a));
return lp_build_mul(bld, a, lp_build_rcp(bld, b));
if (type.floating)
- return LLVMBuildFDiv(bld->builder, a, b, "");
+ return LLVMBuildFDiv(builder, a, b, "");
else if (type.sign)
- return LLVMBuildSDiv(bld->builder, a, b, "");
+ return LLVMBuildSDiv(builder, a, b, "");
else
- return LLVMBuildUDiv(bld->builder, a, b, "");
+ return LLVMBuildUDiv(builder, a, b, "");
}
LLVMValueRef v0,
LLVMValueRef v1)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
LLVMValueRef delta;
LLVMValueRef res;
* but it will be wrong for other uses. Basically we need a more
* powerful lp_type, capable of further distinguishing the values
* interpretation from the value storage. */
- res = LLVMBuildAnd(bld->builder, res, lp_build_const_int_vec(bld->gallivm, bld->type, (1 << bld->type.width/2) - 1), "");
+ res = LLVMBuildAnd(builder, res, lp_build_const_int_vec(bld->gallivm, bld->type, (1 << bld->type.width/2) - 1), "");
}
return res;
LLVMValueRef v0,
LLVMValueRef v1)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
LLVMValueRef res;
shift = lp_build_const_int_vec(bld->gallivm, wide_type, type.width - 1);
xl = lp_build_add(&wide_bld, xl,
- LLVMBuildAShr(bld->builder, xl, shift, ""));
+ LLVMBuildAShr(builder, xl, shift, ""));
xh = lp_build_add(&wide_bld, xh,
- LLVMBuildAShr(bld->builder, xh, shift, ""));
+ LLVMBuildAShr(builder, xh, shift, ""));
/*
* Lerp both halves.
lp_build_abs(struct lp_build_context *bld,
LLVMValueRef a)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
LLVMTypeRef vec_type = lp_build_vec_type(bld->gallivm, type);
LLVMTypeRef int_vec_type = lp_build_int_vec_type(bld->gallivm, type);
unsigned long long absMask = ~(1ULL << (type.width - 1));
LLVMValueRef mask = lp_build_const_int_vec(bld->gallivm, type, ((unsigned long long) absMask));
- a = LLVMBuildBitCast(bld->builder, a, int_vec_type, "");
- a = LLVMBuildAnd(bld->builder, a, mask, "");
- a = LLVMBuildBitCast(bld->builder, a, vec_type, "");
+ a = LLVMBuildBitCast(builder, a, int_vec_type, "");
+ a = LLVMBuildAnd(builder, a, mask, "");
+ a = LLVMBuildBitCast(builder, a, vec_type, "");
return a;
}
if(type.width*type.length == 128 && util_cpu_caps.has_ssse3) {
switch(type.width) {
case 8:
- return lp_build_intrinsic_unary(bld->builder, "llvm.x86.ssse3.pabs.b.128", vec_type, a);
+ return lp_build_intrinsic_unary(builder, "llvm.x86.ssse3.pabs.b.128", vec_type, a);
case 16:
- return lp_build_intrinsic_unary(bld->builder, "llvm.x86.ssse3.pabs.w.128", vec_type, a);
+ return lp_build_intrinsic_unary(builder, "llvm.x86.ssse3.pabs.w.128", vec_type, a);
case 32:
- return lp_build_intrinsic_unary(bld->builder, "llvm.x86.ssse3.pabs.d.128", vec_type, a);
+ return lp_build_intrinsic_unary(builder, "llvm.x86.ssse3.pabs.d.128", vec_type, a);
}
}
- return lp_build_max(bld, a, LLVMBuildNeg(bld->builder, a, ""));
+ return lp_build_max(bld, a, LLVMBuildNeg(builder, a, ""));
}
lp_build_negate(struct lp_build_context *bld,
LLVMValueRef a)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
+
assert(lp_check_value(bld->type, a));
#if HAVE_LLVM >= 0x0207
if (bld->type.floating)
- a = LLVMBuildFNeg(bld->builder, a, "");
+ a = LLVMBuildFNeg(builder, a, "");
else
#endif
- a = LLVMBuildNeg(bld->builder, a, "");
+ a = LLVMBuildNeg(builder, a, "");
return a;
}
lp_build_sgn(struct lp_build_context *bld,
LLVMValueRef a)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
LLVMValueRef cond;
LLVMValueRef res;
mask = lp_build_const_int_vec(bld->gallivm, type, maskBit);
/* Take the sign bit and add it to 1 constant */
- sign = LLVMBuildBitCast(bld->builder, a, int_type, "");
- sign = LLVMBuildAnd(bld->builder, sign, mask, "");
+ sign = LLVMBuildBitCast(builder, a, int_type, "");
+ sign = LLVMBuildAnd(builder, sign, mask, "");
one = LLVMConstBitCast(bld->one, int_type);
- res = LLVMBuildOr(bld->builder, sign, one, "");
- res = LLVMBuildBitCast(bld->builder, res, vec_type, "");
+ res = LLVMBuildOr(builder, sign, one, "");
+ res = LLVMBuildBitCast(builder, res, vec_type, "");
}
else
{
lp_build_set_sign(struct lp_build_context *bld,
LLVMValueRef a, LLVMValueRef sign)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
LLVMTypeRef int_vec_type = lp_build_int_vec_type(bld->gallivm, type);
LLVMTypeRef vec_type = lp_build_vec_type(bld->gallivm, type);
assert(lp_check_value(type, a));
/* val = reinterpret_cast<int>(a) */
- val = LLVMBuildBitCast(bld->builder, a, int_vec_type, "");
+ val = LLVMBuildBitCast(builder, a, int_vec_type, "");
/* val = val & mask */
- val = LLVMBuildAnd(bld->builder, val, mask, "");
+ val = LLVMBuildAnd(builder, val, mask, "");
/* sign = sign << shift */
- sign = LLVMBuildShl(bld->builder, sign, shift, "");
+ sign = LLVMBuildShl(builder, sign, shift, "");
/* res = val | sign */
- res = LLVMBuildOr(bld->builder, val, sign, "");
+ res = LLVMBuildOr(builder, val, sign, "");
/* res = reinterpret_cast<float>(res) */
- res = LLVMBuildBitCast(bld->builder, res, vec_type, "");
+ res = LLVMBuildBitCast(builder, res, vec_type, "");
return res;
}
lp_build_int_to_float(struct lp_build_context *bld,
LLVMValueRef a)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
LLVMTypeRef vec_type = lp_build_vec_type(bld->gallivm, type);
assert(type.floating);
- return LLVMBuildSIToFP(bld->builder, a, vec_type, "");
+ return LLVMBuildSIToFP(builder, a, vec_type, "");
}
LLVMValueRef a,
enum lp_build_round_sse41_mode mode)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
LLVMTypeRef i32t = LLVMInt32TypeInContext(bld->gallivm->context);
const char *intrinsic;
undef = LLVMGetUndef(vec_type);
args[0] = undef;
- args[1] = LLVMBuildInsertElement(bld->builder, undef, a, index0, "");
+ args[1] = LLVMBuildInsertElement(builder, undef, a, index0, "");
args[2] = LLVMConstInt(i32t, mode, 0);
- res = lp_build_intrinsic(bld->builder, intrinsic,
+ res = lp_build_intrinsic(builder, intrinsic,
vec_type, args, Elements(args));
- res = LLVMBuildExtractElement(bld->builder, res, index0, "");
+ res = LLVMBuildExtractElement(builder, res, index0, "");
}
else {
assert(type.width*type.length == 128);
return bld->undef;
}
- res = lp_build_intrinsic_binary(bld->builder, intrinsic,
+ res = lp_build_intrinsic_binary(builder, intrinsic,
bld->vec_type, a,
LLVMConstInt(i32t, mode, 0));
}
lp_build_iround_nearest_sse2(struct lp_build_context *bld,
LLVMValueRef a)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
LLVMTypeRef i32t = LLVMInt32TypeInContext(bld->gallivm->context);
LLVMTypeRef ret_type = lp_build_int_vec_type(bld->gallivm, type);
undef = LLVMGetUndef(vec_type);
- arg = LLVMBuildInsertElement(bld->builder, undef, a, index0, "");
+ arg = LLVMBuildInsertElement(builder, undef, a, index0, "");
- res = lp_build_intrinsic_unary(bld->builder, intrinsic,
+ res = lp_build_intrinsic_unary(builder, intrinsic,
ret_type, arg);
}
else {
intrinsic = "llvm.x86.sse2.cvtps2dq";
- res = lp_build_intrinsic_unary(bld->builder, intrinsic,
+ res = lp_build_intrinsic_unary(builder, intrinsic,
ret_type, a);
}
lp_build_trunc(struct lp_build_context *bld,
LLVMValueRef a)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
assert(type.floating);
LLVMTypeRef vec_type = lp_build_vec_type(bld->gallivm, type);
LLVMTypeRef int_vec_type = lp_build_int_vec_type(bld->gallivm, type);
LLVMValueRef res;
- res = LLVMBuildFPToSI(bld->builder, a, int_vec_type, "");
- res = LLVMBuildSIToFP(bld->builder, res, vec_type, "");
+ res = LLVMBuildFPToSI(builder, a, int_vec_type, "");
+ res = LLVMBuildSIToFP(builder, res, vec_type, "");
return res;
}
}
lp_build_round(struct lp_build_context *bld,
LLVMValueRef a)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
assert(type.floating);
LLVMTypeRef vec_type = lp_build_vec_type(bld->gallivm, type);
LLVMValueRef res;
res = lp_build_iround(bld, a);
- res = LLVMBuildSIToFP(bld->builder, res, vec_type, "");
+ res = LLVMBuildSIToFP(builder, res, vec_type, "");
return res;
}
}
lp_build_floor(struct lp_build_context *bld,
LLVMValueRef a)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
assert(type.floating);
LLVMTypeRef vec_type = lp_build_vec_type(bld->gallivm, type);
LLVMValueRef res;
res = lp_build_ifloor(bld, a);
- res = LLVMBuildSIToFP(bld->builder, res, vec_type, "");
+ res = LLVMBuildSIToFP(builder, res, vec_type, "");
return res;
}
}
lp_build_ceil(struct lp_build_context *bld,
LLVMValueRef a)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
assert(type.floating);
LLVMTypeRef vec_type = lp_build_vec_type(bld->gallivm, type);
LLVMValueRef res;
res = lp_build_iceil(bld, a);
- res = LLVMBuildSIToFP(bld->builder, res, vec_type, "");
+ res = LLVMBuildSIToFP(builder, res, vec_type, "");
return res;
}
}
lp_build_itrunc(struct lp_build_context *bld,
LLVMValueRef a)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
LLVMTypeRef int_vec_type = lp_build_int_vec_type(bld->gallivm, type);
assert(type.floating);
assert(lp_check_value(type, a));
- return LLVMBuildFPToSI(bld->builder, a, int_vec_type, "");
+ return LLVMBuildFPToSI(builder, a, int_vec_type, "");
}
lp_build_iround(struct lp_build_context *bld,
LLVMValueRef a)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
LLVMTypeRef int_vec_type = bld->int_vec_type;
LLVMValueRef res;
LLVMValueRef sign;
/* get sign bit */
- sign = LLVMBuildBitCast(bld->builder, a, int_vec_type, "");
- sign = LLVMBuildAnd(bld->builder, sign, mask, "");
+ sign = LLVMBuildBitCast(builder, a, int_vec_type, "");
+ sign = LLVMBuildAnd(builder, sign, mask, "");
/* sign * 0.5 */
- half = LLVMBuildBitCast(bld->builder, half, int_vec_type, "");
- half = LLVMBuildOr(bld->builder, sign, half, "");
- half = LLVMBuildBitCast(bld->builder, half, vec_type, "");
+ half = LLVMBuildBitCast(builder, half, int_vec_type, "");
+ half = LLVMBuildOr(builder, sign, half, "");
+ half = LLVMBuildBitCast(builder, half, vec_type, "");
}
- res = LLVMBuildFAdd(bld->builder, a, half, "");
+ res = LLVMBuildFAdd(builder, a, half, "");
}
- res = LLVMBuildFPToSI(bld->builder, res, int_vec_type, "");
+ res = LLVMBuildFPToSI(builder, res, int_vec_type, "");
return res;
}
lp_build_ifloor(struct lp_build_context *bld,
LLVMValueRef a)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
LLVMTypeRef int_vec_type = bld->int_vec_type;
LLVMValueRef res;
LLVMValueRef offset;
/* sign = a < 0 ? ~0 : 0 */
- sign = LLVMBuildBitCast(bld->builder, a, int_vec_type, "");
- sign = LLVMBuildAnd(bld->builder, sign, mask, "");
- sign = LLVMBuildAShr(bld->builder, sign,
+ sign = LLVMBuildBitCast(builder, a, int_vec_type, "");
+ sign = LLVMBuildAnd(builder, sign, mask, "");
+ sign = LLVMBuildAShr(builder, sign,
lp_build_const_int_vec(bld->gallivm, type,
type.width - 1),
"ifloor.sign");
offset = LLVMConstBitCast(offset, int_vec_type);
/* offset = a < 0 ? offset : 0.0f */
- offset = LLVMBuildAnd(bld->builder, offset, sign, "");
- offset = LLVMBuildBitCast(bld->builder, offset, vec_type, "ifloor.offset");
+ offset = LLVMBuildAnd(builder, offset, sign, "");
+ offset = LLVMBuildBitCast(builder, offset, vec_type, "ifloor.offset");
- res = LLVMBuildFAdd(bld->builder, res, offset, "ifloor.res");
+ res = LLVMBuildFAdd(builder, res, offset, "ifloor.res");
}
}
/* round to nearest (toward zero) */
- res = LLVMBuildFPToSI(bld->builder, res, int_vec_type, "ifloor.res");
+ res = LLVMBuildFPToSI(builder, res, int_vec_type, "ifloor.res");
return res;
}
lp_build_iceil(struct lp_build_context *bld,
LLVMValueRef a)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
LLVMTypeRef int_vec_type = bld->int_vec_type;
LLVMValueRef res;
LLVMValueRef sign;
/* sign = a < 0 ? 0 : ~0 */
- sign = LLVMBuildBitCast(bld->builder, a, int_vec_type, "");
- sign = LLVMBuildAnd(bld->builder, sign, mask, "");
- sign = LLVMBuildAShr(bld->builder, sign,
+ sign = LLVMBuildBitCast(builder, a, int_vec_type, "");
+ sign = LLVMBuildAnd(builder, sign, mask, "");
+ sign = LLVMBuildAShr(builder, sign,
lp_build_const_int_vec(bld->gallivm, type,
type.width - 1),
"iceil.sign");
- sign = LLVMBuildNot(bld->builder, sign, "iceil.not");
+ sign = LLVMBuildNot(builder, sign, "iceil.not");
/* offset = a < 0 ? 0.0 : offset */
offset = LLVMConstBitCast(offset, int_vec_type);
- offset = LLVMBuildAnd(bld->builder, offset, sign, "");
- offset = LLVMBuildBitCast(bld->builder, offset, vec_type, "iceil.offset");
+ offset = LLVMBuildAnd(builder, offset, sign, "");
+ offset = LLVMBuildBitCast(builder, offset, vec_type, "iceil.offset");
}
- res = LLVMBuildFAdd(bld->builder, a, offset, "iceil.res");
+ res = LLVMBuildFAdd(builder, a, offset, "iceil.res");
}
/* round to nearest (toward zero) */
- res = LLVMBuildFPToSI(bld->builder, res, int_vec_type, "iceil.res");
+ res = LLVMBuildFPToSI(builder, res, int_vec_type, "iceil.res");
return res;
}
LLVMValueRef *out_ipart,
LLVMValueRef *out_fpart)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
LLVMValueRef ipart;
*/
ipart = lp_build_floor(bld, a);
- *out_fpart = LLVMBuildFSub(bld->builder, a, ipart, "fpart");
- *out_ipart = LLVMBuildFPToSI(bld->builder, ipart, bld->int_vec_type, "ipart");
+ *out_fpart = LLVMBuildFSub(builder, a, ipart, "fpart");
+ *out_ipart = LLVMBuildFPToSI(builder, ipart, bld->int_vec_type, "ipart");
}
else {
/*
*/
*out_ipart = lp_build_ifloor(bld, a);
- ipart = LLVMBuildSIToFP(bld->builder, *out_ipart, bld->vec_type, "ipart");
- *out_fpart = LLVMBuildFSub(bld->builder, a, ipart, "fpart");
+ ipart = LLVMBuildSIToFP(builder, *out_ipart, bld->vec_type, "ipart");
+ *out_fpart = LLVMBuildFSub(builder, a, ipart, "fpart");
}
}
lp_build_sqrt(struct lp_build_context *bld,
LLVMValueRef a)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
LLVMTypeRef vec_type = lp_build_vec_type(bld->gallivm, type);
char intrinsic[32];
assert(type.floating);
util_snprintf(intrinsic, sizeof intrinsic, "llvm.sqrt.v%uf%u", type.length, type.width);
- return lp_build_intrinsic_unary(bld->builder, intrinsic, vec_type, a);
+ return lp_build_intrinsic_unary(builder, intrinsic, vec_type, a);
}
LLVMValueRef a,
LLVMValueRef rcp_a)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
LLVMValueRef two = lp_build_const_vec(bld->gallivm, bld->type, 2.0);
LLVMValueRef res;
- res = LLVMBuildFMul(bld->builder, a, rcp_a, "");
- res = LLVMBuildFSub(bld->builder, two, res, "");
- res = LLVMBuildFMul(bld->builder, rcp_a, res, "");
+ res = LLVMBuildFMul(builder, a, rcp_a, "");
+ res = LLVMBuildFSub(builder, two, res, "");
+ res = LLVMBuildFMul(builder, rcp_a, res, "");
return res;
}
lp_build_rcp(struct lp_build_context *bld,
LLVMValueRef a)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
assert(lp_check_value(type, a));
LLVMValueRef res;
unsigned i;
- res = lp_build_intrinsic_unary(bld->builder, "llvm.x86.sse.rcp.ps", bld->vec_type, a);
+ res = lp_build_intrinsic_unary(builder, "llvm.x86.sse.rcp.ps", bld->vec_type, a);
for (i = 0; i < num_iterations; ++i) {
res = lp_build_rcp_refine(bld, a, res);
return res;
}
- return LLVMBuildFDiv(bld->builder, bld->one, a, "");
+ return LLVMBuildFDiv(builder, bld->one, a, "");
}
LLVMValueRef a,
LLVMValueRef rsqrt_a)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
LLVMValueRef half = lp_build_const_vec(bld->gallivm, bld->type, 0.5);
LLVMValueRef three = lp_build_const_vec(bld->gallivm, bld->type, 3.0);
LLVMValueRef res;
- res = LLVMBuildFMul(bld->builder, rsqrt_a, rsqrt_a, "");
- res = LLVMBuildFMul(bld->builder, a, res, "");
- res = LLVMBuildFSub(bld->builder, three, res, "");
- res = LLVMBuildFMul(bld->builder, rsqrt_a, res, "");
- res = LLVMBuildFMul(bld->builder, half, res, "");
+ res = LLVMBuildFMul(builder, rsqrt_a, rsqrt_a, "");
+ res = LLVMBuildFMul(builder, a, res, "");
+ res = LLVMBuildFSub(builder, three, res, "");
+ res = LLVMBuildFMul(builder, rsqrt_a, res, "");
+ res = LLVMBuildFMul(builder, half, res, "");
return res;
}
lp_build_rsqrt(struct lp_build_context *bld,
LLVMValueRef a)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
assert(lp_check_value(type, a));
LLVMValueRef res;
unsigned i;
- res = lp_build_intrinsic_unary(bld->builder, "llvm.x86.sse.rsqrt.ps", bld->vec_type, a);
+ res = lp_build_intrinsic_unary(builder, "llvm.x86.sse.rsqrt.ps", bld->vec_type, a);
for (i = 0; i < num_iterations; ++i) {
res = lp_build_rsqrt_refine(bld, a, res);
lp_build_sin(struct lp_build_context *bld,
LLVMValueRef a)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
struct gallivm_state *gallivm = bld->gallivm;
struct lp_type int_type = lp_int_type(bld->type);
- LLVMBuilderRef b = bld->builder;
+ LLVMBuilderRef b = builder;
LLVMTypeRef v4sf = LLVMVectorType(LLVMFloatTypeInContext(bld->gallivm->context), 4);
LLVMTypeRef v4si = LLVMVectorType(LLVMInt32TypeInContext(bld->gallivm->context), 4);
lp_build_cos(struct lp_build_context *bld,
LLVMValueRef a)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
struct gallivm_state *gallivm = bld->gallivm;
struct lp_type int_type = lp_int_type(bld->type);
- LLVMBuilderRef b = bld->builder;
+ LLVMBuilderRef b = builder;
LLVMTypeRef v4sf = LLVMVectorType(LLVMFloatTypeInContext(bld->gallivm->context), 4);
LLVMTypeRef v4si = LLVMVectorType(LLVMInt32TypeInContext(bld->gallivm->context), 4);
LLVMValueRef *p_frac_part,
LLVMValueRef *p_exp2)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
LLVMTypeRef vec_type = lp_build_vec_type(bld->gallivm, type);
LLVMTypeRef int_vec_type = lp_build_int_vec_type(bld->gallivm, type);
ipart = lp_build_floor(bld, x);
/* fpart = x - ipart */
- fpart = LLVMBuildFSub(bld->builder, x, ipart, "");
+ fpart = LLVMBuildFSub(builder, x, ipart, "");
}
if(p_exp2_int_part || p_exp2) {
/* expipart = (float) (1 << ipart) */
- ipart = LLVMBuildFPToSI(bld->builder, ipart, int_vec_type, "");
- expipart = LLVMBuildAdd(bld->builder, ipart,
+ ipart = LLVMBuildFPToSI(builder, ipart, int_vec_type, "");
+ expipart = LLVMBuildAdd(builder, ipart,
lp_build_const_int_vec(bld->gallivm, type, 127), "");
- expipart = LLVMBuildShl(bld->builder, expipart,
+ expipart = LLVMBuildShl(builder, expipart,
lp_build_const_int_vec(bld->gallivm, type, 23), "");
- expipart = LLVMBuildBitCast(bld->builder, expipart, vec_type, "");
+ expipart = LLVMBuildBitCast(builder, expipart, vec_type, "");
}
if(p_exp2) {
expfpart = lp_build_polynomial(bld, fpart, lp_build_exp2_polynomial,
Elements(lp_build_exp2_polynomial));
- res = LLVMBuildFMul(bld->builder, expipart, expfpart, "");
+ res = LLVMBuildFMul(builder, expipart, expfpart, "");
}
if(p_exp2_int_part)
LLVMValueRef x,
int bias)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
unsigned mantissa = lp_mantissa(type);
LLVMValueRef res;
assert(lp_check_value(bld->type, x));
- x = LLVMBuildBitCast(bld->builder, x, bld->int_vec_type, "");
+ x = LLVMBuildBitCast(builder, x, bld->int_vec_type, "");
- res = LLVMBuildLShr(bld->builder, x,
+ res = LLVMBuildLShr(builder, x,
lp_build_const_int_vec(bld->gallivm, type, mantissa), "");
- res = LLVMBuildAnd(bld->builder, res,
+ res = LLVMBuildAnd(builder, res,
lp_build_const_int_vec(bld->gallivm, type, 255), "");
- res = LLVMBuildSub(bld->builder, res,
+ res = LLVMBuildSub(builder, res,
lp_build_const_int_vec(bld->gallivm, type, 127 - bias), "");
return res;
lp_build_extract_mantissa(struct lp_build_context *bld,
LLVMValueRef x)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
unsigned mantissa = lp_mantissa(type);
LLVMValueRef mantmask = lp_build_const_int_vec(bld->gallivm, type,
assert(type.floating);
- x = LLVMBuildBitCast(bld->builder, x, bld->int_vec_type, "");
+ x = LLVMBuildBitCast(builder, x, bld->int_vec_type, "");
/* res = x / 2**ipart */
- res = LLVMBuildAnd(bld->builder, x, mantmask, "");
- res = LLVMBuildOr(bld->builder, res, one, "");
- res = LLVMBuildBitCast(bld->builder, res, bld->vec_type, "");
+ res = LLVMBuildAnd(builder, x, mantmask, "");
+ res = LLVMBuildOr(builder, res, one, "");
+ res = LLVMBuildBitCast(builder, res, bld->vec_type, "");
return res;
}
LLVMValueRef *p_floor_log2,
LLVMValueRef *p_log2)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
LLVMTypeRef vec_type = lp_build_vec_type(bld->gallivm, type);
LLVMTypeRef int_vec_type = lp_build_int_vec_type(bld->gallivm, type);
assert(type.floating && type.width == 32);
- i = LLVMBuildBitCast(bld->builder, x, int_vec_type, "");
+ i = LLVMBuildBitCast(builder, x, int_vec_type, "");
/* exp = (float) exponent(x) */
- exp = LLVMBuildAnd(bld->builder, i, expmask, "");
+ exp = LLVMBuildAnd(builder, i, expmask, "");
}
if(p_floor_log2 || p_log2) {
- logexp = LLVMBuildLShr(bld->builder, exp, lp_build_const_int_vec(bld->gallivm, type, 23), "");
- logexp = LLVMBuildSub(bld->builder, logexp, lp_build_const_int_vec(bld->gallivm, type, 127), "");
- logexp = LLVMBuildSIToFP(bld->builder, logexp, vec_type, "");
+ logexp = LLVMBuildLShr(builder, exp, lp_build_const_int_vec(bld->gallivm, type, 23), "");
+ logexp = LLVMBuildSub(builder, logexp, lp_build_const_int_vec(bld->gallivm, type, 127), "");
+ logexp = LLVMBuildSIToFP(builder, logexp, vec_type, "");
}
if(p_log2) {
/* mant = (float) mantissa(x) */
- mant = LLVMBuildAnd(bld->builder, i, mantmask, "");
- mant = LLVMBuildOr(bld->builder, mant, one, "");
- mant = LLVMBuildBitCast(bld->builder, mant, vec_type, "");
+ mant = LLVMBuildAnd(builder, i, mantmask, "");
+ mant = LLVMBuildOr(builder, mant, one, "");
+ mant = LLVMBuildBitCast(builder, mant, vec_type, "");
logmant = lp_build_polynomial(bld, mant, lp_build_log2_polynomial,
Elements(lp_build_log2_polynomial));
/* This effectively increases the polynomial degree by one, but ensures that log2(1) == 0*/
- logmant = LLVMBuildFMul(bld->builder, logmant, LLVMBuildFSub(bld->builder, mant, bld->one, ""), "");
+ logmant = LLVMBuildFMul(builder, logmant, LLVMBuildFSub(builder, mant, bld->one, ""), "");
- res = LLVMBuildFAdd(bld->builder, logmant, logexp, "");
+ res = LLVMBuildFAdd(builder, logmant, logexp, "");
}
if(p_exp) {
- exp = LLVMBuildBitCast(bld->builder, exp, vec_type, "");
+ exp = LLVMBuildBitCast(builder, exp, vec_type, "");
*p_exp = exp;
}
lp_build_fast_log2(struct lp_build_context *bld,
LLVMValueRef x)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
LLVMValueRef ipart;
LLVMValueRef fpart;
/* ipart = floor(log2(x)) - 1 */
ipart = lp_build_extract_exponent(bld, x, -1);
- ipart = LLVMBuildSIToFP(bld->builder, ipart, bld->vec_type, "");
+ ipart = LLVMBuildSIToFP(builder, ipart, bld->vec_type, "");
/* fpart = x / 2**ipart */
fpart = lp_build_extract_mantissa(bld, x);
/* ipart + fpart */
- return LLVMBuildFAdd(bld->builder, ipart, fpart, "");
+ return LLVMBuildFAdd(builder, ipart, fpart, "");
}
lp_build_ilog2(struct lp_build_context *bld,
LLVMValueRef x)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
LLVMValueRef sqrt2 = lp_build_const_vec(bld->gallivm, bld->type, M_SQRT2);
LLVMValueRef ipart;
assert(lp_check_value(bld->type, x));
/* x * 2^(0.5) i.e., add 0.5 to the log2(x) */
- x = LLVMBuildFMul(bld->builder, x, sqrt2, "");
+ x = LLVMBuildFMul(builder, x, sqrt2, "");
/* ipart = floor(log2(x) + 0.5) */
ipart = lp_build_extract_exponent(bld, x, 0);
LLVMValueRef
lp_build_or(struct lp_build_context *bld, LLVMValueRef a, LLVMValueRef b)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
LLVMValueRef res;
/* can't do bitwise ops on floating-point values */
if (type.floating) {
- a = LLVMBuildBitCast(bld->builder, a, bld->int_vec_type, "");
- b = LLVMBuildBitCast(bld->builder, b, bld->int_vec_type, "");
+ a = LLVMBuildBitCast(builder, a, bld->int_vec_type, "");
+ b = LLVMBuildBitCast(builder, b, bld->int_vec_type, "");
}
- res = LLVMBuildOr(bld->builder, a, b, "");
+ res = LLVMBuildOr(builder, a, b, "");
if (type.floating) {
- res = LLVMBuildBitCast(bld->builder, res, bld->vec_type, "");
+ res = LLVMBuildBitCast(builder, res, bld->vec_type, "");
}
return res;
LLVMValueRef
lp_build_and(struct lp_build_context *bld, LLVMValueRef a, LLVMValueRef b)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
LLVMValueRef res;
/* can't do bitwise ops on floating-point values */
if (type.floating) {
- a = LLVMBuildBitCast(bld->builder, a, bld->int_vec_type, "");
- b = LLVMBuildBitCast(bld->builder, b, bld->int_vec_type, "");
+ a = LLVMBuildBitCast(builder, a, bld->int_vec_type, "");
+ b = LLVMBuildBitCast(builder, b, bld->int_vec_type, "");
}
- res = LLVMBuildAnd(bld->builder, a, b, "");
+ res = LLVMBuildAnd(builder, a, b, "");
if (type.floating) {
- res = LLVMBuildBitCast(bld->builder, res, bld->vec_type, "");
+ res = LLVMBuildBitCast(builder, res, bld->vec_type, "");
}
return res;
LLVMValueRef
lp_build_andnot(struct lp_build_context *bld, LLVMValueRef a, LLVMValueRef b)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
LLVMValueRef res;
/* can't do bitwise ops on floating-point values */
if (type.floating) {
- a = LLVMBuildBitCast(bld->builder, a, bld->int_vec_type, "");
- b = LLVMBuildBitCast(bld->builder, b, bld->int_vec_type, "");
+ a = LLVMBuildBitCast(builder, a, bld->int_vec_type, "");
+ b = LLVMBuildBitCast(builder, b, bld->int_vec_type, "");
}
- res = LLVMBuildNot(bld->builder, b, "");
- res = LLVMBuildAnd(bld->builder, a, res, "");
+ res = LLVMBuildNot(builder, b, "");
+ res = LLVMBuildAnd(builder, a, res, "");
if (type.floating) {
- res = LLVMBuildBitCast(bld->builder, res, bld->vec_type, "");
+ res = LLVMBuildBitCast(builder, res, bld->vec_type, "");
}
return res;
LLVMValueRef
lp_build_shl(struct lp_build_context *bld, LLVMValueRef a, LLVMValueRef b)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
LLVMValueRef res;
assert(lp_check_value(type, a));
assert(lp_check_value(type, b));
- res = LLVMBuildShl(bld->builder, a, b, "");
+ res = LLVMBuildShl(builder, a, b, "");
return res;
}
LLVMValueRef
lp_build_shr(struct lp_build_context *bld, LLVMValueRef a, LLVMValueRef b)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
LLVMValueRef res;
assert(lp_check_value(type, b));
if (type.sign) {
- res = LLVMBuildAShr(bld->builder, a, b, "");
+ res = LLVMBuildAShr(builder, a, b, "");
} else {
- res = LLVMBuildLShr(bld->builder, a, b, "");
+ res = LLVMBuildLShr(builder, a, b, "");
}
return res;
{
struct lp_build_context bld;
- bld.builder = builder;
bld.gallivm = gallivm;
bld.type = src_type;
bld.vec_type = src_vec_type;
LLVMValueRef a,
LLVMValueRef b)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
struct lp_type type = bld->type;
LLVMValueRef res;
if(type.floating) {
LLVMTypeRef int_vec_type = lp_build_int_vec_type(bld->gallivm, type);
- a = LLVMBuildBitCast(bld->builder, a, int_vec_type, "");
- b = LLVMBuildBitCast(bld->builder, b, int_vec_type, "");
+ a = LLVMBuildBitCast(builder, a, int_vec_type, "");
+ b = LLVMBuildBitCast(builder, b, int_vec_type, "");
}
- a = LLVMBuildAnd(bld->builder, a, mask, "");
+ a = LLVMBuildAnd(builder, a, mask, "");
/* This often gets translated to PANDN, but sometimes the NOT is
* pre-computed and stored in another constant. The best strategy depends
* on available registers, so it is not a big deal -- hopefully LLVM does
* the right decision attending the rest of the program.
*/
- b = LLVMBuildAnd(bld->builder, b, LLVMBuildNot(bld->builder, mask, ""), "");
+ b = LLVMBuildAnd(builder, b, LLVMBuildNot(builder, mask, ""), "");
- res = LLVMBuildOr(bld->builder, a, b, "");
+ res = LLVMBuildOr(builder, a, b, "");
if(type.floating) {
LLVMTypeRef vec_type = lp_build_vec_type(bld->gallivm, type);
- res = LLVMBuildBitCast(bld->builder, res, vec_type, "");
+ res = LLVMBuildBitCast(builder, res, vec_type, "");
}
return res;
LLVMValueRef a,
LLVMValueRef b)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
LLVMContextRef lc = bld->gallivm->context;
struct lp_type type = bld->type;
LLVMValueRef res;
return a;
if (type.length == 1) {
- mask = LLVMBuildTrunc(bld->builder, mask, LLVMInt1TypeInContext(lc), "");
- res = LLVMBuildSelect(bld->builder, mask, a, b, "");
+ mask = LLVMBuildTrunc(builder, mask, LLVMInt1TypeInContext(lc), "");
+ res = LLVMBuildSelect(builder, mask, a, b, "");
}
else if (util_cpu_caps.has_sse4_1 &&
type.width * type.length == 128 &&
}
if (arg_type != bld->int_vec_type) {
- mask = LLVMBuildBitCast(bld->builder, mask, arg_type, "");
+ mask = LLVMBuildBitCast(builder, mask, arg_type, "");
}
if (arg_type != bld->vec_type) {
- a = LLVMBuildBitCast(bld->builder, a, arg_type, "");
- b = LLVMBuildBitCast(bld->builder, b, arg_type, "");
+ a = LLVMBuildBitCast(builder, a, arg_type, "");
+ b = LLVMBuildBitCast(builder, b, arg_type, "");
}
args[0] = b;
args[1] = a;
args[2] = mask;
- res = lp_build_intrinsic(bld->builder, intrinsic,
+ res = lp_build_intrinsic(builder, intrinsic,
arg_type, args, Elements(args));
if (arg_type != bld->vec_type) {
- res = LLVMBuildBitCast(bld->builder, res, bld->vec_type, "");
+ res = LLVMBuildBitCast(builder, res, bld->vec_type, "");
}
}
else {
LLVMValueRef a,
LLVMValueRef b)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
const unsigned n = type.length;
unsigned i, j;
(mask & (1 << i) ? 0 : n) + j + i,
0);
- return LLVMBuildShuffleVector(bld->builder, a, b, LLVMConstVector(shuffles, n), "");
+ return LLVMBuildShuffleVector(builder, a, b, LLVMConstVector(shuffles, n), "");
}
else {
#if 0
cond_vec[j + i] = LLVMConstInt(elem_type,
mask & (1 << i) ? 1 : 0, 0);
- return LLVMBuildSelect(bld->builder, LLVMConstVector(cond_vec, n), a, b, "");
+ return LLVMBuildSelect(builder, LLVMConstVector(cond_vec, n), a, b, "");
#else
LLVMValueRef mask_vec = lp_build_const_mask_aos(bld->gallivm, type, mask);
return lp_build_select(bld, mask_vec, a, b);
lp_build_scalar_ddx(struct lp_build_context *bld,
LLVMValueRef a)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
LLVMValueRef idx_left = lp_build_const_int32(bld->gallivm, LP_BLD_QUAD_TOP_LEFT);
LLVMValueRef idx_right = lp_build_const_int32(bld->gallivm, LP_BLD_QUAD_TOP_RIGHT);
- LLVMValueRef a_left = LLVMBuildExtractElement(bld->builder, a, idx_left, "left");
- LLVMValueRef a_right = LLVMBuildExtractElement(bld->builder, a, idx_right, "right");
+ LLVMValueRef a_left = LLVMBuildExtractElement(builder, a, idx_left, "left");
+ LLVMValueRef a_right = LLVMBuildExtractElement(builder, a, idx_right, "right");
if (bld->type.floating)
- return LLVMBuildFSub(bld->builder, a_right, a_left, "ddx");
+ return LLVMBuildFSub(builder, a_right, a_left, "ddx");
else
- return LLVMBuildSub(bld->builder, a_right, a_left, "ddx");
+ return LLVMBuildSub(builder, a_right, a_left, "ddx");
}
lp_build_scalar_ddy(struct lp_build_context *bld,
LLVMValueRef a)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
LLVMValueRef idx_top = lp_build_const_int32(bld->gallivm, LP_BLD_QUAD_TOP_LEFT);
LLVMValueRef idx_bottom = lp_build_const_int32(bld->gallivm, LP_BLD_QUAD_BOTTOM_LEFT);
- LLVMValueRef a_top = LLVMBuildExtractElement(bld->builder, a, idx_top, "top");
- LLVMValueRef a_bottom = LLVMBuildExtractElement(bld->builder, a, idx_bottom, "bottom");
+ LLVMValueRef a_top = LLVMBuildExtractElement(builder, a, idx_top, "top");
+ LLVMValueRef a_bottom = LLVMBuildExtractElement(builder, a, idx_bottom, "bottom");
if (bld->type.floating)
- return LLVMBuildFSub(bld->builder, a_bottom, a_top, "ddy");
+ return LLVMBuildFSub(builder, a_bottom, a_top, "ddy");
else
- return LLVMBuildSub(bld->builder, a_bottom, a_top, "ddy");
+ return LLVMBuildSub(builder, a_bottom, a_top, "ddy");
}
LLVMValueRef base_size,
LLVMValueRef level)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
assert(lp_check_value(bld->type, base_size));
assert(lp_check_value(bld->type, level));
}
else {
LLVMValueRef size =
- LLVMBuildLShr(bld->builder, base_size, level, "minify");
+ LLVMBuildLShr(builder, base_size, level, "minify");
assert(bld->type.sign);
size = lp_build_max(bld, size, bld->one);
return size;
LLVMValueRef *out_offset,
LLVMValueRef *out_subcoord)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
LLVMValueRef offset;
LLVMValueRef subcoord;
*/
#if 0
LLVMValueRef block_width = lp_build_const_int_vec(bld->type, block_length);
- subcoord = LLVMBuildURem(bld->builder, coord, block_width, "");
- coord = LLVMBuildUDiv(bld->builder, coord, block_width, "");
+ subcoord = LLVMBuildURem(builder, coord, block_width, "");
+ coord = LLVMBuildUDiv(builder, coord, block_width, "");
#else
unsigned logbase2 = util_unsigned_logbase2(block_length);
LLVMValueRef block_shift = lp_build_const_int_vec(bld->gallivm, bld->type, logbase2);
LLVMValueRef block_mask = lp_build_const_int_vec(bld->gallivm, bld->type, block_length - 1);
- subcoord = LLVMBuildAnd(bld->builder, coord, block_mask, "");
- coord = LLVMBuildLShr(bld->builder, coord, block_shift, "");
+ subcoord = LLVMBuildAnd(builder, coord, block_mask, "");
+ coord = LLVMBuildLShr(builder, coord, block_shift, "");
#endif
}
lp_build_broadcast_scalar(struct lp_build_context *bld,
LLVMValueRef scalar)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
assert(lp_check_elem_type(type, LLVMTypeOf(scalar)));
struct lp_type i32_vec_type = lp_type_int_vec(32);
i32_vec_type.length = type.length;
- res = LLVMBuildInsertElement(bld->builder, bld->undef, scalar,
+ res = LLVMBuildInsertElement(builder, bld->undef, scalar,
lp_build_const_int32(bld->gallivm, 0), "");
- res = LLVMBuildShuffleVector(bld->builder, res, bld->undef,
+ res = LLVMBuildShuffleVector(builder, res, bld->undef,
lp_build_const_int_vec(bld->gallivm, i32_vec_type, 0), "");
#else
/* XXX: The above path provokes a bug in LLVM 2.6 */
res = bld->undef;
for(i = 0; i < type.length; ++i) {
LLVMValueRef index = lp_build_const_int32(bld->gallivm, i);
- res = LLVMBuildInsertElement(bld->builder, res, scalar, index, "");
+ res = LLVMBuildInsertElement(builder, res, scalar, index, "");
}
#endif
return res;
LLVMValueRef a,
unsigned channel)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
const unsigned n = type.length;
unsigned i, j;
for(i = 0; i < 4; ++i)
shuffles[j + i] = LLVMConstInt(elem_type, j + channel, 0);
- return LLVMBuildShuffleVector(bld->builder, a, bld->undef, LLVMConstVector(shuffles, n), "");
+ return LLVMBuildShuffleVector(builder, a, bld->undef, LLVMConstVector(shuffles, n), "");
}
else {
/*
};
unsigned i;
- a = LLVMBuildAnd(bld->builder, a,
+ a = LLVMBuildAnd(builder, a,
lp_build_const_mask_aos(bld->gallivm,
type, 1 << channel), "");
type4.width *= 4;
type4.length /= 4;
- a = LLVMBuildBitCast(bld->builder, a, lp_build_vec_type(bld->gallivm, type4), "");
+ a = LLVMBuildBitCast(builder, a, lp_build_vec_type(bld->gallivm, type4), "");
for(i = 0; i < 2; ++i) {
LLVMValueRef tmp = NULL;
#endif
if(shift > 0)
- tmp = LLVMBuildLShr(bld->builder, a, lp_build_const_int_vec(bld->gallivm, type4, shift*type.width), "");
+ tmp = LLVMBuildLShr(builder, a, lp_build_const_int_vec(bld->gallivm, type4, shift*type.width), "");
if(shift < 0)
- tmp = LLVMBuildShl(bld->builder, a, lp_build_const_int_vec(bld->gallivm, type4, -shift*type.width), "");
+ tmp = LLVMBuildShl(builder, a, lp_build_const_int_vec(bld->gallivm, type4, -shift*type.width), "");
assert(tmp);
if(tmp)
- a = LLVMBuildOr(bld->builder, a, tmp, "");
+ a = LLVMBuildOr(builder, a, tmp, "");
}
- return LLVMBuildBitCast(bld->builder, a, lp_build_vec_type(bld->gallivm, type), "");
+ return LLVMBuildBitCast(builder, a, lp_build_vec_type(bld->gallivm, type), "");
}
}
LLVMValueRef a,
const unsigned char swizzles[4])
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const struct lp_type type = bld->type;
const unsigned n = type.length;
unsigned i, j;
}
}
- return LLVMBuildShuffleVector(bld->builder, a,
+ return LLVMBuildShuffleVector(builder, a,
LLVMConstVector(aux, n),
LLVMConstVector(shuffles, n), "");
} else {
type4.width *= 4;
type4.length /= 4;
- a = LLVMBuildBitCast(bld->builder, a, lp_build_vec_type(bld->gallivm, type4), "");
- res = LLVMBuildBitCast(bld->builder, res, lp_build_vec_type(bld->gallivm, type4), "");
+ a = LLVMBuildBitCast(builder, a, lp_build_vec_type(bld->gallivm, type4), "");
+ res = LLVMBuildBitCast(builder, res, lp_build_vec_type(bld->gallivm, type4), "");
/*
* Mask and shift the channels, trying to group as many channels in the
if (0)
debug_printf("shift = %i, mask = 0x%08llx\n", shift, mask);
- masked = LLVMBuildAnd(bld->builder, a,
+ masked = LLVMBuildAnd(builder, a,
lp_build_const_int_vec(bld->gallivm, type4, mask), "");
if (shift > 0) {
- shifted = LLVMBuildShl(bld->builder, masked,
+ shifted = LLVMBuildShl(builder, masked,
lp_build_const_int_vec(bld->gallivm, type4, shift*type.width), "");
} else if (shift < 0) {
- shifted = LLVMBuildLShr(bld->builder, masked,
+ shifted = LLVMBuildLShr(builder, masked,
lp_build_const_int_vec(bld->gallivm, type4, -shift*type.width), "");
} else {
shifted = masked;
}
- res = LLVMBuildOr(bld->builder, res, shifted, "");
+ res = LLVMBuildOr(builder, res, shifted, "");
}
}
- return LLVMBuildBitCast(bld->builder, res,
+ return LLVMBuildBitCast(builder, res,
lp_build_vec_type(bld->gallivm, type), "");
}
}
const struct tgsi_full_instruction *inst,
unsigned src_op)
{
+ LLVMBuilderRef builder = bld->base.gallivm->builder;
struct lp_type type = bld->base.type;
const struct tgsi_full_src_register *reg = &inst->Src[src_op];
LLVMValueRef res;
index = lp_build_const_int32(bld->base.gallivm, reg->Register.Index * 4 + chan);
- scalar_ptr = LLVMBuildGEP(bld->base.builder, bld->consts_ptr,
+ scalar_ptr = LLVMBuildGEP(builder, bld->consts_ptr,
&index, 1, "");
- scalar = LLVMBuildLoad(bld->base.builder, scalar_ptr, "");
+ scalar = LLVMBuildLoad(builder, scalar_ptr, "");
lp_build_name(scalar, "const[%u].%c", reg->Register.Index, "xyzw"[chan]);
swizzle = lp_build_const_int32(bld->base.gallivm, chan);
- res = LLVMBuildInsertElement(bld->base.builder, res, scalar, swizzle, "");
+ res = LLVMBuildInsertElement(builder, res, scalar, swizzle, "");
}
/*
shuffles[i] = shuffles[i % 4];
}
- res = LLVMBuildShuffleVector(bld->base.builder,
+ res = LLVMBuildShuffleVector(builder,
res, bld->base.undef,
LLVMConstVector(shuffles, type.length),
"");
{
LLVMValueRef temp_ptr;
temp_ptr = bld->temps[reg->Register.Index];
- res = LLVMBuildLoad(bld->base.builder, temp_ptr, "");
+ res = LLVMBuildLoad(builder, temp_ptr, "");
if (!res)
return bld->base.undef;
}
unsigned index,
LLVMValueRef value)
{
+ LLVMBuilderRef builder = bld->base.gallivm->builder;
const struct tgsi_full_dst_register *reg = &inst->Dst[index];
LLVMValueRef mask = NULL;
LLVMValueRef ptr;
assert(inst->Predicate.Index < LP_MAX_TGSI_PREDS);
- pred = LLVMBuildLoad(bld->base.builder,
+ pred = LLVMBuildLoad(builder,
bld->preds[inst->Predicate.Index], "");
/*
bld->base.zero);
if (inst->Predicate.Negate) {
- pred = LLVMBuildNot(bld->base.builder, pred, "");
+ pred = LLVMBuildNot(builder, pred, "");
}
pred = swizzle_aos(bld, pred,
inst->Predicate.SwizzleW);
if (mask) {
- mask = LLVMBuildAnd(bld->base.builder, mask, pred, "");
+ mask = LLVMBuildAnd(builder, mask, pred, "");
} else {
mask = pred;
}
reg->Register.WriteMask);
if (mask) {
- mask = LLVMBuildAnd(bld->base.builder, mask, writemask, "");
+ mask = LLVMBuildAnd(builder, mask, writemask, "");
} else {
mask = writemask;
}
if (mask) {
LLVMValueRef orig_value;
- orig_value = LLVMBuildLoad(bld->base.builder, ptr, "");
+ orig_value = LLVMBuildLoad(builder, ptr, "");
value = lp_build_select(&bld->base,
mask, value, orig_value);
}
- LLVMBuildStore(bld->base.builder, value, ptr);
+ LLVMBuildStore(builder, value, ptr);
}
if (0) {
LLVMModuleRef module = LLVMGetGlobalParent(
- LLVMGetBasicBlockParent(LLVMGetInsertBlock(bld.base.builder)));
+ LLVMGetBasicBlockParent(LLVMGetInsertBlock(gallivm->builder)));
LLVMDumpModule(module);
}
static void lp_exec_mask_update(struct lp_exec_mask *mask)
{
+ LLVMBuilderRef builder = mask->bld->gallivm->builder;
+
if (mask->loop_stack_size) {
/*for loops we need to update the entire mask at runtime */
LLVMValueRef tmp;
assert(mask->break_mask);
- tmp = LLVMBuildAnd(mask->bld->builder,
+ tmp = LLVMBuildAnd(builder,
mask->cont_mask,
mask->break_mask,
"maskcb");
- mask->exec_mask = LLVMBuildAnd(mask->bld->builder,
+ mask->exec_mask = LLVMBuildAnd(builder,
mask->cond_mask,
tmp,
"maskfull");
mask->exec_mask = mask->cond_mask;
if (mask->call_stack_size) {
- mask->exec_mask = LLVMBuildAnd(mask->bld->builder,
+ mask->exec_mask = LLVMBuildAnd(builder,
mask->exec_mask,
mask->ret_mask,
"callmask");
static void lp_exec_mask_cond_push(struct lp_exec_mask *mask,
LLVMValueRef val)
{
+ LLVMBuilderRef builder = mask->bld->gallivm->builder;
+
assert(mask->cond_stack_size < LP_MAX_TGSI_NESTING);
if (mask->cond_stack_size == 0) {
assert(mask->cond_mask == LLVMConstAllOnes(mask->int_vec_type));
}
mask->cond_stack[mask->cond_stack_size++] = mask->cond_mask;
assert(LLVMTypeOf(val) == mask->int_vec_type);
- mask->cond_mask = LLVMBuildAnd(mask->bld->builder,
+ mask->cond_mask = LLVMBuildAnd(builder,
mask->cond_mask,
val,
"");
static void lp_exec_mask_cond_invert(struct lp_exec_mask *mask)
{
+ LLVMBuilderRef builder = mask->bld->gallivm->builder;
LLVMValueRef prev_mask;
LLVMValueRef inv_mask;
assert(prev_mask == LLVMConstAllOnes(mask->int_vec_type));
}
- inv_mask = LLVMBuildNot(mask->bld->builder, mask->cond_mask, "");
+ inv_mask = LLVMBuildNot(builder, mask->cond_mask, "");
- mask->cond_mask = LLVMBuildAnd(mask->bld->builder,
+ mask->cond_mask = LLVMBuildAnd(builder,
inv_mask,
prev_mask, "");
lp_exec_mask_update(mask);
static void lp_exec_bgnloop(struct lp_exec_mask *mask)
{
+ LLVMBuilderRef builder = mask->bld->gallivm->builder;
+
if (mask->loop_stack_size == 0) {
assert(mask->loop_block == NULL);
assert(mask->cont_mask == LLVMConstAllOnes(mask->int_vec_type));
++mask->loop_stack_size;
mask->break_var = lp_build_alloca(mask->bld->gallivm, mask->int_vec_type, "");
- LLVMBuildStore(mask->bld->builder, mask->break_mask, mask->break_var);
+ LLVMBuildStore(builder, mask->break_mask, mask->break_var);
mask->loop_block = lp_build_insert_new_block(mask->bld->gallivm, "bgnloop");
- LLVMBuildBr(mask->bld->builder, mask->loop_block);
- LLVMPositionBuilderAtEnd(mask->bld->builder, mask->loop_block);
+ LLVMBuildBr(builder, mask->loop_block);
+ LLVMPositionBuilderAtEnd(builder, mask->loop_block);
- mask->break_mask = LLVMBuildLoad(mask->bld->builder, mask->break_var, "");
+ mask->break_mask = LLVMBuildLoad(builder, mask->break_var, "");
lp_exec_mask_update(mask);
}
static void lp_exec_break(struct lp_exec_mask *mask)
{
- LLVMValueRef exec_mask = LLVMBuildNot(mask->bld->builder,
+ LLVMBuilderRef builder = mask->bld->gallivm->builder;
+ LLVMValueRef exec_mask = LLVMBuildNot(builder,
mask->exec_mask,
"break");
- mask->break_mask = LLVMBuildAnd(mask->bld->builder,
+ mask->break_mask = LLVMBuildAnd(builder,
mask->break_mask,
exec_mask, "break_full");
static void lp_exec_continue(struct lp_exec_mask *mask)
{
- LLVMValueRef exec_mask = LLVMBuildNot(mask->bld->builder,
+ LLVMBuilderRef builder = mask->bld->gallivm->builder;
+ LLVMValueRef exec_mask = LLVMBuildNot(builder,
mask->exec_mask,
"");
- mask->cont_mask = LLVMBuildAnd(mask->bld->builder,
+ mask->cont_mask = LLVMBuildAnd(builder,
mask->cont_mask,
exec_mask, "");
static void lp_exec_endloop(struct gallivm_state *gallivm,
struct lp_exec_mask *mask)
{
+ LLVMBuilderRef builder = mask->bld->gallivm->builder;
LLVMBasicBlockRef endloop;
LLVMTypeRef reg_type = LLVMIntTypeInContext(gallivm->context,
mask->bld->type.width *
* Unlike the continue mask, the break_mask must be preserved across loop
* iterations
*/
- LLVMBuildStore(mask->bld->builder, mask->break_mask, mask->break_var);
+ LLVMBuildStore(builder, mask->break_mask, mask->break_var);
/* i1cond = (mask == 0) */
i1cond = LLVMBuildICmp(
- mask->bld->builder,
+ builder,
LLVMIntNE,
- LLVMBuildBitCast(mask->bld->builder, mask->exec_mask, reg_type, ""),
+ LLVMBuildBitCast(builder, mask->exec_mask, reg_type, ""),
LLVMConstNull(reg_type), "");
endloop = lp_build_insert_new_block(mask->bld->gallivm, "endloop");
- LLVMBuildCondBr(mask->bld->builder,
+ LLVMBuildCondBr(builder,
i1cond, mask->loop_block, endloop);
- LLVMPositionBuilderAtEnd(mask->bld->builder, endloop);
+ LLVMPositionBuilderAtEnd(builder, endloop);
assert(mask->loop_stack_size);
--mask->loop_stack_size;
LLVMValueRef val,
LLVMValueRef dst)
{
+ LLVMBuilderRef builder = mask->bld->gallivm->builder;
+
/* Mix the predicate and execution mask */
if (mask->has_mask) {
if (pred) {
- pred = LLVMBuildAnd(mask->bld->builder, pred, mask->exec_mask, "");
+ pred = LLVMBuildAnd(builder, pred, mask->exec_mask, "");
} else {
pred = mask->exec_mask;
}
if (pred) {
LLVMValueRef real_val, dst_val;
- dst_val = LLVMBuildLoad(mask->bld->builder, dst, "");
+ dst_val = LLVMBuildLoad(builder, dst, "");
real_val = lp_build_select(mask->bld,
pred,
val, dst_val);
- LLVMBuildStore(mask->bld->builder, real_val, dst);
+ LLVMBuildStore(builder, real_val, dst);
} else
- LLVMBuildStore(mask->bld->builder, val, dst);
+ LLVMBuildStore(builder, val, dst);
}
static void lp_exec_mask_call(struct lp_exec_mask *mask,
static void lp_exec_mask_ret(struct lp_exec_mask *mask, int *pc)
{
+ LLVMBuilderRef builder = mask->bld->gallivm->builder;
LLVMValueRef exec_mask;
if (mask->call_stack_size == 0) {
*pc = -1;
return;
}
- exec_mask = LLVMBuildNot(mask->bld->builder,
+ exec_mask = LLVMBuildNot(builder,
mask->exec_mask,
"ret");
- mask->ret_mask = LLVMBuildAnd(mask->bld->builder,
+ mask->ret_mask = LLVMBuildAnd(builder,
mask->ret_mask,
exec_mask, "ret_full");
unsigned index,
unsigned chan)
{
+ LLVMBuilderRef builder = bld->base.gallivm->builder;
assert(chan < 4);
if (bld->indirect_files & (1 << TGSI_FILE_TEMPORARY)) {
LLVMValueRef lindex = lp_build_const_int32(bld->base.gallivm, index * 4 + chan);
- return LLVMBuildGEP(bld->base.builder, bld->temps_array, &lindex, 1, "");
+ return LLVMBuildGEP(builder, bld->temps_array, &lindex, 1, "");
}
else {
return bld->temps[index][chan];
unsigned index,
unsigned chan)
{
+ LLVMBuilderRef builder = bld->base.gallivm->builder;
assert(chan < 4);
if (bld->indirect_files & (1 << TGSI_FILE_OUTPUT)) {
LLVMValueRef lindex = lp_build_const_int32(bld->base.gallivm,
index * 4 + chan);
- return LLVMBuildGEP(bld->base.builder, bld->outputs_array, &lindex, 1, "");
+ return LLVMBuildGEP(builder, bld->outputs_array, &lindex, 1, "");
}
else {
return bld->outputs[index][chan];
LLVMValueRef base_ptr,
LLVMValueRef indexes)
{
+ LLVMBuilderRef builder = bld->base.gallivm->builder;
LLVMValueRef res = bld->base.undef;
unsigned i;
*/
for (i = 0; i < bld->base.type.length; i++) {
LLVMValueRef ii = lp_build_const_int32(bld->base.gallivm, i);
- LLVMValueRef index = LLVMBuildExtractElement(bld->base.builder,
+ LLVMValueRef index = LLVMBuildExtractElement(builder,
indexes, ii, "");
- LLVMValueRef scalar_ptr = LLVMBuildGEP(bld->base.builder, base_ptr,
+ LLVMValueRef scalar_ptr = LLVMBuildGEP(builder, base_ptr,
&index, 1, "gather_ptr");
- LLVMValueRef scalar = LLVMBuildLoad(bld->base.builder, scalar_ptr, "");
+ LLVMValueRef scalar = LLVMBuildLoad(builder, scalar_ptr, "");
- res = LLVMBuildInsertElement(bld->base.builder, res, scalar, ii, "");
+ res = LLVMBuildInsertElement(builder, res, scalar, ii, "");
}
return res;
LLVMValueRef pred)
{
struct gallivm_state *gallivm = bld->base.gallivm;
- LLVMBuilderRef builder = bld->base.builder;
+ LLVMBuilderRef builder = builder;
unsigned i;
/* Mix the predicate and execution mask */
if (mask->has_mask) {
if (pred) {
- pred = LLVMBuildAnd(mask->bld->builder, pred, mask->exec_mask, "");
+ pred = LLVMBuildAnd(builder, pred, mask->exec_mask, "");
}
else {
pred = mask->exec_mask;
unsigned reg_file, unsigned reg_index,
const struct tgsi_src_register *indirect_reg)
{
+ LLVMBuilderRef builder = bld->base.gallivm->builder;
struct lp_build_context *uint_bld = &bld->uint_bld;
/* always use X component of address register */
unsigned swizzle = indirect_reg->SwizzleX;
base = lp_build_const_int_vec(bld->base.gallivm, uint_bld->type, reg_index);
assert(swizzle < 4);
- rel = LLVMBuildLoad(bld->base.builder,
+ rel = LLVMBuildLoad(builder,
bld->addr[indirect_reg->Index][swizzle],
"load addr reg");
/* for indexing we want integers */
- rel = LLVMBuildFPToSI(bld->base.builder,
+ rel = LLVMBuildFPToSI(builder,
rel,
uint_bld->vec_type, "");
const unsigned chan_index )
{
struct gallivm_state *gallivm = bld->base.gallivm;
+ LLVMBuilderRef builder = gallivm->builder;
struct lp_build_context *uint_bld = &bld->uint_bld;
const struct tgsi_full_src_register *reg = &inst->Src[src_op];
const unsigned swizzle =
index = lp_build_const_int32(gallivm, reg->Register.Index*4 + swizzle);
- scalar_ptr = LLVMBuildGEP(bld->base.builder, bld->consts_ptr,
+ scalar_ptr = LLVMBuildGEP(builder, bld->consts_ptr,
&index, 1, "");
- scalar = LLVMBuildLoad(bld->base.builder, scalar_ptr, "");
+ scalar = LLVMBuildLoad(builder, scalar_ptr, "");
res = lp_build_broadcast_scalar(&bld->base, scalar);
}
/* cast inputs_array pointer to float* */
float4_ptr_type = LLVMPointerType(LLVMFloatTypeInContext(gallivm->context), 0);
- inputs_array = LLVMBuildBitCast(uint_bld->builder, bld->inputs_array,
- float4_ptr_type, "");
+ inputs_array = LLVMBuildBitCast(builder, bld->inputs_array,
+ float4_ptr_type, "");
/* Gather values from the temporary register array */
res = build_gather(bld, inputs_array, index_vec);
if (bld->indirect_files & (1 << TGSI_FILE_INPUT)) {
LLVMValueRef lindex = lp_build_const_int32(gallivm,
reg->Register.Index * 4 + swizzle);
- LLVMValueRef input_ptr = LLVMBuildGEP(bld->base.builder,
+ LLVMValueRef input_ptr = LLVMBuildGEP(builder,
bld->inputs_array, &lindex, 1, "");
- res = LLVMBuildLoad(bld->base.builder, input_ptr, "");
+ res = LLVMBuildLoad(builder, input_ptr, "");
}
else {
res = bld->inputs[reg->Register.Index][swizzle];
/* cast temps_array pointer to float* */
float4_ptr_type = LLVMPointerType(LLVMFloatTypeInContext(bld->base.gallivm->context), 0);
- temps_array = LLVMBuildBitCast(uint_bld->builder, bld->temps_array,
+ temps_array = LLVMBuildBitCast(builder, bld->temps_array,
float4_ptr_type, "");
/* Gather values from the temporary register array */
else {
LLVMValueRef temp_ptr;
temp_ptr = get_temp_ptr(bld, reg->Register.Index, swizzle);
- res = LLVMBuildLoad(bld->base.builder, temp_ptr, "");
+ res = LLVMBuildLoad(builder, temp_ptr, "");
if (!res)
return bld->base.undef;
}
const struct tgsi_full_instruction *inst,
LLVMValueRef *pred)
{
+ LLVMBuilderRef builder = bld->base.gallivm->builder;
unsigned index;
unsigned char swizzles[4];
LLVMValueRef unswizzled[4] = {NULL, NULL, NULL, NULL};
* in the swizzles
*/
if (!unswizzled[swizzle]) {
- value = LLVMBuildLoad(bld->base.builder,
+ value = LLVMBuildLoad(builder,
bld->preds[index][swizzle], "");
/*
value,
bld->base.zero);
if (inst->Predicate.Negate) {
- value = LLVMBuildNot(bld->base.builder, value, "");
+ value = LLVMBuildNot(builder, value, "");
}
unswizzled[swizzle] = value;
switch( reg->Register.File ) {
case TGSI_FILE_OUTPUT:
if (reg->Register.Indirect) {
- LLVMBuilderRef builder = bld->base.builder;
+ LLVMBuilderRef builder = builder;
LLVMValueRef chan_vec =
lp_build_const_int_vec(gallivm, uint_bld->type, chan_index);
LLVMValueRef length_vec =
case TGSI_FILE_TEMPORARY:
if (reg->Register.Indirect) {
- LLVMBuilderRef builder = bld->base.builder;
+ LLVMBuilderRef builder = builder;
LLVMValueRef chan_vec =
lp_build_const_int_vec(gallivm, uint_bld->type, chan_index);
LLVMValueRef length_vec =
enum lp_build_tex_modifier modifier,
LLVMValueRef *texel)
{
+ LLVMBuilderRef builder = bld->base.gallivm->builder;
unsigned unit;
LLVMValueRef lod_bias, explicit_lod;
LLVMValueRef oow = NULL;
for (i = 0; i < num_coords; i++) {
LLVMValueRef src1 = emit_fetch( bld, inst, 1, i );
LLVMValueRef src2 = emit_fetch( bld, inst, 2, i );
- ddx[i] = LLVMBuildExtractElement(bld->base.builder, src1, index0, "");
- ddy[i] = LLVMBuildExtractElement(bld->base.builder, src2, index0, "");
+ ddx[i] = LLVMBuildExtractElement(builder, src1, index0, "");
+ ddy[i] = LLVMBuildExtractElement(builder, src2, index0, "");
}
unit = inst->Src[3].Register.Index;
} else {
const struct tgsi_full_instruction *inst,
int pc)
{
+ LLVMBuilderRef builder = bld->base.gallivm->builder;
const struct tgsi_full_src_register *reg = &inst->Src[0];
LLVMValueRef terms[NUM_CHANNELS];
LLVMValueRef mask;
chan_mask = lp_build_cmp(&bld->base, PIPE_FUNC_GEQUAL, terms[chan_index], bld->base.zero);
if(mask)
- mask = LLVMBuildAnd(bld->base.builder, mask, chan_mask, "");
+ mask = LLVMBuildAnd(builder, mask, chan_mask, "");
else
mask = chan_mask;
}
const struct tgsi_full_instruction *inst,
int pc)
{
+ LLVMBuilderRef builder = bld->base.gallivm->builder;
LLVMValueRef mask;
/* For those channels which are "alive", disable fragment shader
* execution.
*/
if (bld->exec_mask.has_mask) {
- mask = LLVMBuildNot(bld->base.builder, bld->exec_mask.exec_mask, "kilp");
+ mask = LLVMBuildNot(builder, bld->exec_mask.exec_mask, "kilp");
}
else {
LLVMValueRef zero = LLVMConstNull(bld->base.int_vec_type);
for (chan = 0; chan < 4; chan++) {
temp_ptr = get_temp_ptr(bld, index, chan);
- res = LLVMBuildLoad(bld->base.builder, temp_ptr, "");
+ res = LLVMBuildLoad(builder, temp_ptr, "");
v[chan][0] = LLVMBuildExtractElement(builder, res, i0, "");
v[chan][1] = LLVMBuildExtractElement(builder, res, i1, "");
v[chan][2] = LLVMBuildExtractElement(builder, res, i2, "");
LLVMValueRef lindex =
lp_build_const_int32(gallivm, index * 4 + chan);
LLVMValueRef input_ptr =
- LLVMBuildGEP(bld.base.builder, bld.inputs_array,
+ LLVMBuildGEP(gallivm->builder, bld.inputs_array,
&lindex, 1, "");
LLVMValueRef value = bld.inputs[index][chan];
if (value)
- LLVMBuildStore(bld.base.builder, value, input_ptr);
+ LLVMBuildStore(gallivm->builder, value, input_ptr);
}
}
}
if (0) {
LLVMModuleRef module = LLVMGetGlobalParent(
- LLVMGetBasicBlockParent(LLVMGetInsertBlock(bld.base.builder)));
+ LLVMGetBasicBlockParent(LLVMGetInsertBlock(gallivm->builder)));
LLVMDumpModule(module);
}
struct lp_type type)
{
bld->gallivm = gallivm;
- bld->builder = gallivm->builder;
bld->type = type;
bld->int_elem_type = lp_build_int_elem_type(gallivm, type);
*/
struct lp_build_context
{
- LLVMBuilderRef builder;
-
struct gallivm_state *gallivm;
/**
LLVMValueRef stencilRef,
LLVMValueRef stencilVals)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
const unsigned stencilMax = 255; /* XXX fix */
struct lp_type type = bld->type;
LLVMValueRef res;
if (stencil->valuemask != stencilMax) {
/* compute stencilRef = stencilRef & valuemask */
LLVMValueRef valuemask = lp_build_const_int_vec(bld->gallivm, type, stencil->valuemask);
- stencilRef = LLVMBuildAnd(bld->builder, stencilRef, valuemask, "");
+ stencilRef = LLVMBuildAnd(builder, stencilRef, valuemask, "");
/* compute stencilVals = stencilVals & valuemask */
- stencilVals = LLVMBuildAnd(bld->builder, stencilVals, valuemask, "");
+ stencilVals = LLVMBuildAnd(builder, stencilVals, valuemask, "");
}
res = lp_build_cmp(bld, stencil->func, stencilRef, stencilVals);
LLVMValueRef stencilVals)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
struct lp_type type = bld->type;
LLVMValueRef res;
LLVMValueRef max = lp_build_const_int_vec(bld->gallivm, type, 0xff);
break;
case PIPE_STENCIL_OP_INCR_WRAP:
res = lp_build_add(bld, stencilVals, bld->one);
- res = LLVMBuildAnd(bld->builder, res, max, "");
+ res = LLVMBuildAnd(builder, res, max, "");
break;
case PIPE_STENCIL_OP_DECR_WRAP:
res = lp_build_sub(bld, stencilVals, bld->one);
- res = LLVMBuildAnd(bld->builder, res, max, "");
+ res = LLVMBuildAnd(builder, res, max, "");
break;
case PIPE_STENCIL_OP_INVERT:
- res = LLVMBuildNot(bld->builder, stencilVals, "");
- res = LLVMBuildAnd(bld->builder, res, max, "");
+ res = LLVMBuildNot(builder, stencilVals, "");
+ res = LLVMBuildAnd(builder, res, max, "");
break;
default:
assert(0 && "bad stencil op mode");
LLVMValueRef front_facing)
{
+ LLVMBuilderRef builder = bld->gallivm->builder;
LLVMValueRef res;
assert(stencil[0].enabled);
/* mask &= stencil->writemask */
LLVMValueRef writemask = lp_build_const_int_vec(bld->gallivm, bld->type,
stencil->writemask);
- mask = LLVMBuildAnd(bld->builder, mask, writemask, "");
+ mask = LLVMBuildAnd(builder, mask, writemask, "");
/* res = (res & mask) | (stencilVals & ~mask) */
res = lp_build_select_bitwise(bld, writemask, res, stencilVals);
}
z_fail_mask, front_facing);
/* apply Z-pass operator */
- z_pass_mask = LLVMBuildAnd(z_bld.builder, orig_mask, z_pass, "");
+ z_pass_mask = LLVMBuildAnd(builder, orig_mask, z_pass, "");
stencil_vals = lp_build_stencil_op(&s_bld, stencil, Z_PASS_OP,
stencil_refs, stencil_vals,
z_pass_mask, front_facing);
/* No depth test: apply Z-pass operator to stencil buffer values which
* passed the stencil test.
*/
- s_pass_mask = LLVMBuildAnd(s_bld.builder, orig_mask, s_pass_mask, "");
+ s_pass_mask = LLVMBuildAnd(builder, orig_mask, s_pass_mask, "");
stencil_vals = lp_build_stencil_op(&s_bld, stencil, Z_PASS_OP,
stencil_refs, stencil_vals,
s_pass_mask, front_facing);
z_dst = LLVMBuildShl(builder, z_dst, shift, "");
}
if (stencil_vals && stencil_shift)
- stencil_vals = LLVMBuildShl(s_bld.builder, stencil_vals,
+ stencil_vals = LLVMBuildShl(builder, stencil_vals,
stencil_shift, "");
/* Finally, merge/store the z/stencil values */
(stencil[0].enabled && stencil[0].writemask)) {
if (z_dst && stencil_vals)
- zs_dst = LLVMBuildOr(z_bld.builder, z_dst, stencil_vals, "");
+ zs_dst = LLVMBuildOr(builder, z_dst, stencil_vals, "");
else if (z_dst)
zs_dst = z_dst;
else
LLVMValueRef dady_ptr)
{
struct lp_build_context *coeff_bld = &bld->coeff_bld;
- LLVMBuilderRef builder = coeff_bld->builder;
struct gallivm_state *gallivm = coeff_bld->gallivm;
+ LLVMBuilderRef builder = gallivm->builder;
LLVMValueRef zero = LLVMConstNull(coeff_bld->elem_type);
LLVMValueRef one = LLVMConstReal(coeff_bld->elem_type, 1.0);
LLVMValueRef i0 = lp_build_const_int32(gallivm, 0);
int start,
int end)
{
+ LLVMBuilderRef builder = gallivm->builder;
struct lp_build_context *coeff_bld = &bld->coeff_bld;
LLVMValueRef shuffle = lp_build_const_int_vec(gallivm, coeff_bld->type, quad_index);
LLVMValueRef oow = NULL;
* Broadcast the attribute value for this quad into all elements
*/
- a = LLVMBuildShuffleVector(coeff_bld->builder,
+ a = LLVMBuildShuffleVector(builder,
a, coeff_bld->undef, shuffle, "");
/*
LLVMValueRef x0,
LLVMValueRef y0)
{
+ LLVMBuilderRef builder = bld->coeff_bld.gallivm->builder;
struct lp_build_context *coeff_bld = &bld->coeff_bld;
- bld->x = LLVMBuildSIToFP(coeff_bld->builder, x0, coeff_bld->elem_type, "");
- bld->y = LLVMBuildSIToFP(coeff_bld->builder, y0, coeff_bld->elem_type, "");
+ bld->x = LLVMBuildSIToFP(builder, x0, coeff_bld->elem_type, "");
+ bld->y = LLVMBuildSIToFP(builder, y0, coeff_bld->elem_type, "");
}