[Mesa-dev] [PATCH 01/13] i965: Use immediate storage in brw_reg for visitor regs.
Matt Turner
mattst88 at gmail.com
Mon Jun 30 14:40:32 PDT 2014
---
src/mesa/drivers/dri/i965/brw_fs.cpp | 26 ++++++++++++----------
.../drivers/dri/i965/brw_fs_copy_propagation.cpp | 4 ++--
src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 6 ++---
src/mesa/drivers/dri/i965/brw_vec4.cpp | 24 +++++++++-----------
.../drivers/dri/i965/brw_vec4_copy_propagation.cpp | 10 ++++-----
src/mesa/drivers/dri/i965/brw_vec4_generator.cpp | 6 ++---
6 files changed, 37 insertions(+), 39 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index d22b1bf..b260409 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. */
@@ -452,7 +452,7 @@ fs_reg::equals(const fs_reg &r) const
memcmp(&fixed_hw_reg, &r.fixed_hw_reg,
sizeof(fixed_hw_reg)) == 0 &&
stride == r.stride &&
- imm.u == r.imm.u);
+ fixed_hw_reg.dw1.ud == r.fixed_hw_reg.dw1.ud);
}
fs_reg &
@@ -486,7 +486,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 +495,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
@@ -2028,7 +2030,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;
@@ -2042,7 +2044,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;
@@ -2537,7 +2539,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
@@ -2749,13 +2751,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 72329e1..3452a95 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 fda828b..f7e11ac 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 6927297..c7fb4bb 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)
@@ -334,7 +334,7 @@ src_reg::equals(const src_reg &r) const
!reladdr && !r.reladdr &&
memcmp(&fixed_hw_reg, &r.fixed_hw_reg,
sizeof(fixed_hw_reg)) == 0 &&
- imm.u == r.imm.u);
+ fixed_hw_reg.dw1.ud == r.fixed_hw_reg.dw1.ud);
}
static bool
@@ -608,11 +608,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 +618,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;
}
}
@@ -1332,13 +1328,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 a277f99..b6dc07f 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 70e393b..62b0153 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");
--
1.8.3.2
More information about the mesa-dev
mailing list