i965: Use immediate storage in brw_reg for visitor regs.
authorMatt Turner <mattst88@gmail.com>
Sun, 29 Jun 2014 22:13:24 +0000 (15:13 -0700)
committerMatt Turner <mattst88@gmail.com>
Sun, 6 Jul 2014 05:42:29 +0000 (22:42 -0700)
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
src/mesa/drivers/dri/i965/brw_fs_generator.cpp
src/mesa/drivers/dri/i965/brw_vec4.cpp
src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
src/mesa/drivers/dri/i965/brw_vec4_generator.cpp

index 1810d8116ecc62ac9c8c8b27b4d81d10eadef81a..8a4a8346056420da3fc6ecc9f90d9cd3d0db2837 100644 (file)
@@ -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, "???");
index 72329e15ed63f692562d1ac9825829efa7d2e108..3452a9547e896004993ed1b904fc0ceacd948dea 100644 (file)
@@ -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;
index 52e88d41b365b537ccffc253cf73a65e21d516bc..eae55f0015851d116ed302d1d1c097a4a8330fe5 100644 (file)
@@ -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");
index cf24bcfeb20b5391389385d971101b1f50c9593f..3b5187583675ff81eb074c4ff48ebe299772a703 100644 (file)
@@ -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, "???");
index a277f998e460b3631def90822d6a654cb97776b9..b6dc07f25d4b30dcac6d9706d60b1710bd8cd7c7 100644 (file)
@@ -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) {
index 07e29a5d32f8fde2103bccdac63be9575f6625ce..5266f81ed7c824d41f922e255579a4497fd939f4 100644 (file)
@@ -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");