mesa: Use the new hash table for the variable refcount visitor.
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> [jordan.l.justen@intel.com: open_hash_table => hash_table] Signed-off-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:

committed by
Jordan Justen

parent
59284bc44a
commit
1ddc021b2a
@@ -49,6 +49,7 @@ libglsl_la_LIBADD = glcpp/libglcpp.la
|
||||
libglsl_la_LDFLAGS =
|
||||
|
||||
glsl_compiler_SOURCES = \
|
||||
$(top_srcdir)/src/mesa/main/hash_table.c \
|
||||
$(top_srcdir)/src/mesa/program/prog_hash_table.c \
|
||||
$(top_srcdir)/src/mesa/program/symbol_table.c \
|
||||
$(GLSL_COMPILER_CXX_FILES)
|
||||
@@ -56,6 +57,7 @@ glsl_compiler_SOURCES = \
|
||||
glsl_compiler_LDADD = libglsl.la
|
||||
|
||||
glsl_test_SOURCES = \
|
||||
$(top_srcdir)/src/mesa/main/hash_table.c \
|
||||
$(top_srcdir)/src/mesa/program/prog_hash_table.c \
|
||||
$(top_srcdir)/src/mesa/program/symbol_table.c \
|
||||
$(GLSL_SRCDIR)/standalone_scaffolding.cpp \
|
||||
|
@@ -56,6 +56,9 @@ if env['msvc']:
|
||||
if env['crosscompile'] and not env['embedded']:
|
||||
Import('builtin_glsl_function')
|
||||
else:
|
||||
# Copy these files to avoid generation object files into src/mesa/program
|
||||
env.Prepend(CPPPATH = ['#src/mesa/main'])
|
||||
env.Command('hash_table.c', '#src/mesa/main/hash_table.c', Copy('$TARGET', '$SOURCE'))
|
||||
# Copy these files to avoid generation object files into src/mesa/program
|
||||
env.Prepend(CPPPATH = ['#src/mesa/program'])
|
||||
env.Command('prog_hash_table.c', '#src/mesa/program/prog_hash_table.c', Copy('$TARGET', '$SOURCE'))
|
||||
@@ -64,6 +67,7 @@ else:
|
||||
compiler_objs = env.StaticObject(source_lists['GLSL_COMPILER_CXX_FILES'])
|
||||
|
||||
mesa_objs = env.StaticObject([
|
||||
'hash_table.c',
|
||||
'prog_hash_table.c',
|
||||
'symbol_table.c',
|
||||
])
|
||||
|
@@ -55,6 +55,7 @@ builtin_compiler_SOURCES = \
|
||||
$(GLSL_BUILDDIR)/glsl_parser.cc \
|
||||
$(LIBGLSL_FILES) \
|
||||
$(LIBGLSL_CXX_FILES) \
|
||||
$(top_srcdir)/src/mesa/main/hash_table.c \
|
||||
$(top_srcdir)/src/mesa/program/prog_hash_table.c \
|
||||
$(top_srcdir)/src/mesa/program/symbol_table.c \
|
||||
$(GLSL_COMPILER_CXX_FILES) \
|
||||
|
@@ -33,7 +33,26 @@
|
||||
#include "ir_visitor.h"
|
||||
#include "ir_variable_refcount.h"
|
||||
#include "glsl_types.h"
|
||||
#include "main/hash_table.h"
|
||||
|
||||
ir_variable_refcount_visitor::ir_variable_refcount_visitor()
|
||||
{
|
||||
this->mem_ctx = ralloc_context(NULL);
|
||||
this->ht = _mesa_hash_table_create(NULL, _mesa_key_pointer_equal);
|
||||
}
|
||||
|
||||
static void
|
||||
free_entry(struct hash_entry *entry)
|
||||
{
|
||||
ir_variable_refcount_entry *ivre = (ir_variable_refcount_entry *) entry->data;
|
||||
delete ivre;
|
||||
}
|
||||
|
||||
ir_variable_refcount_visitor::~ir_variable_refcount_visitor()
|
||||
{
|
||||
ralloc_free(this->mem_ctx);
|
||||
_mesa_hash_table_destroy(this->ht, free_entry);
|
||||
}
|
||||
|
||||
// constructor
|
||||
ir_variable_refcount_entry::ir_variable_refcount_entry(ir_variable *var)
|
||||
@@ -50,15 +69,17 @@ 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) {
|
||||
ir_variable_refcount_entry *entry = (ir_variable_refcount_entry *)iter.get();
|
||||
if (entry->var == var)
|
||||
return entry;
|
||||
}
|
||||
|
||||
ir_variable_refcount_entry *entry = new(mem_ctx) ir_variable_refcount_entry(var);
|
||||
struct hash_entry *e = _mesa_hash_table_search(this->ht,
|
||||
_mesa_hash_pointer(var),
|
||||
var);
|
||||
if (e)
|
||||
return (ir_variable_refcount_entry *)e->data;
|
||||
|
||||
ir_variable_refcount_entry *entry = new ir_variable_refcount_entry(var);
|
||||
assert(entry->referenced_count == 0);
|
||||
this->variable_list.push_tail(entry);
|
||||
_mesa_hash_table_insert(this->ht, _mesa_hash_pointer(var), var, entry);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
@@ -33,7 +33,7 @@
|
||||
#include "ir_visitor.h"
|
||||
#include "glsl_types.h"
|
||||
|
||||
class ir_variable_refcount_entry : public exec_node
|
||||
class ir_variable_refcount_entry
|
||||
{
|
||||
public:
|
||||
ir_variable_refcount_entry(ir_variable *var);
|
||||
@@ -52,16 +52,8 @@ public:
|
||||
|
||||
class ir_variable_refcount_visitor : public ir_hierarchical_visitor {
|
||||
public:
|
||||
ir_variable_refcount_visitor(void)
|
||||
{
|
||||
this->mem_ctx = ralloc_context(NULL);
|
||||
this->variable_list.make_empty();
|
||||
}
|
||||
|
||||
~ir_variable_refcount_visitor(void)
|
||||
{
|
||||
ralloc_free(this->mem_ctx);
|
||||
}
|
||||
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 *);
|
||||
@@ -71,8 +63,7 @@ public:
|
||||
|
||||
ir_variable_refcount_entry *get_variable_entry(ir_variable *var);
|
||||
|
||||
/* List of ir_variable_refcount_entry */
|
||||
exec_list variable_list;
|
||||
struct hash_table *ht;
|
||||
|
||||
void *mem_ctx;
|
||||
};
|
||||
|
@@ -31,6 +31,7 @@
|
||||
#include "ir_visitor.h"
|
||||
#include "ir_variable_refcount.h"
|
||||
#include "glsl_types.h"
|
||||
#include "main/hash_table.h"
|
||||
|
||||
static bool debug = false;
|
||||
|
||||
@@ -49,8 +50,9 @@ do_dead_code(exec_list *instructions, bool uniform_locations_assigned)
|
||||
|
||||
v.run(instructions);
|
||||
|
||||
foreach_iter(exec_list_iterator, iter, v.variable_list) {
|
||||
ir_variable_refcount_entry *entry = (ir_variable_refcount_entry *)iter.get();
|
||||
struct hash_entry *e;
|
||||
hash_table_foreach(v.ht, e) {
|
||||
ir_variable_refcount_entry *entry = (ir_variable_refcount_entry *)e->data;
|
||||
|
||||
/* Since each assignment is a reference, the refereneced count must be
|
||||
* greater than or equal to the assignment count. If they are equal,
|
||||
|
@@ -36,6 +36,7 @@ include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := libmesa_glsl_utils
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
main/hash_table.c \
|
||||
program/prog_hash_table.c \
|
||||
program/symbol_table.c
|
||||
|
||||
@@ -52,6 +53,7 @@ LOCAL_MODULE := libmesa_glsl_utils
|
||||
LOCAL_IS_HOST_MODULE := true
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
main/hash_table.c \
|
||||
program/prog_hash_table.c \
|
||||
program/symbol_table.c
|
||||
|
||||
|
Reference in New Issue
Block a user