summaryrefslogtreecommitdiffstats
path: root/src/glsl/ir.h
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2013-10-30 23:56:18 -0700
committerEric Anholt <[email protected]>2013-11-15 11:33:07 -0800
commit8957c6b887ff09f44e7b491e7a0551e94a265b8d (patch)
tree2301a0352283077ecc0dbd87251d4f7eb4fdfbb6 /src/glsl/ir.h
parentfc51e7ac58d7aeab0b455e9d39b6547c2b954494 (diff)
glsl: Move the CSE equality functions to the ir class.
I want to reuse them in opt_algebraic. v2: Merge in Chris Forbes's break fix. Reviewed-by: Jordan Justen <[email protected]>
Diffstat (limited to 'src/glsl/ir.h')
-rw-r--r--src/glsl/ir.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index 2f06fb9eaa8..7859702ed01 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -139,6 +139,16 @@ public:
virtual class ir_jump * as_jump() { return NULL; }
/*@}*/
+ /**
+ * IR equality method: Return true if the referenced instruction would
+ * return the same value as this one.
+ *
+ * This intended to be used for CSE and algebraic optimizations, on rvalues
+ * in particular. No support for other instruction types (assignments,
+ * jumps, calls, etc.) is planned.
+ */
+ virtual bool equals(ir_instruction *ir);
+
protected:
ir_instruction()
{
@@ -1405,6 +1415,8 @@ public:
return this;
}
+ virtual bool equals(ir_instruction *ir);
+
virtual ir_expression *clone(void *mem_ctx, struct hash_table *ht) const;
/**
@@ -1739,6 +1751,8 @@ public:
virtual ir_visitor_status accept(ir_hierarchical_visitor *);
+ virtual bool equals(ir_instruction *ir);
+
/**
* Return a string representing the ir_texture_opcode.
*/
@@ -1843,6 +1857,8 @@ public:
virtual ir_visitor_status accept(ir_hierarchical_visitor *);
+ virtual bool equals(ir_instruction *ir);
+
bool is_lvalue() const
{
return val->is_lvalue() && !mask.has_duplicates;
@@ -1907,6 +1923,8 @@ public:
return this;
}
+ virtual bool equals(ir_instruction *ir);
+
/**
* Get the variable that is ultimately referenced by an r-value
*/
@@ -1965,6 +1983,8 @@ public:
return this;
}
+ virtual bool equals(ir_instruction *ir);
+
/**
* Get the variable that is ultimately referenced by an r-value
*/
@@ -2099,6 +2119,8 @@ public:
virtual ir_visitor_status accept(ir_hierarchical_visitor *);
+ virtual bool equals(ir_instruction *ir);
+
/**
* Get a particular component of a constant as a specific type
*