aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2012-10-17 15:20:09 -0700
committerJordan Justen <[email protected]>2012-12-07 14:46:18 -0800
commit1ddc021b2a992a214a7668672d35a55c160f6a90 (patch)
tree19b3e4edcc5be22e010ceba05ced0bf5fdf1d779
parent59284bc44a3f30ec18192098a4e1e43b6c6d392a (diff)
mesa: Use the new hash table for the variable refcount visitor.
Reviewed-by: Jordan Justen <[email protected]> [[email protected]: open_hash_table => hash_table] Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
-rw-r--r--src/glsl/Makefile.am2
-rw-r--r--src/glsl/SConscript4
-rw-r--r--src/glsl/builtin_compiler/Makefile.am1
-rw-r--r--src/glsl/ir_variable_refcount.cpp35
-rw-r--r--src/glsl/ir_variable_refcount.h17
-rw-r--r--src/glsl/opt_dead_code.cpp6
-rw-r--r--src/mesa/Android.libmesa_glsl_utils.mk2
7 files changed, 45 insertions, 22 deletions
diff --git a/src/glsl/Makefile.am b/src/glsl/Makefile.am
index 2ba439c77cc..aff1559e0f1 100644
--- a/src/glsl/Makefile.am
+++ b/src/glsl/Makefile.am
@@ -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 \
diff --git a/src/glsl/SConscript b/src/glsl/SConscript
index 38de60ded33..6abba2a240f 100644
--- a/src/glsl/SConscript
+++ b/src/glsl/SConscript
@@ -57,6 +57,9 @@ 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'))
env.Command('symbol_table.c', '#src/mesa/program/symbol_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',
])
diff --git a/src/glsl/builtin_compiler/Makefile.am b/src/glsl/builtin_compiler/Makefile.am
index 5fad35d50e7..d27aca5550e 100644
--- a/src/glsl/builtin_compiler/Makefile.am
+++ b/src/glsl/builtin_compiler/Makefile.am
@@ -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) \
diff --git a/src/glsl/ir_variable_refcount.cpp b/src/glsl/ir_variable_refcount.cpp
index 1633a735744..923eb1a8274 100644
--- a/src/glsl/ir_variable_refcount.cpp
+++ b/src/glsl/ir_variable_refcount.cpp
@@ -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;
}
diff --git a/src/glsl/ir_variable_refcount.h b/src/glsl/ir_variable_refcount.h
index 51a4945a135..c15e8110d04 100644
--- a/src/glsl/ir_variable_refcount.h
+++ b/src/glsl/ir_variable_refcount.h
@@ -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;
};
diff --git a/src/glsl/opt_dead_code.cpp b/src/glsl/opt_dead_code.cpp
index de8475f956e..47247e20d9f 100644
--- a/src/glsl/opt_dead_code.cpp
+++ b/src/glsl/opt_dead_code.cpp
@@ -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,
diff --git a/src/mesa/Android.libmesa_glsl_utils.mk b/src/mesa/Android.libmesa_glsl_utils.mk
index 5ae946fd8dc..9beeda57f55 100644
--- a/src/mesa/Android.libmesa_glsl_utils.mk
+++ b/src/mesa/Android.libmesa_glsl_utils.mk
@@ -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