From 8957c6b887ff09f44e7b491e7a0551e94a265b8d Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 30 Oct 2013 23:56:18 -0700 Subject: 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 --- src/glsl/ir.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/glsl/ir.h') 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 * -- cgit v1.2.3