Regarding the recent addition of llvmpipe I decided to try it out and
found that it wouldn't compile using gcc 4.4 but would using gcc 4.3. I
tracked the bug down to the -std=c99 flag and it was caused by an
illegal declaration:
union U
{
struct
{
short a;
short b;
};
int c;
};
With this declaration a non-conforming compiler will accept access to
U::a and U::b however gcc 4.4 does actually conform to C99 which means
that this is illegal.
The correct declaration goes:
union U
{
struct
{
short a;
short b;
} v;
int c;
};
The values are accessed through U::v::a and U::v::b. I made a patch that
lets it compile. I also patched (not included here) the radeon winsys to
use llvmpipe instead of softpipe to test it but it doesn't appear to
work too well. I can't find any declaration of LLVMBuildNot anywhere
though, so can someone tell me what I'm doing wrong?
libGL error: dlopen ./r300_dri.so failed (./r300_dri.so: undefined
symbol: LLVMBuildNot)
>From ff1dd87762a98cc93a800fe96e7a96357e5f69d3 Mon Sep 17 00:00:00 2001
From: Joakim Sindholt <[email protected]>
Date: Sat, 29 Aug 2009 15:07:01 +0200
Subject: [PATCH] llvmpipe: conform to C99
---
src/gallium/drivers/llvmpipe/lp_bld_arit.c | 128 ++++++++++----------
src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c | 2 +-
src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c | 4 +-
src/gallium/drivers/llvmpipe/lp_bld_const.c | 118 ++++++++++----------
src/gallium/drivers/llvmpipe/lp_bld_conv.c | 140 +++++++++++-----------
src/gallium/drivers/llvmpipe/lp_bld_depth.c | 20 ++--
src/gallium/drivers/llvmpipe/lp_bld_flow.c | 2 +-
src/gallium/drivers/llvmpipe/lp_bld_logic.c | 28 +++---
src/gallium/drivers/llvmpipe/lp_bld_swizzle.c | 16 ++--
src/gallium/drivers/llvmpipe/lp_bld_type.c | 20 ++--
src/gallium/drivers/llvmpipe/lp_bld_type.h | 2 +-
src/gallium/drivers/llvmpipe/lp_state_fs.c | 34 +++---
12 files changed, 257 insertions(+), 257 deletions(-)
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_arit.c b/src/gallium/drivers/llvmpipe/lp_bld_arit.c
index 710e624..2b709ce 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_arit.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_arit.c
@@ -71,25 +71,25 @@ lp_build_min_simple(struct lp_build_context *bld,
/* TODO: optimize the constant case */
#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
- if(type.width * type.length == 128) {
- if(type.floating) {
- if(type.width == 32)
+ if(type.vec.width * type.vec.length == 128) {
+ if(type.vec.floating) {
+ if(type.vec.width == 32)
intrinsic = "llvm.x86.sse.min.ps";
- if(type.width == 64)
+ if(type.vec.width == 64)
intrinsic = "llvm.x86.sse2.min.pd";
}
else {
- if(type.width == 8 && !type.sign)
+ if(type.vec.width == 8 && !type.vec.sign)
intrinsic = "llvm.x86.sse2.pminu.b";
- if(type.width == 8 && type.sign)
+ if(type.vec.width == 8 && type.vec.sign)
intrinsic = "llvm.x86.sse41.pminsb";
- if(type.width == 16 && !type.sign)
+ if(type.vec.width == 16 && !type.vec.sign)
intrinsic = "llvm.x86.sse41.pminuw";
- if(type.width == 16 && type.sign)
+ if(type.vec.width == 16 && type.vec.sign)
intrinsic = "llvm.x86.sse2.pmins.w";
- if(type.width == 32 && !type.sign)
+ if(type.vec.width == 32 && !type.vec.sign)
intrinsic = "llvm.x86.sse41.pminud";
- if(type.width == 32 && type.sign)
+ if(type.vec.width == 32 && type.vec.sign)
intrinsic = "llvm.x86.sse41.pminsd";
}
}
@@ -98,10 +98,10 @@ lp_build_min_simple(struct lp_build_context *bld,
if(intrinsic)
return lp_build_intrinsic_binary(bld->builder, intrinsic, lp_build_vec_type(bld->type), a, b);
- if(type.floating)
+ if(type.vec.floating)
cond = LLVMBuildFCmp(bld->builder, LLVMRealULT, a, b, "");
else
- cond = LLVMBuildICmp(bld->builder, type.sign ? LLVMIntSLT : LLVMIntULT, a, b, "");
+ cond = LLVMBuildICmp(bld->builder, type.vec.sign ? LLVMIntSLT : LLVMIntULT, a, b, "");
return LLVMBuildSelect(bld->builder, cond, a, b, "");
}
@@ -122,25 +122,25 @@ lp_build_max_simple(struct lp_build_context *bld,
/* TODO: optimize the constant case */
#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
- if(type.width * type.length == 128) {
- if(type.floating) {
- if(type.width == 32)
+ if(type.vec.width * type.vec.length == 128) {
+ if(type.vec.floating) {
+ if(type.vec.width == 32)
intrinsic = "llvm.x86.sse.max.ps";
- if(type.width == 64)
+ if(type.vec.width == 64)
intrinsic = "llvm.x86.sse2.max.pd";
}
else {
- if(type.width == 8 && !type.sign)
+ if(type.vec.width == 8 && !type.vec.sign)
intrinsic = "llvm.x86.sse2.pmaxu.b";
- if(type.width == 8 && type.sign)
+ if(type.vec.width == 8 && type.vec.sign)
intrinsic = "llvm.x86.sse41.pmaxsb";
- if(type.width == 16 && !type.sign)
+ if(type.vec.width == 16 && !type.vec.sign)
intrinsic = "llvm.x86.sse41.pmaxuw";
- if(type.width == 16 && type.sign)
+ if(type.vec.width == 16 && type.vec.sign)
intrinsic = "llvm.x86.sse2.pmaxs.w";
- if(type.width == 32 && !type.sign)
+ if(type.vec.width == 32 && !type.vec.sign)
intrinsic = "llvm.x86.sse41.pmaxud";
- if(type.width == 32 && type.sign)
+ if(type.vec.width == 32 && type.vec.sign)
intrinsic = "llvm.x86.sse41.pmaxsd";
}
}
@@ -149,16 +149,16 @@ lp_build_max_simple(struct lp_build_context *bld,
if(intrinsic)
return lp_build_intrinsic_binary(bld->builder, intrinsic, lp_build_vec_type(bld->type), a, b);
- if(type.floating)
+ if(type.vec.floating)
cond = LLVMBuildFCmp(bld->builder, LLVMRealULT, a, b, "");
else
- cond = LLVMBuildICmp(bld->builder, type.sign ? LLVMIntSLT : LLVMIntULT, a, b, "");
+ cond = LLVMBuildICmp(bld->builder, type.vec.sign ? LLVMIntSLT : LLVMIntULT, a, b, "");
return LLVMBuildSelect(bld->builder, cond, b, a, "");
}
/**
- * Generate 1 - a, or ~a depending on bld->type.
+ * Generate 1 - a, or ~a depending on bld->type.vec.
*/
LLVMValueRef
lp_build_comp(struct lp_build_context *bld,
@@ -171,7 +171,7 @@ lp_build_comp(struct lp_build_context *bld,
if(a == bld->zero)
return bld->one;
- if(type.norm && !type.floating && !type.fixed && !type.sign) {
+ if(type.vec.norm && !type.vec.floating && !type.vec.fixed && !type.vec.sign) {
if(LLVMIsConstant(a))
return LLVMConstNot(a);
else
@@ -203,19 +203,19 @@ lp_build_add(struct lp_build_context *bld,
if(a == bld->undef || b == bld->undef)
return bld->undef;
- if(bld->type.norm) {
+ if(bld->type.vec.norm) {
const char *intrinsic = NULL;
if(a == bld->one || b == bld->one)
return bld->one;
#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
- if(type.width * type.length == 128 &&
- !type.floating && !type.fixed) {
- if(type.width == 8)
- intrinsic = type.sign ? "llvm.x86.sse2.padds.b" : "llvm.x86.sse2.paddus.b";
- if(type.width == 16)
- intrinsic = type.sign ? "llvm.x86.sse2.padds.w" : "llvm.x86.sse2.paddus.w";
+ if(type.vec.width * type.vec.length == 128 &&
+ !type.vec.floating && !type.vec.fixed) {
+ if(type.vec.width == 8)
+ intrinsic = type.vec.sign ? "llvm.x86.sse2.padds.b" : "llvm.x86.sse2.paddus.b";
+ if(type.vec.width == 16)
+ intrinsic = type.vec.sign ? "llvm.x86.sse2.padds.w" : "llvm.x86.sse2.paddus.w";
}
#endif
@@ -229,7 +229,7 @@ lp_build_add(struct lp_build_context *bld,
res = LLVMBuildAdd(bld->builder, a, b, "");
/* clamp to ceiling of 1.0 */
- if(bld->type.norm && (bld->type.floating || bld->type.fixed))
+ if(bld->type.vec.norm && (bld->type.vec.floating || bld->type.vec.fixed))
res = lp_build_min_simple(bld, res, bld->one);
/* XXX clamp to floor of -1 or 0??? */
@@ -256,19 +256,19 @@ lp_build_sub(struct lp_build_context *bld,
if(a == b)
return bld->zero;
- if(bld->type.norm) {
+ if(bld->type.vec.norm) {
const char *intrinsic = NULL;
if(b == bld->one)
return bld->zero;
#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
- if(type.width * type.length == 128 &&
- !type.floating && !type.fixed) {
- if(type.width == 8)
- intrinsic = type.sign ? "llvm.x86.sse2.psubs.b" : "llvm.x86.sse2.psubus.b";
- if(type.width == 16)
- intrinsic = type.sign ? "llvm.x86.sse2.psubs.w" : "llvm.x86.sse2.psubus.w";
+ if(type.vec.width * type.vec.length == 128 &&
+ !type.vec.floating && !type.vec.fixed) {
+ if(type.vec.width == 8)
+ intrinsic = type.vec.sign ? "llvm.x86.sse2.psubs.b" : "llvm.x86.sse2.psubus.b";
+ if(type.vec.width == 16)
+ intrinsic = type.vec.sign ? "llvm.x86.sse2.psubs.w" : "llvm.x86.sse2.psubus.w";
}
#endif
@@ -281,7 +281,7 @@ lp_build_sub(struct lp_build_context *bld,
else
res = LLVMBuildSub(bld->builder, a, b, "");
- if(bld->type.norm && (bld->type.floating || bld->type.fixed))
+ if(bld->type.vec.norm && (bld->type.vec.floating || bld->type.vec.fixed))
res = lp_build_max_simple(bld, res, bld->zero);
return res;
@@ -423,9 +423,9 @@ lp_build_mul(struct lp_build_context *bld,
if(a == bld->undef || b == bld->undef)
return bld->undef;
- if(!type.floating && !type.fixed && type.norm) {
+ if(!type.vec.floating && !type.vec.fixed && type.vec.norm) {
#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
- if(type.width == 8 && type.length == 16) {
+ if(type.vec.width == 8 && type.vec.length == 16) {
LLVMTypeRef i16x8 = LLVMVectorType(LLVMInt16Type(), 8);
LLVMTypeRef i8x16 = LLVMVectorType(LLVMInt8Type(), 16);
static LLVMValueRef ml = NULL;
@@ -499,7 +499,7 @@ lp_build_div(struct lp_build_context *bld,
return LLVMConstFDiv(a, b);
#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
- if(type.width == 32 && type.length == 4)
+ if(type.vec.width == 32 && type.vec.length == 4)
return lp_build_mul(bld, a, lp_build_rcp(bld, b));
#endif
@@ -522,7 +522,7 @@ lp_build_min(struct lp_build_context *bld,
if(a == b)
return a;
- if(bld->type.norm) {
+ if(bld->type.vec.norm) {
if(a == bld->zero || b == bld->zero)
return bld->zero;
if(a == bld->one)
@@ -550,7 +550,7 @@ lp_build_max(struct lp_build_context *bld,
if(a == b)
return a;
- if(bld->type.norm) {
+ if(bld->type.vec.norm) {
if(a == bld->one || b == bld->one)
return bld->one;
if(a == bld->zero)
@@ -572,18 +572,18 @@ lp_build_abs(struct lp_build_context *bld,
{
const union lp_type type = bld->type;
- if(!type.sign)
+ if(!type.vec.sign)
return a;
/* XXX: is this really necessary? */
#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
- if(!type.floating && type.width*type.length == 128) {
+ if(!type.vec.floating && type.vec.width*type.vec.length == 128) {
LLVMTypeRef vec_type = lp_build_vec_type(type);
- if(type.width == 8)
+ if(type.vec.width == 8)
return lp_build_intrinsic_unary(bld->builder, "llvm.x86.ssse3.pabs.b.128", vec_type, a);
- if(type.width == 16)
+ if(type.vec.width == 16)
return lp_build_intrinsic_unary(bld->builder, "llvm.x86.ssse3.pabs.w.128", vec_type, a);
- if(type.width == 32)
+ if(type.vec.width == 32)
return lp_build_intrinsic_unary(bld->builder, "llvm.x86.ssse3.pabs.d.128", vec_type, a);
}
#endif
@@ -603,8 +603,8 @@ lp_build_sqrt(struct lp_build_context *bld,
/* TODO: optimize the constant case */
/* TODO: optimize the constant case */
- assert(type.floating);
- util_snprintf(intrinsic, sizeof intrinsic, "llvm.sqrt.v%uf%u", type.length, type.width);
+ assert(type.vec.floating);
+ util_snprintf(intrinsic, sizeof intrinsic, "llvm.sqrt.v%uf%u", type.vec.length, type.vec.width);
return lp_build_intrinsic_unary(bld->builder, intrinsic, vec_type, a);
}
@@ -623,14 +623,14 @@ lp_build_rcp(struct lp_build_context *bld,
if(a == bld->undef)
return bld->undef;
- assert(type.floating);
+ assert(type.vec.floating);
if(LLVMIsConstant(a))
return LLVMConstFDiv(bld->one, a);
/* XXX: is this really necessary? */
#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
- if(type.width == 32 && type.length == 4)
+ if(type.vec.width == 32 && type.vec.length == 4)
return lp_build_intrinsic_unary(bld->builder, "llvm.x86.sse.rcp.ps", lp_build_vec_type(type), a);
#endif
@@ -647,11 +647,11 @@ lp_build_rsqrt(struct lp_build_context *bld,
{
const union lp_type type = bld->type;
- assert(type.floating);
+ assert(type.vec.floating);
/* XXX: is this really necessary? */
#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
- if(type.width == 32 && type.length == 4)
+ if(type.vec.width == 32 && type.vec.length == 4)
return lp_build_intrinsic_unary(bld->builder, "llvm.x86.sse.rsqrt.ps", lp_build_vec_type(type), a);
#endif
@@ -672,8 +672,8 @@ lp_build_cos(struct lp_build_context *bld,
/* TODO: optimize the constant case */
- assert(type.floating);
- util_snprintf(intrinsic, sizeof intrinsic, "llvm.cos.v%uf%u", type.length, type.width);
+ assert(type.vec.floating);
+ util_snprintf(intrinsic, sizeof intrinsic, "llvm.cos.v%uf%u", type.vec.length, type.vec.width);
return lp_build_intrinsic_unary(bld->builder, intrinsic, vec_type, a);
}
@@ -692,8 +692,8 @@ lp_build_sin(struct lp_build_context *bld,
/* TODO: optimize the constant case */
- assert(type.floating);
- util_snprintf(intrinsic, sizeof intrinsic, "llvm.sin.v%uf%u", type.length, type.width);
+ assert(type.vec.floating);
+ util_snprintf(intrinsic, sizeof intrinsic, "llvm.sin.v%uf%u", type.vec.length, type.vec.width);
return lp_build_intrinsic_unary(bld->builder, intrinsic, vec_type, a);
}
@@ -819,7 +819,7 @@ lp_build_exp2_approx(struct lp_build_context *bld,
if(LLVMIsConstant(x))
debug_printf("%s: inefficient/imprecise constant arithmetic\n");
- assert(type.floating && type.width == 32);
+ assert(type.vec.floating && type.vec.width == 32);
x = lp_build_min(bld, x, lp_build_const_scalar(type, 129.0));
x = lp_build_max(bld, x, lp_build_const_scalar(type, -126.99999));
@@ -918,7 +918,7 @@ lp_build_log2_approx(struct lp_build_context *bld,
if(LLVMIsConstant(x))
debug_printf("%s: inefficient/imprecise constant arithmetic\n");
- assert(type.floating && type.width == 32);
+ assert(type.vec.floating && type.vec.width == 32);
i = LLVMBuildBitCast(bld->builder, x, int_vec_type, "");
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c b/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
index c11a939..18a6266 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
@@ -320,7 +320,7 @@ lp_build_blend_aos(LLVMBuilderRef builder,
return src;
/* It makes no sense to blend unless values are normalized */
- assert(type.norm);
+ assert(type.vec.norm);
/* Setup build context */
memset(&bld, 0, sizeof bld);
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c b/src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c
index b92254a..c818998 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c
@@ -220,7 +220,7 @@ lp_build_blend_soa(LLVMBuilderRef builder,
for (i = 0; i < 4; ++i) {
if (blend->colormask & (1 << i)) {
if (blend->logicop_enable) {
- if(!type.floating) {
+ if(!type.vec.floating) {
res[i] = lp_build_logicop(builder, blend->logicop_func, src[i], dst[i]);
}
else
@@ -233,7 +233,7 @@ lp_build_blend_soa(LLVMBuilderRef builder,
boolean func_commutative = lp_build_blend_func_commutative(func);
/* It makes no sense to blend unless values are normalized */
- assert(type.norm);
+ assert(type.vec.norm);
/*
* Compute src/dst factors.
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_const.c b/src/gallium/drivers/llvmpipe/lp_bld_const.c
index 2148736..4ca5a01 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_const.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_const.c
@@ -44,10 +44,10 @@
unsigned
lp_mantissa(union lp_type type)
{
- assert(type.floating);
+ assert(type.vec.floating);
- if(type.floating) {
- switch(type.width) {
+ if(type.vec.floating) {
+ switch(type.vec.width) {
case 32:
return 23;
case 64:
@@ -58,10 +58,10 @@ lp_mantissa(union lp_type type)
}
}
else {
- if(type.sign)
- return type.width - 1;
+ if(type.vec.sign)
+ return type.vec.width - 1;
else
- return type.width;
+ return type.vec.width;
}
}
@@ -74,12 +74,12 @@ lp_mantissa(union lp_type type)
unsigned
lp_const_shift(union lp_type type)
{
- if(type.floating)
+ if(type.vec.floating)
return 0;
- else if(type.fixed)
- return type.width/2;
- else if(type.norm)
- return type.sign ? type.width - 1 : type.width;
+ else if(type.vec.fixed)
+ return type.vec.width/2;
+ else if(type.vec.norm)
+ return type.vec.sign ? type.vec.width - 1 : type.vec.width;
else
return 0;
}
@@ -88,9 +88,9 @@ lp_const_shift(union lp_type type)
unsigned
lp_const_offset(union lp_type type)
{
- if(type.floating || type.fixed)
+ if(type.vec.floating || type.vec.fixed)
return 0;
- else if(type.norm)
+ else if(type.vec.norm)
return 1;
else
return 0;
@@ -119,21 +119,21 @@ lp_const_scale(union lp_type type)
/**
- * Minimum value representable by the type.
+ * Minimum value representable by the type.vec.
*/
double
lp_const_min(union lp_type type)
{
unsigned bits;
- if(!type.sign)
+ if(!type.vec.sign)
return 0.0;
- if(type.norm)
+ if(type.vec.norm)
return -1.0;
- if (type.floating) {
- switch(type.width) {
+ if (type.vec.floating) {
+ switch(type.vec.width) {
case 32:
return -FLT_MAX;
case 64:
@@ -144,29 +144,29 @@ lp_const_min(union lp_type type)
}
}
- if(type.fixed)
+ if(type.vec.fixed)
/* FIXME: consider the fractional bits? */
- bits = type.width / 2 - 1;
+ bits = type.vec.width / 2 - 1;
else
- bits = type.width - 1;
+ bits = type.vec.width - 1;
return (double)-((long long)1 << bits);
}
/**
- * Maximum value representable by the type.
+ * Maximum value representable by the type.vec.
*/
double
lp_const_max(union lp_type type)
{
unsigned bits;
- if(type.norm)
+ if(type.vec.norm)
return 1.0;
- if (type.floating) {
- switch(type.width) {
+ if (type.vec.floating) {
+ switch(type.vec.width) {
case 32:
return FLT_MAX;
case 64:
@@ -177,12 +177,12 @@ lp_const_max(union lp_type type)
}
}
- if(type.fixed)
- bits = type.width / 2;
+ if(type.vec.fixed)
+ bits = type.vec.width / 2;
else
- bits = type.width;
+ bits = type.vec.width;
- if(type.sign)
+ if(type.vec.sign)
bits -= 1;
return (double)(((unsigned long long)1 << bits) - 1);
@@ -192,8 +192,8 @@ lp_const_max(union lp_type type)
double
lp_const_eps(union lp_type type)
{
- if (type.floating) {
- switch(type.width) {
+ if (type.vec.floating) {
+ switch(type.vec.width) {
case 32:
return FLT_EPSILON;
case 64:
@@ -233,26 +233,26 @@ lp_build_one(union lp_type type)
LLVMValueRef elems[LP_MAX_VECTOR_LENGTH];
unsigned i;
- assert(type.length <= LP_MAX_VECTOR_LENGTH);
+ assert(type.vec.length <= LP_MAX_VECTOR_LENGTH);
elem_type = lp_build_elem_type(type);
- if(type.floating)
+ if(type.vec.floating)
elems[0] = LLVMConstReal(elem_type, 1.0);
- else if(type.fixed)
- elems[0] = LLVMConstInt(elem_type, 1LL << (type.width/2), 0);
- else if(!type.norm)
+ else if(type.vec.fixed)
+ elems[0] = LLVMConstInt(elem_type, 1LL << (type.vec.width/2), 0);
+ else if(!type.vec.norm)
elems[0] = LLVMConstInt(elem_type, 1, 0);
- else if(type.sign)
- elems[0] = LLVMConstInt(elem_type, (1LL << (type.width - 1)) - 1, 0);
+ else if(type.vec.sign)
+ elems[0] = LLVMConstInt(elem_type, (1LL << (type.vec.width - 1)) - 1, 0);
else {
/* special case' -- 1.0 for normalized types is more easily attained if
* we start with a vector consisting of all bits set */
- LLVMTypeRef vec_type = LLVMVectorType(elem_type, type.length);
+ LLVMTypeRef vec_type = LLVMVectorType(elem_type, type.vec.length);
LLVMValueRef vec = LLVMConstAllOnes(vec_type);
#if 0
- if(type.sign)
+ if(type.vec.sign)
/* TODO: Unfortunately this caused "Tried to create a shift operation
* on a non-integer type!" */
vec = LLVMConstLShr(vec, lp_build_int_const_scalar(type, 1));
@@ -261,10 +261,10 @@ lp_build_one(union lp_type type)
return vec;
}
- for(i = 1; i < type.length; ++i)
+ for(i = 1; i < type.vec.length; ++i)
elems[i] = elems[0];
- return LLVMConstVector(elems, type.length);
+ return LLVMConstVector(elems, type.vec.length);
}
@@ -276,9 +276,9 @@ lp_build_const_scalar(union lp_type type,
LLVMValueRef elems[LP_MAX_VECTOR_LENGTH];
unsigned i;
- assert(type.length <= LP_MAX_VECTOR_LENGTH);
+ assert(type.vec.length <= LP_MAX_VECTOR_LENGTH);
- if(type.floating) {
+ if(type.vec.floating) {
elems[0] = LLVMConstReal(elem_type, val);
}
else {
@@ -287,10 +287,10 @@ lp_build_const_scalar(union lp_type type,
elems[0] = LLVMConstInt(elem_type, val*dscale + 0.5, 0);
}
- for(i = 1; i < type.length; ++i)
+ for(i = 1; i < type.vec.length; ++i)
elems[i] = elems[0];
- return LLVMConstVector(elems, type.length);
+ return LLVMConstVector(elems, type.vec.length);
}
@@ -302,12 +302,12 @@ lp_build_int_const_scalar(union lp_type type,
LLVMValueRef elems[LP_MAX_VECTOR_LENGTH];
unsigned i;
- assert(type.length <= LP_MAX_VECTOR_LENGTH);
+ assert(type.vec.length <= LP_MAX_VECTOR_LENGTH);
- for(i = 0; i < type.length; ++i)
- elems[i] = LLVMConstInt(elem_type, val, type.sign ? 1 : 0);
+ for(i = 0; i < type.vec.length; ++i)
+ elems[i] = LLVMConstInt(elem_type, val, type.vec.sign ? 1 : 0);
- return LLVMConstVector(elems, type.length);
+ return LLVMConstVector(elems, type.vec.length);
}
@@ -321,15 +321,15 @@ lp_build_const_aos(union lp_type type,
LLVMValueRef elems[LP_MAX_VECTOR_LENGTH];
unsigned i;
- assert(type.length % 4 == 0);
- assert(type.length <= LP_MAX_VECTOR_LENGTH);
+ assert(type.vec.length % 4 == 0);
+ assert(type.vec.length <= LP_MAX_VECTOR_LENGTH);
elem_type = lp_build_elem_type(type);
if(swizzle == NULL)
swizzle = default_swizzle;
- if(type.floating) {
+ if(type.vec.floating) {
elems[swizzle[0]] = LLVMConstReal(elem_type, r);
elems[swizzle[1]] = LLVMConstReal(elem_type, g);
elems[swizzle[2]] = LLVMConstReal(elem_type, b);
@@ -344,10 +344,10 @@ lp_build_const_aos(union lp_type type,
elems[swizzle[3]] = LLVMConstInt(elem_type, a*dscale + 0.5, 0);
}
- for(i = 4; i < type.length; ++i)
+ for(i = 4; i < type.vec.length; ++i)
elems[i] = elems[i % 4];
- return LLVMConstVector(elems, type.length);
+ return LLVMConstVector(elems, type.vec.length);
}
@@ -355,15 +355,15 @@ LLVMValueRef
lp_build_const_mask_aos(union lp_type type,
boolean cond[4])
{
- LLVMTypeRef elem_type = LLVMIntType(type.width);
+ LLVMTypeRef elem_type = LLVMIntType(type.vec.width);
LLVMValueRef masks[LP_MAX_VECTOR_LENGTH];
unsigned i, j;
- assert(type.length <= LP_MAX_VECTOR_LENGTH);
+ assert(type.vec.length <= LP_MAX_VECTOR_LENGTH);
- for(j = 0; j < type.length; j += 4)
+ for(j = 0; j < type.vec.length; j += 4)
for(i = 0; i < 4; ++i)
masks[j + i] = LLVMConstInt(elem_type, cond[i] ? ~0 : 0, 0);
- return LLVMConstVector(masks, type.length);
+ return LLVMConstVector(masks, type.vec.length);
}
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_conv.c b/src/gallium/drivers/llvmpipe/lp_bld_conv.c
index c8954c8..b9f7998 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_conv.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_conv.c
@@ -40,11 +40,11 @@
*
* - register width must remain constant:
*
- * src_type.width * src_type.length == dst_type.width * dst_type.length
+ * src_type.vec.width * src_type.vec.length == dst_type.vec.width * dst_type.vec.length
*
* - total number of elements must remain constant:
*
- * src_type.length * num_srcs == dst_type.length * num_dsts
+ * src_type.vec.length * num_srcs == dst_type.vec.length * num_dsts
*
* It is not always possible to do the conversion both accurately and
* efficiently, usually due to lack of adequate machine instructions. In these
@@ -53,7 +53,7 @@
* precision parameter which can gauge the accuracy vs efficiency compromise,
* but for now if the data conversion between two stages happens to be the
* bottleneck, then most likely should just avoid converting at all and run
- * both stages with the same type.
+ * both stages with the same type.vec.
*
* Make sure to run lp_test_conv unit test after any change to this file.
*
@@ -99,7 +99,7 @@ lp_build_clamped_float_to_unsigned_norm(LLVMBuilderRef builder,
double scale;
double bias;
- assert(src_type.floating);
+ assert(src_type.vec.floating);
mantissa = lp_mantissa(src_type);
@@ -257,20 +257,20 @@ lp_build_expand(LLVMBuilderRef builder,
unsigned i;
/* Register width must remain constant */
- assert(src_type.width * src_type.length == dst_type.width * dst_type.length);
+ assert(src_type.vec.width * src_type.vec.length == dst_type.vec.width * dst_type.vec.length);
/* We must not loose or gain channels. Only precision */
- assert(src_type.length == dst_type.length * num_dsts);
+ assert(src_type.vec.length == dst_type.vec.length * num_dsts);
num_tmps = 1;
dst[0] = src;
- while(src_type.width < dst_type.width) {
+ while(src_type.vec.width < dst_type.vec.width) {
union lp_type new_type = src_type;
LLVMTypeRef new_vec_type;
- new_type.width *= 2;
- new_type.length /= 2;
+ new_type.vec.width *= 2;
+ new_type.vec.length /= 2;
new_vec_type = lp_build_vec_type(new_type);
for(i = num_tmps; i--; ) {
@@ -281,8 +281,8 @@ lp_build_expand(LLVMBuilderRef builder,
LLVMValueRef hi;
zero = lp_build_zero(src_type);
- shuffle_lo = lp_build_const_unpack_shuffle(src_type.length, 0);
- shuffle_hi = lp_build_const_unpack_shuffle(src_type.length, 1);
+ shuffle_lo = lp_build_const_unpack_shuffle(src_type.vec.length, 0);
+ shuffle_hi = lp_build_const_unpack_shuffle(src_type.vec.length, 1);
/* PUNPCKLBW, PUNPCKHBW */
lo = LLVMBuildShuffleVector(builder, dst[i], zero, shuffle_lo, "");
@@ -326,30 +326,30 @@ lp_build_pack2(LLVMBuilderRef builder,
LLVMValueRef res;
/* Register width must remain constant */
- assert(src_type.width * src_type.length == dst_type.width * dst_type.length);
+ assert(src_type.vec.width * src_type.vec.length == dst_type.vec.width * dst_type.vec.length);
/* We must not loose or gain channels. Only precision */
- assert(src_type.length * 2 == dst_type.length);
+ assert(src_type.vec.length * 2 == dst_type.vec.length);
- assert(!src_type.floating);
- assert(!dst_type.floating);
+ assert(!src_type.vec.floating);
+ assert(!dst_type.vec.floating);
#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
- if(src_type.width * src_type.length == 128) {
+ if(src_type.vec.width * src_type.vec.length == 128) {
/* All X86 non-interleaved pack instructions all take signed inputs and
* saturate them, so saturate beforehand. */
- if(!src_type.sign && !clamped) {
+ if(!src_type.vec.sign && !clamped) {
struct lp_build_context bld;
- unsigned dst_bits = dst_type.sign ? dst_type.width - 1 : dst_type.width;
+ unsigned dst_bits = dst_type.vec.sign ? dst_type.vec.width - 1 : dst_type.vec.width;
LLVMValueRef dst_max = lp_build_int_const_scalar(src_type, ((unsigned long long)1 << dst_bits) - 1);
lp_build_context_init(&bld, builder, src_type);
lo = lp_build_min(&bld, lo, dst_max);
hi = lp_build_min(&bld, hi, dst_max);
}
- switch(src_type.width) {
+ switch(src_type.vec.width) {
case 32:
- if(dst_type.sign)
+ if(dst_type.vec.sign)
res = lp_build_intrinsic_binary(builder, "llvm.x86.sse2.packssdw.128", src_vec_type, lo, hi);
else
/* PACKUSDW is the only instrinsic with a consistent signature */
@@ -357,7 +357,7 @@ lp_build_pack2(LLVMBuilderRef builder,
break;
case 16:
- if(dst_type.sign)
+ if(dst_type.vec.sign)
res = lp_build_intrinsic_binary(builder, "llvm.x86.sse2.packsswb.128", src_vec_type, lo, hi);
else
res = lp_build_intrinsic_binary(builder, "llvm.x86.sse2.packuswb.128", src_vec_type, lo, hi);
@@ -377,7 +377,7 @@ lp_build_pack2(LLVMBuilderRef builder,
lo = LLVMBuildBitCast(builder, lo, dst_vec_type, "");
hi = LLVMBuildBitCast(builder, hi, dst_vec_type, "");
- shuffle = lp_build_const_pack_shuffle(dst_type.length);
+ shuffle = lp_build_const_pack_shuffle(dst_type.vec.length);
res = LLVMBuildShuffleVector(builder, lo, hi, shuffle, "");
@@ -401,23 +401,23 @@ lp_build_trunc(LLVMBuilderRef builder,
unsigned i;
/* Register width must remain constant */
- assert(src_type.width * src_type.length == dst_type.width * dst_type.length);
+ assert(src_type.vec.width * src_type.vec.length == dst_type.vec.width * dst_type.vec.length);
/* We must not loose or gain channels. Only precision */
- assert(src_type.length * num_srcs == dst_type.length);
+ assert(src_type.vec.length * num_srcs == dst_type.vec.length);
for(i = 0; i < num_srcs; ++i)
tmp[i] = src[i];
- while(src_type.width > dst_type.width) {
+ while(src_type.vec.width > dst_type.vec.width) {
union lp_type new_type = src_type;
- new_type.width /= 2;
- new_type.length *= 2;
+ new_type.vec.width /= 2;
+ new_type.vec.length *= 2;
/* Take in consideration the sign changes only in the last step */
- if(new_type.width == dst_type.width)
- new_type.sign = dst_type.sign;
+ if(new_type.vec.width == dst_type.vec.width)
+ new_type.vec.sign = dst_type.vec.sign;
num_srcs /= 2;
@@ -453,13 +453,13 @@ lp_build_conv(LLVMBuilderRef builder,
unsigned i;
/* Register width must remain constant */
- assert(src_type.width * src_type.length == dst_type.width * dst_type.length);
+ assert(src_type.vec.width * src_type.vec.length == dst_type.vec.width * dst_type.vec.length);
/* We must not loose or gain channels. Only precision */
- assert(src_type.length * num_srcs == dst_type.length * num_dsts);
+ assert(src_type.vec.length * num_srcs == dst_type.vec.length * num_dsts);
- assert(src_type.length <= LP_MAX_VECTOR_LENGTH);
- assert(dst_type.length <= LP_MAX_VECTOR_LENGTH);
+ assert(src_type.vec.length <= LP_MAX_VECTOR_LENGTH);
+ assert(dst_type.vec.length <= LP_MAX_VECTOR_LENGTH);
tmp_type = src_type;
for(i = 0; i < num_srcs; ++i)
@@ -503,18 +503,18 @@ lp_build_conv(LLVMBuilderRef builder,
* Scale to the narrowest range
*/
- if(dst_type.floating) {
+ if(dst_type.vec.floating) {
/* Nothing to do */
}
- else if(tmp_type.floating) {
- if(!dst_type.fixed && !dst_type.sign && dst_type.norm) {
+ else if(tmp_type.vec.floating) {
+ if(!dst_type.vec.fixed && !dst_type.vec.sign && dst_type.vec.norm) {
for(i = 0; i < num_tmps; ++i) {
tmp[i] = lp_build_clamped_float_to_unsigned_norm(builder,
tmp_type,
- dst_type.width,
+ dst_type.vec.width,
tmp[i]);
}
- tmp_type.floating = FALSE;
+ tmp_type.vec.floating = FALSE;
}
else {
double dst_scale = lp_const_scale(dst_type);
@@ -527,11 +527,11 @@ lp_build_conv(LLVMBuilderRef builder,
}
/* Use an equally sized integer for intermediate computations */
- tmp_type.floating = FALSE;
+ tmp_type.vec.floating = FALSE;
tmp_vec_type = lp_build_vec_type(tmp_type);
for(i = 0; i < num_tmps; ++i) {
#if 0
- if(dst_type.sign)
+ if(dst_type.vec.sign)
tmp[i] = LLVMBuildFPToSI(builder, tmp[i], tmp_vec_type, "");
else
tmp[i] = LLVMBuildFPToUI(builder, tmp[i], tmp_vec_type, "");
@@ -550,7 +550,7 @@ lp_build_conv(LLVMBuilderRef builder,
if(src_shift > dst_shift) {
LLVMValueRef shift = lp_build_int_const_scalar(tmp_type, src_shift - dst_shift);
for(i = 0; i < num_tmps; ++i)
- if(src_type.sign)
+ if(src_type.vec.sign)
tmp[i] = LLVMBuildAShr(builder, tmp[i], shift, "");
else
tmp[i] = LLVMBuildLShr(builder, tmp[i], shift, "");
@@ -561,56 +561,56 @@ lp_build_conv(LLVMBuilderRef builder,
* Truncate or expand bit width
*/
- assert(!tmp_type.floating || tmp_type.width == dst_type.width);
+ assert(!tmp_type.vec.floating || tmp_type.vec.width == dst_type.vec.width);
- if(tmp_type.width > dst_type.width) {
+ if(tmp_type.vec.width > dst_type.vec.width) {
assert(num_dsts == 1);
tmp[0] = lp_build_trunc(builder, tmp_type, dst_type, TRUE, tmp, num_tmps);
- tmp_type.width = dst_type.width;
- tmp_type.length = dst_type.length;
+ tmp_type.vec.width = dst_type.vec.width;
+ tmp_type.vec.length = dst_type.vec.length;
num_tmps = 1;
}
- if(tmp_type.width < dst_type.width) {
+ if(tmp_type.vec.width < dst_type.vec.width) {
assert(num_tmps == 1);
lp_build_expand(builder, tmp_type, dst_type, tmp[0], tmp, num_dsts);
- tmp_type.width = dst_type.width;
- tmp_type.length = dst_type.length;
+ tmp_type.vec.width = dst_type.vec.width;
+ tmp_type.vec.length = dst_type.vec.length;
num_tmps = num_dsts;
}
- assert(tmp_type.width == dst_type.width);
- assert(tmp_type.length == dst_type.length);
+ assert(tmp_type.vec.width == dst_type.vec.width);
+ assert(tmp_type.vec.length == dst_type.vec.length);
assert(num_tmps == num_dsts);
/*
* Scale to the widest range
*/
- if(src_type.floating) {
+ if(src_type.vec.floating) {
/* Nothing to do */
}
- else if(!src_type.floating && dst_type.floating) {
- if(!src_type.fixed && !src_type.sign && src_type.norm) {
+ else if(!src_type.vec.floating && dst_type.vec.floating) {
+ if(!src_type.vec.fixed && !src_type.vec.sign && src_type.vec.norm) {
for(i = 0; i < num_tmps; ++i) {
tmp[i] = lp_build_unsigned_norm_to_float(builder,
- src_type.width,
+ src_type.vec.width,
dst_type,
tmp[i]);
}
- tmp_type.floating = TRUE;
+ tmp_type.vec.floating = TRUE;
}
else {
double src_scale = lp_const_scale(src_type);
LLVMTypeRef tmp_vec_type;
/* Use an equally sized integer for intermediate computations */
- tmp_type.floating = TRUE;
- tmp_type.sign = TRUE;
+ tmp_type.vec.floating = TRUE;
+ tmp_type.vec.sign = TRUE;
tmp_vec_type = lp_build_vec_type(tmp_type);
for(i = 0; i < num_tmps; ++i) {
#if 0
- if(dst_type.sign)
+ if(dst_type.vec.sign)
tmp[i] = LLVMBuildSIToFP(builder, tmp[i], tmp_vec_type, "");
else
tmp[i] = LLVMBuildUIToFP(builder, tmp[i], tmp_vec_type, "");
@@ -662,10 +662,10 @@ lp_build_conv_mask(LLVMBuilderRef builder,
LLVMValueRef *dst, unsigned num_dsts)
{
/* Register width must remain constant */
- assert(src_type.width * src_type.length == dst_type.width * dst_type.length);
+ assert(src_type.vec.width * src_type.vec.length == dst_type.vec.width * dst_type.vec.length);
/* We must not loose or gain channels. Only precision */
- assert(src_type.length * num_srcs == dst_type.length * num_dsts);
+ assert(src_type.vec.length * num_srcs == dst_type.vec.length * num_dsts);
/*
* Drop
@@ -673,25 +673,25 @@ lp_build_conv_mask(LLVMBuilderRef builder,
* We assume all values are 0 or -1
*/
- src_type.floating = FALSE;
- src_type.fixed = FALSE;
- src_type.sign = TRUE;
- src_type.norm = FALSE;
+ src_type.vec.floating = FALSE;
+ src_type.vec.fixed = FALSE;
+ src_type.vec.sign = TRUE;
+ src_type.vec.norm = FALSE;
- dst_type.floating = FALSE;
- dst_type.fixed = FALSE;
- dst_type.sign = TRUE;
- dst_type.norm = FALSE;
+ dst_type.vec.floating = FALSE;
+ dst_type.vec.fixed = FALSE;
+ dst_type.vec.sign = TRUE;
+ dst_type.vec.norm = FALSE;
/*
* Truncate or expand bit width
*/
- if(src_type.width > dst_type.width) {
+ if(src_type.vec.width > dst_type.vec.width) {
assert(num_dsts == 1);
dst[0] = lp_build_trunc(builder, src_type, dst_type, TRUE, src, num_srcs);
}
- else if(src_type.width < dst_type.width) {
+ else if(src_type.vec.width < dst_type.vec.width) {
assert(num_srcs == 1);
lp_build_expand(builder, src_type, dst_type, src[0], dst, num_dsts);
}
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_depth.c b/src/gallium/drivers/llvmpipe/lp_bld_depth.c
index 2cd6e6b..3155322 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_depth.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_depth.c
@@ -86,23 +86,23 @@ lp_depth_type(const struct util_format_description *format_desc,
assert(swizzle < 4);
type.value = 0;
- type.width = format_desc->block.bits;
+ type.vec.width = format_desc->block.bits;
if(format_desc->channel[swizzle].type == UTIL_FORMAT_TYPE_FLOAT) {
- type.floating = TRUE;
+ type.vec.floating = TRUE;
assert(swizzle = 0);
assert(format_desc->channel[swizzle].size == format_desc->block.bits);
}
else if(format_desc->channel[swizzle].type == UTIL_FORMAT_TYPE_UNSIGNED) {
assert(format_desc->block.bits <= 32);
if(format_desc->channel[swizzle].normalized)
- type.norm = TRUE;
+ type.vec.norm = TRUE;
}
else
assert(0);
- assert(type.width <= length);
- type.length = length / type.width;
+ assert(type.vec.width <= length);
+ type.vec.length = length / type.vec.width;
return type;
}
@@ -139,8 +139,8 @@ lp_build_depth_test(LLVMBuilderRef builder,
/* Sanity checking */
assert(z_swizzle < 4);
- assert(format_desc->block.bits == type.width);
- if(type.floating) {
+ assert(format_desc->block.bits == type.vec.width);
+ if(type.vec.floating) {
assert(z_swizzle == 0);
assert(format_desc->channel[z_swizzle].type == UTIL_FORMAT_TYPE_FLOAT);
assert(format_desc->channel[z_swizzle].size == format_desc->block.bits);
@@ -148,9 +148,9 @@ lp_build_depth_test(LLVMBuilderRef builder,
else {
assert(format_desc->channel[z_swizzle].type == UTIL_FORMAT_TYPE_UNSIGNED);
assert(format_desc->channel[z_swizzle].normalized);
- assert(!type.fixed);
- assert(!type.sign);
- assert(type.norm);
+ assert(!type.vec.fixed);
+ assert(!type.vec.sign);
+ assert(type.vec.norm);
}
/* Setup build context */
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_flow.c b/src/gallium/drivers/llvmpipe/lp_bld_flow.c
index 9d99e1a..12cedc4 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_flow.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_flow.c
@@ -46,7 +46,7 @@ lp_build_mask_begin(struct lp_build_mask_context *mask,
memset(mask, 0, sizeof *mask);
mask->builder = builder;
- mask->reg_type = LLVMIntType(type.width * type.length);
+ mask->reg_type = LLVMIntType(type.vec.width * type.vec.length);
mask->value = value;
}
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_logic.c b/src/gallium/drivers/llvmpipe/lp_bld_logic.c
index 1e1ecf8..0b34477 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_logic.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_logic.c
@@ -63,8 +63,8 @@ lp_build_cmp(struct lp_build_context *bld,
/* XXX: It is not clear if we should use the ordered or unordered operators */
#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
- if(type.width * type.length == 128) {
- if(type.floating) {
+ if(type.vec.width * type.vec.length == 128) {
+ if(type.vec.floating) {
LLVMValueRef args[3];
unsigned cc;
boolean swap;
@@ -135,7 +135,7 @@ lp_build_cmp(struct lp_build_context *bld,
LLVMValueRef args[2];
LLVMValueRef res;
- switch (type.width) {
+ switch (type.vec.width) {
case 8:
pcmpeq = "llvm.x86.sse2.pcmpeq.b";
pcmpgt = "llvm.x86.sse2.pcmpgt.b";
@@ -157,9 +157,9 @@ lp_build_cmp(struct lp_build_context *bld,
* instructions. So flip the sign bit so that the results match.
*/
if(table[func].gt &&
- ((type.width == 8 && type.sign) ||
- (type.width != 8 && !type.sign))) {
- LLVMValueRef msb = lp_build_int_const_scalar(type, (unsigned long long)1 << (type.width - 1));
+ ((type.vec.width == 8 && type.vec.sign) ||
+ (type.vec.width != 8 && !type.vec.sign))) {
+ LLVMValueRef msb = lp_build_int_const_scalar(type, (unsigned long long)1 << (type.vec.width - 1));
a = LLVMBuildXor(bld->builder, a, msb, "");
b = LLVMBuildXor(bld->builder, b, msb, "");
}
@@ -188,7 +188,7 @@ lp_build_cmp(struct lp_build_context *bld,
}
#endif
- if(type.floating) {
+ if(type.vec.floating) {
LLVMRealPredicate op;
switch(func) {
case PIPE_FUNC_NEVER:
@@ -231,16 +231,16 @@ lp_build_cmp(struct lp_build_context *bld,
op = LLVMIntNE;
break;
case PIPE_FUNC_LESS:
- op = type.sign ? LLVMIntSLT : LLVMIntULT;
+ op = type.vec.sign ? LLVMIntSLT : LLVMIntULT;
break;
case PIPE_FUNC_LEQUAL:
- op = type.sign ? LLVMIntSLE : LLVMIntULE;
+ op = type.vec.sign ? LLVMIntSLE : LLVMIntULE;
break;
case PIPE_FUNC_GREATER:
- op = type.sign ? LLVMIntSGT : LLVMIntUGT;
+ op = type.vec.sign ? LLVMIntSGT : LLVMIntUGT;
break;
case PIPE_FUNC_GEQUAL:
- op = type.sign ? LLVMIntSGE : LLVMIntUGE;
+ op = type.vec.sign ? LLVMIntSGE : LLVMIntUGE;
break;
default:
assert(0);
@@ -265,7 +265,7 @@ lp_build_select(struct lp_build_context *bld,
if(a == b)
return a;
- if(type.floating) {
+ if(type.vec.floating) {
LLVMTypeRef int_vec_type = lp_build_int_vec_type(type);
a = LLVMBuildBitCast(bld->builder, a, int_vec_type, "");
b = LLVMBuildBitCast(bld->builder, b, int_vec_type, "");
@@ -284,7 +284,7 @@ lp_build_select(struct lp_build_context *bld,
res = LLVMBuildOr(bld->builder, a, b, "");
- if(type.floating) {
+ if(type.vec.floating) {
LLVMTypeRef vec_type = lp_build_vec_type(type);
res = LLVMBuildBitCast(bld->builder, res, vec_type, "");
}
@@ -300,7 +300,7 @@ lp_build_select_aos(struct lp_build_context *bld,
boolean cond[4])
{
const union lp_type type = bld->type;
- const unsigned n = type.length;
+ const unsigned n = type.vec.length;
unsigned i, j;
if(a == b)
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_swizzle.c b/src/gallium/drivers/llvmpipe/lp_bld_swizzle.c
index ac7eed9..b720f0a 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_swizzle.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_swizzle.c
@@ -69,7 +69,7 @@ lp_build_broadcast_scalar(struct lp_build_context *bld,
unsigned i;
res = bld->undef;
- for(i = 0; i < type.length; ++i) {
+ for(i = 0; i < type.vec.length; ++i) {
LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0);
res = LLVMBuildInsertElement(bld->builder, res, scalar, index, "");
}
@@ -84,7 +84,7 @@ lp_build_broadcast_aos(struct lp_build_context *bld,
unsigned channel)
{
const union lp_type type = bld->type;
- const unsigned n = type.length;
+ const unsigned n = type.vec.length;
unsigned i, j;
if(a == bld->undef || a == bld->zero || a == bld->one)
@@ -130,8 +130,8 @@ lp_build_broadcast_aos(struct lp_build_context *bld,
a = LLVMBuildAnd(bld->builder, a, lp_build_const_mask_aos(type, cond), "");
- type4.width *= 4;
- type4.length /= 4;
+ type4.vec.width *= 4;
+ type4.vec.length /= 4;
a = LLVMBuildBitCast(bld->builder, a, lp_build_vec_type(type4), "");
@@ -144,9 +144,9 @@ lp_build_broadcast_aos(struct lp_build_context *bld,
#endif
if(shift > 0)
- tmp = LLVMBuildLShr(bld->builder, a, lp_build_int_const_scalar(type4, shift*type.width), "");
+ tmp = LLVMBuildLShr(bld->builder, a, lp_build_int_const_scalar(type4, shift*type.vec.width), "");
if(shift < 0)
- tmp = LLVMBuildShl(bld->builder, a, lp_build_int_const_scalar(type4, -shift*type.width), "");
+ tmp = LLVMBuildShl(bld->builder, a, lp_build_int_const_scalar(type4, -shift*type.vec.width), "");
assert(tmp);
if(tmp)
@@ -163,7 +163,7 @@ lp_build_swizzle1_aos(struct lp_build_context *bld,
LLVMValueRef a,
unsigned char swizzle[4])
{
- const unsigned n = bld->type.length;
+ const unsigned n = bld->type.vec.length;
unsigned i, j;
if(a == bld->undef || a == bld->zero || a == bld->one)
@@ -194,7 +194,7 @@ lp_build_swizzle2_aos(struct lp_build_context *bld,
LLVMValueRef b,
unsigned char swizzle[4])
{
- const unsigned n = bld->type.length;
+ const unsigned n = bld->type.vec.length;
unsigned i, j;
if(swizzle[0] < 4 && swizzle[1] < 4 && swizzle[2] < 4 && swizzle[3] < 4)
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_type.c b/src/gallium/drivers/llvmpipe/lp_bld_type.c
index 8e0026f..6ce79fa 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_type.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_type.c
@@ -35,8 +35,8 @@
LLVMTypeRef
lp_build_elem_type(union lp_type type)
{
- if (type.floating) {
- switch(type.width) {
+ if (type.vec.floating) {
+ switch(type.vec.width) {
case 32:
return LLVMFloatType();
break;
@@ -49,7 +49,7 @@ lp_build_elem_type(union lp_type type)
}
}
else {
- return LLVMIntType(type.width);
+ return LLVMIntType(type.vec.width);
}
}
@@ -58,7 +58,7 @@ LLVMTypeRef
lp_build_vec_type(union lp_type type)
{
LLVMTypeRef elem_type = lp_build_elem_type(type);
- return LLVMVectorType(elem_type, type.length);
+ return LLVMVectorType(elem_type, type.vec.length);
}
@@ -79,8 +79,8 @@ lp_check_elem_type(union lp_type type, LLVMTypeRef elem_type)
elem_kind = LLVMGetTypeKind(elem_type);
- if (type.floating) {
- switch(type.width) {
+ if (type.vec.floating) {
+ switch(type.vec.width) {
case 32:
if(elem_kind != LLVMFloatTypeKind)
return FALSE;
@@ -98,7 +98,7 @@ lp_check_elem_type(union lp_type type, LLVMTypeRef elem_type)
if(elem_kind != LLVMIntegerTypeKind)
return FALSE;
- if(LLVMGetIntTypeWidth(elem_type) != type.width)
+ if(LLVMGetIntTypeWidth(elem_type) != type.vec.width)
return FALSE;
}
@@ -118,7 +118,7 @@ lp_check_vec_type(union lp_type type, LLVMTypeRef vec_type)
if(LLVMGetTypeKind(vec_type) != LLVMVectorTypeKind)
return FALSE;
- if(LLVMGetVectorSize(vec_type) != type.length)
+ if(LLVMGetVectorSize(vec_type) != type.vec.length)
return FALSE;
elem_type = LLVMGetElementType(vec_type);
@@ -145,7 +145,7 @@ lp_check_value(union lp_type type, LLVMValueRef val)
LLVMTypeRef
lp_build_int_elem_type(union lp_type type)
{
- return LLVMIntType(type.width);
+ return LLVMIntType(type.vec.width);
}
@@ -153,7 +153,7 @@ LLVMTypeRef
lp_build_int_vec_type(union lp_type type)
{
LLVMTypeRef elem_type = lp_build_int_elem_type(type);
- return LLVMVectorType(elem_type, type.length);
+ return LLVMVectorType(elem_type, type.vec.length);
}
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_type.h b/src/gallium/drivers/llvmpipe/lp_bld_type.h
index 3ce566b..8b065b6 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_type.h
+++ b/src/gallium/drivers/llvmpipe/lp_bld_type.h
@@ -106,7 +106,7 @@ union lp_type {
* @sa LP_MAX_VECTOR_LENGTH
*/
unsigned length:14;
- };
+ } vec;
uint32_t value;
};
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index 94170bd..3eec5cd 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -147,17 +147,17 @@ generate_depth(struct llvmpipe_context *lp,
format_desc = util_format_description(lp->framebuffer.zsbuf->format);
assert(format_desc);
- /* Pick the depth type. */
- dst_type = lp_depth_type(format_desc, src_type.width*src_type.length);
+ /* Pick the depth type.vec. */
+ dst_type = lp_depth_type(format_desc, src_type.vec.width*src_type.vec.length);
/* FIXME: Cope with a depth test type with a different bit width. */
- assert(dst_type.width == src_type.width);
- assert(dst_type.length == src_type.length);
+ assert(dst_type.vec.width == src_type.vec.width);
+ assert(dst_type.vec.length == src_type.vec.length);
#if 1
src = lp_build_clamped_float_to_unsigned_norm(builder,
src_type,
- dst_type.width,
+ dst_type.vec.width,
src);
#else
lp_build_conv(builder, src_type, dst_type, &src, 1, &src, 1);
@@ -508,22 +508,22 @@ generate_fragment(struct llvmpipe_context *lp,
* characteristics. */
fs_type.value = 0;
- fs_type.floating = TRUE; /* floating point values */
- fs_type.sign = TRUE; /* values are signed */
- fs_type.norm = FALSE; /* values are not limited to [0,1] or [-1,1] */
- fs_type.width = 32; /* 32-bit float */
- fs_type.length = 4; /* 4 element per vector */
+ fs_type.vec.floating = TRUE; /* floating point values */
+ fs_type.vec.sign = TRUE; /* values are signed */
+ fs_type.vec.norm = FALSE; /* values are not limited to [0,1] or [-1,1] */
+ fs_type.vec.width = 32; /* 32-bit float */
+ fs_type.vec.length = 4; /* 4 element per vector */
num_fs = 4;
blend_type.value = 0;
- blend_type.floating = FALSE; /* values are integers */
- blend_type.sign = FALSE; /* values are unsigned */
- blend_type.norm = TRUE; /* values are in [0,1] or [-1,1] */
- blend_type.width = 8; /* 8-bit ubyte values */
- blend_type.length = 16; /* 16 elements per vector */
+ blend_type.vec.floating = FALSE; /* values are integers */
+ blend_type.vec.sign = FALSE; /* values are unsigned */
+ blend_type.vec.norm = TRUE; /* values are in [0,1] or [-1,1] */
+ blend_type.vec.width = 8; /* 8-bit ubyte values */
+ blend_type.vec.length = 16; /* 16 elements per vector */
/*
- * Generate the function prototype. Any change here must be reflected in
+ * Generate the function prototype.vec. Any change here must be reflected in
* lp_jit.h's lp_jit_frag_func function pointer type, and vice-versa.
*/
@@ -616,7 +616,7 @@ generate_fragment(struct llvmpipe_context *lp,
}
/*
- * Convert the fs's output color and mask to fit to the blending type.
+ * Convert the fs's output color and mask to fit to the blending type.vec.
*/
for(chan = 0; chan < NUM_CHANNELS; ++chan) {
--
1.6.2.5
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Mesa3d-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev