summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2014-06-29 15:13:24 -0700
committerMatt Turner <[email protected]>2014-07-05 22:42:29 -0700
commit53992a102ffddf2e0fad401252cfc1c034d022ad (patch)
tree037b55050ef729582002b1d79b15fad2f6fcf234
parent45446efc30b66e2a000c7ae5464f75c4af3e4792 (diff)
i965: Use immediate storage in brw_reg for visitor regs.
Reviewed-by: Topi Pohjolainen <[email protected]>
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs.cpp27
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp4
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs_generator.cpp6
-rw-r--r--src/mesa/drivers/dri/i965/brw_vec4.cpp25
-rw-r--r--src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp10
-rw-r--r--src/mesa/drivers/dri/i965/brw_vec4_generator.cpp6
6 files changed, 37 insertions, 41 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 1810d8116ec..8a4a8346056 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -408,7 +408,7 @@ fs_reg::fs_reg(float f)
init();
this->file = IMM;
this->type = BRW_REGISTER_TYPE_F;
- this->imm.f = f;
+ this->fixed_hw_reg.dw1.f = f;
}
/** Immediate value constructor. */
@@ -417,7 +417,7 @@ fs_reg::fs_reg(int32_t i)
init();
this->file = IMM;
this->type = BRW_REGISTER_TYPE_D;
- this->imm.i = i;
+ this->fixed_hw_reg.dw1.d = i;
}
/** Immediate value constructor. */
@@ -426,7 +426,7 @@ fs_reg::fs_reg(uint32_t u)
init();
this->file = IMM;
this->type = BRW_REGISTER_TYPE_UD;
- this->imm.u = u;
+ this->fixed_hw_reg.dw1.ud = u;
}
/** Fixed brw_reg. */
@@ -451,8 +451,7 @@ fs_reg::equals(const fs_reg &r) const
!reladdr && !r.reladdr &&
memcmp(&fixed_hw_reg, &r.fixed_hw_reg,
sizeof(fixed_hw_reg)) == 0 &&
- stride == r.stride &&
- imm.u == r.imm.u);
+ stride == r.stride);
}
fs_reg &
@@ -486,7 +485,7 @@ fs_reg::is_zero() const
if (file != IMM)
return false;
- return type == BRW_REGISTER_TYPE_F ? imm.f == 0.0 : imm.i == 0;
+ return fixed_hw_reg.dw1.d == 0;
}
bool
@@ -495,7 +494,9 @@ fs_reg::is_one() const
if (file != IMM)
return false;
- return type == BRW_REGISTER_TYPE_F ? imm.f == 1.0 : imm.i == 1;
+ return type == BRW_REGISTER_TYPE_F
+ ? fixed_hw_reg.dw1.f == 1.0
+ : fixed_hw_reg.dw1.d == 1;
}
bool
@@ -2031,7 +2032,7 @@ fs_visitor::opt_algebraic()
case BRW_CONDITIONAL_L:
switch (inst->src[1].type) {
case BRW_REGISTER_TYPE_F:
- if (inst->src[1].imm.f >= 1.0f) {
+ if (inst->src[1].fixed_hw_reg.dw1.f >= 1.0f) {
inst->opcode = BRW_OPCODE_MOV;
inst->src[1] = reg_undef;
progress = true;
@@ -2045,7 +2046,7 @@ fs_visitor::opt_algebraic()
case BRW_CONDITIONAL_G:
switch (inst->src[1].type) {
case BRW_REGISTER_TYPE_F:
- if (inst->src[1].imm.f <= 0.0f) {
+ if (inst->src[1].fixed_hw_reg.dw1.f <= 0.0f) {
inst->opcode = BRW_OPCODE_MOV;
inst->src[1] = reg_undef;
inst->conditional_mod = BRW_CONDITIONAL_NONE;
@@ -2540,7 +2541,7 @@ fs_visitor::lower_uniform_pull_constant_loads()
fs_reg const_offset_reg = inst->src[1];
assert(const_offset_reg.file == IMM &&
const_offset_reg.type == BRW_REGISTER_TYPE_UD);
- const_offset_reg.imm.u /= 4;
+ const_offset_reg.fixed_hw_reg.dw1.ud /= 4;
fs_reg payload = fs_reg(this, glsl_type::uint_type);
/* This is actually going to be a MOV, but since only the first dword
@@ -2752,13 +2753,13 @@ fs_visitor::dump_instruction(backend_instruction *be_inst, FILE *file)
case IMM:
switch (inst->src[i].type) {
case BRW_REGISTER_TYPE_F:
- fprintf(file, "%ff", inst->src[i].imm.f);
+ fprintf(file, "%ff", inst->src[i].fixed_hw_reg.dw1.f);
break;
case BRW_REGISTER_TYPE_D:
- fprintf(file, "%dd", inst->src[i].imm.i);
+ fprintf(file, "%dd", inst->src[i].fixed_hw_reg.dw1.d);
break;
case BRW_REGISTER_TYPE_UD:
- fprintf(file, "%uu", inst->src[i].imm.u);
+ fprintf(file, "%uu", inst->src[i].fixed_hw_reg.dw1.ud);
break;
default:
fprintf(file, "???");
diff --git a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
index 72329e15ed6..3452a9547e8 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
@@ -483,10 +483,10 @@ try_constant_propagate(struct brw_context *brw, fs_inst *inst,
* anyway.
*/
assert(i == 0);
- if (inst->src[0].imm.f != 0.0f) {
+ if (inst->src[0].fixed_hw_reg.dw1.f != 0.0f) {
inst->opcode = BRW_OPCODE_MOV;
inst->src[0] = entry->src;
- inst->src[0].imm.f = 1.0f / inst->src[0].imm.f;
+ inst->src[0].fixed_hw_reg.dw1.f = 1.0f / inst->src[0].fixed_hw_reg.dw1.f;
progress = true;
}
break;
diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
index 52e88d41b36..eae55f00158 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
@@ -1031,13 +1031,13 @@ brw_reg_from_fs_reg(fs_reg *reg)
case IMM:
switch (reg->type) {
case BRW_REGISTER_TYPE_F:
- brw_reg = brw_imm_f(reg->imm.f);
+ brw_reg = brw_imm_f(reg->fixed_hw_reg.dw1.f);
break;
case BRW_REGISTER_TYPE_D:
- brw_reg = brw_imm_d(reg->imm.i);
+ brw_reg = brw_imm_d(reg->fixed_hw_reg.dw1.d);
break;
case BRW_REGISTER_TYPE_UD:
- brw_reg = brw_imm_ud(reg->imm.u);
+ brw_reg = brw_imm_ud(reg->fixed_hw_reg.dw1.ud);
break;
default:
unreachable("not reached");
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index cf24bcfeb20..3b518758367 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -91,7 +91,7 @@ src_reg::src_reg(float f)
this->file = IMM;
this->type = BRW_REGISTER_TYPE_F;
- this->imm.f = f;
+ this->fixed_hw_reg.dw1.f = f;
}
src_reg::src_reg(uint32_t u)
@@ -100,7 +100,7 @@ src_reg::src_reg(uint32_t u)
this->file = IMM;
this->type = BRW_REGISTER_TYPE_UD;
- this->imm.u = u;
+ this->fixed_hw_reg.dw1.ud = u;
}
src_reg::src_reg(int32_t i)
@@ -109,7 +109,7 @@ src_reg::src_reg(int32_t i)
this->file = IMM;
this->type = BRW_REGISTER_TYPE_D;
- this->imm.i = i;
+ this->fixed_hw_reg.dw1.d = i;
}
src_reg::src_reg(struct brw_reg reg)
@@ -333,8 +333,7 @@ src_reg::equals(const src_reg &r) const
swizzle == r.swizzle &&
!reladdr && !r.reladdr &&
memcmp(&fixed_hw_reg, &r.fixed_hw_reg,
- sizeof(fixed_hw_reg)) == 0 &&
- imm.u == r.imm.u);
+ sizeof(fixed_hw_reg)) == 0);
}
static bool
@@ -608,11 +607,7 @@ src_reg::is_zero() const
if (file != IMM)
return false;
- if (type == BRW_REGISTER_TYPE_F) {
- return imm.f == 0.0;
- } else {
- return imm.i == 0;
- }
+ return fixed_hw_reg.dw1.d == 0;
}
bool
@@ -622,9 +617,9 @@ src_reg::is_one() const
return false;
if (type == BRW_REGISTER_TYPE_F) {
- return imm.f == 1.0;
+ return fixed_hw_reg.dw1.f == 1.0;
} else {
- return imm.i == 1;
+ return fixed_hw_reg.dw1.d == 1;
}
}
@@ -1335,13 +1330,13 @@ vec4_visitor::dump_instruction(backend_instruction *be_inst, FILE *file)
case IMM:
switch (inst->src[i].type) {
case BRW_REGISTER_TYPE_F:
- fprintf(file, "%fF", inst->src[i].imm.f);
+ fprintf(file, "%fF", inst->src[i].fixed_hw_reg.dw1.f);
break;
case BRW_REGISTER_TYPE_D:
- fprintf(file, "%dD", inst->src[i].imm.i);
+ fprintf(file, "%dD", inst->src[i].fixed_hw_reg.dw1.d);
break;
case BRW_REGISTER_TYPE_UD:
- fprintf(file, "%uU", inst->src[i].imm.u);
+ fprintf(file, "%uU", inst->src[i].fixed_hw_reg.dw1.ud);
break;
default:
fprintf(file, "???");
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
index a277f998e46..b6dc07f25d4 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
@@ -92,18 +92,18 @@ try_constant_propagate(struct brw_context *brw, vec4_instruction *inst,
if (inst->src[arg].abs) {
if (value.type == BRW_REGISTER_TYPE_F) {
- value.imm.f = fabs(value.imm.f);
+ value.fixed_hw_reg.dw1.f = fabs(value.fixed_hw_reg.dw1.f);
} else if (value.type == BRW_REGISTER_TYPE_D) {
- if (value.imm.i < 0)
- value.imm.i = -value.imm.i;
+ if (value.fixed_hw_reg.dw1.d < 0)
+ value.fixed_hw_reg.dw1.d = -value.fixed_hw_reg.dw1.d;
}
}
if (inst->src[arg].negate) {
if (value.type == BRW_REGISTER_TYPE_F)
- value.imm.f = -value.imm.f;
+ value.fixed_hw_reg.dw1.f = -value.fixed_hw_reg.dw1.f;
else
- value.imm.u = -value.imm.u;
+ value.fixed_hw_reg.dw1.ud = -value.fixed_hw_reg.dw1.ud;
}
switch (inst->opcode) {
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
index 07e29a5d32f..5266f81ed7c 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
@@ -84,13 +84,13 @@ vec4_instruction::get_src(const struct brw_vec4_prog_data *prog_data, int i)
case IMM:
switch (src[i].type) {
case BRW_REGISTER_TYPE_F:
- brw_reg = brw_imm_f(src[i].imm.f);
+ brw_reg = brw_imm_f(src[i].fixed_hw_reg.dw1.f);
break;
case BRW_REGISTER_TYPE_D:
- brw_reg = brw_imm_d(src[i].imm.i);
+ brw_reg = brw_imm_d(src[i].fixed_hw_reg.dw1.d);
break;
case BRW_REGISTER_TYPE_UD:
- brw_reg = brw_imm_ud(src[i].imm.u);
+ brw_reg = brw_imm_ud(src[i].fixed_hw_reg.dw1.ud);
break;
default:
unreachable("not reached");