#include "ir_visitor.h"
#include "glsl_types.h"
-class variable_entry : public exec_node
+struct assignment_entry {
+ exec_node link;
+ ir_assignment *assign;
+};
+
+class ir_variable_refcount_entry
{
public:
- variable_entry(ir_variable *var)
- {
- this->var = var;
- assign = NULL;
- referenced_count = 0;
- assigned_count = 0;
- declaration = false;
- }
+ ir_variable_refcount_entry(ir_variable *var);
ir_variable *var; /* The key: the variable's pointer. */
- ir_assignment *assign; /* An assignment to the variable, if any */
+
+ /**
+ * List of assignments to the variable, if any.
+ * This is intended to be used for dead code optimisation and may
+ * not be a complete list.
+ */
+ exec_list assign_list;
/** Number of times the variable is referenced, including assignments. */
unsigned referenced_count;
class ir_variable_refcount_visitor : public ir_hierarchical_visitor {
public:
- ir_variable_refcount_visitor(void)
- {
- this->mem_ctx = talloc_new(NULL);
- this->variable_list.make_empty();
- }
-
- ~ir_variable_refcount_visitor(void)
- {
- this->mem_ctx = talloc_new(NULL);
- }
+ ir_variable_refcount_visitor(void);
+ ~ir_variable_refcount_visitor(void);
virtual ir_visitor_status visit(ir_variable *);
virtual ir_visitor_status visit(ir_dereference_variable *);
virtual ir_visitor_status visit_enter(ir_function_signature *);
virtual ir_visitor_status visit_leave(ir_assignment *);
- variable_entry *get_variable_entry(ir_variable *var);
+ ir_variable_refcount_entry *get_variable_entry(ir_variable *var);
- /* List of variable_entry */
- exec_list variable_list;
+ struct hash_table *ht;
void *mem_ctx;
};