nv50,nvc0: share the format table code
[mesa.git] / src / glsl / ir_variable_refcount.cpp
index 20c2f6602bf229c749a069c932ebfbdd10fd58a9..1633a735744126207d478b03dec5789f061a67e8 100644 (file)
 #include "ir_variable_refcount.h"
 #include "glsl_types.h"
 
-variable_entry *
+
+// constructor
+ir_variable_refcount_entry::ir_variable_refcount_entry(ir_variable *var)
+{
+   this->var = var;
+   assign = NULL;
+   assigned_count = 0;
+   declaration = false;
+   referenced_count = 0;
+}
+
+
+ir_variable_refcount_entry *
 ir_variable_refcount_visitor::get_variable_entry(ir_variable *var)
 {
    assert(var);
    foreach_iter(exec_list_iterator, iter, this->variable_list) {
-      variable_entry *entry = (variable_entry *)iter.get();
+      ir_variable_refcount_entry *entry = (ir_variable_refcount_entry *)iter.get();
       if (entry->var == var)
         return entry;
    }
 
-   variable_entry *entry = new(mem_ctx) variable_entry(var);
+   ir_variable_refcount_entry *entry = new(mem_ctx) ir_variable_refcount_entry(var);
+   assert(entry->referenced_count == 0);
    this->variable_list.push_tail(entry);
    return entry;
 }
@@ -53,7 +66,7 @@ ir_variable_refcount_visitor::get_variable_entry(ir_variable *var)
 ir_visitor_status
 ir_variable_refcount_visitor::visit(ir_variable *ir)
 {
-   variable_entry *entry = this->get_variable_entry(ir);
+   ir_variable_refcount_entry *entry = this->get_variable_entry(ir);
    if (entry)
       entry->declaration = true;
 
@@ -65,7 +78,7 @@ ir_visitor_status
 ir_variable_refcount_visitor::visit(ir_dereference_variable *ir)
 {
    ir_variable *const var = ir->variable_referenced();
-   variable_entry *entry = this->get_variable_entry(var);
+   ir_variable_refcount_entry *entry = this->get_variable_entry(var);
 
    if (entry)
       entry->referenced_count++;
@@ -88,7 +101,7 @@ ir_variable_refcount_visitor::visit_enter(ir_function_signature *ir)
 ir_visitor_status
 ir_variable_refcount_visitor::visit_leave(ir_assignment *ir)
 {
-   variable_entry *entry;
+   ir_variable_refcount_entry *entry;
    entry = this->get_variable_entry(ir->lhs->variable_referenced());
    if (entry) {
       entry->assigned_count++;