[Mesa-dev] [PATCH] i965: Make src_reg::equals() take a constant reference, not a pointer.

Kenneth Graunke kenneth at whitecape.org
Sun Jun 8 02:50:15 PDT 2014


This is more typical C++ style.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_vec4.cpp             | 22 +++++++++++-----------
 src/mesa/drivers/dri/i965/brw_vec4.h               |  2 +-
 .../drivers/dri/i965/brw_vec4_copy_propagation.cpp |  4 ++--
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index fa186b5..e816b94 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -323,19 +323,19 @@ vec4_visitor::implied_mrf_writes(vec4_instruction *inst)
 }
 
 bool
-src_reg::equals(src_reg *r)
+src_reg::equals(const src_reg &r) const
 {
-   return (file == r->file &&
-	   reg == r->reg &&
-	   reg_offset == r->reg_offset &&
-	   type == r->type &&
-	   negate == r->negate &&
-	   abs == r->abs &&
-	   swizzle == r->swizzle &&
-	   !reladdr && !r->reladdr &&
-	   memcmp(&fixed_hw_reg, &r->fixed_hw_reg,
+   return (file == r.file &&
+	   reg == r.reg &&
+	   reg_offset == r.reg_offset &&
+	   type == r.type &&
+	   negate == r.negate &&
+	   abs == r.abs &&
+	   swizzle == r.swizzle &&
+	   !reladdr && !r.reladdr &&
+	   memcmp(&fixed_hw_reg, &r.fixed_hw_reg,
 		  sizeof(fixed_hw_reg)) == 0 &&
-	   imm.u == r->imm.u);
+	   imm.u == r.imm.u);
 }
 
 static bool
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
index c2bbd68..a3ba9c7 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -126,7 +126,7 @@ public:
    src_reg(int32_t i);
    src_reg(struct brw_reg reg);
 
-   bool equals(src_reg *r);
+   bool equals(const src_reg &r) const;
    bool is_zero() const;
    bool is_one() const;
    bool is_accumulator() const;
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 83cf191..2d1c62b 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
@@ -82,7 +82,7 @@ try_constant_propagation(vec4_instruction *inst, int arg, src_reg *values[4])
     */
    src_reg value = *values[0];
    for (int i = 1; i < 4; i++) {
-      if (!value.equals(values[i]))
+      if (!value.equals(*values[i]))
 	 return false;
    }
 
@@ -272,7 +272,7 @@ vec4_visitor::try_copy_propagation(vec4_instruction *inst, int arg,
       return false;
 
    /* Don't report progress if this is a noop. */
-   if (value.equals(&inst->src[arg]))
+   if (value.equals(inst->src[arg]))
       return false;
 
    value.type = inst->src[arg].type;
-- 
2.0.0



More information about the mesa-dev mailing list