[Mesa-dev] [PATCH 15/23] glsl: Convert if lowering to use the util hash table
Thomas Helland
thomashelland90 at gmail.com
Tue Aug 16 20:10:28 UTC 2016
Also do some miner whitespace cleanups
Signed-off-by: Thomas Helland <thomashelland90 at gmail.com>
---
src/compiler/glsl/lower_if_to_cond_assign.cpp | 44 ++++++++++++++-------------
1 file changed, 23 insertions(+), 21 deletions(-)
diff --git a/src/compiler/glsl/lower_if_to_cond_assign.cpp b/src/compiler/glsl/lower_if_to_cond_assign.cpp
index 6a70347..a785ed3 100644
--- a/src/compiler/glsl/lower_if_to_cond_assign.cpp
+++ b/src/compiler/glsl/lower_if_to_cond_assign.cpp
@@ -47,7 +47,7 @@
#include "compiler/glsl_types.h"
#include "ir.h"
-#include "program/hash_table.h"
+#include "util/hash_table.h"
namespace {
@@ -59,13 +59,14 @@ public:
this->max_depth = max_depth;
this->depth = 0;
- this->condition_variables = hash_table_ctor(0, hash_table_pointer_hash,
- hash_table_pointer_compare);
+ this->condition_variables =
+ _mesa_hash_table_create(NULL, _mesa_hash_pointer,
+ _mesa_key_pointer_equal);
}
~ir_if_to_cond_assign_visitor()
{
- hash_table_dtor(this->condition_variables);
+ _mesa_hash_table_destroy(this->condition_variables, NULL);
}
ir_visitor_status visit_enter(ir_if *);
@@ -120,32 +121,33 @@ move_block_to_cond_assign(void *mem_ctx,
if (ir->ir_type == ir_type_assignment) {
ir_assignment *assign = (ir_assignment *)ir;
- if (hash_table_find(ht, assign) == NULL) {
- hash_table_insert(ht, assign, assign);
+ if (_mesa_hash_table_search(ht, assign) == NULL) {
+ _mesa_hash_table_insert(ht, assign, assign);
/* If the LHS of the assignment is a condition variable that was
* previously added, insert an additional assignment of false to
* the variable.
*/
const bool assign_to_cv =
- hash_table_find(ht, assign->lhs->variable_referenced()) != NULL;
+ _mesa_hash_table_search(
+ ht, assign->lhs->variable_referenced()) != NULL;
if (!assign->condition) {
- if (assign_to_cv) {
- assign->rhs =
- new(mem_ctx) ir_expression(ir_binop_logic_and,
- glsl_type::bool_type,
- cond_expr->clone(mem_ctx, NULL),
- assign->rhs);
- } else {
- assign->condition = cond_expr->clone(mem_ctx, NULL);
+ if (assign_to_cv) {
+ assign->rhs =
+ new(mem_ctx) ir_expression(ir_binop_logic_and,
+ glsl_type::bool_type,
+ cond_expr->clone(mem_ctx, NULL),
+ assign->rhs);
+ } else {
+ assign->condition = cond_expr->clone(mem_ctx, NULL);
}
} else {
assign->condition =
- new(mem_ctx) ir_expression(ir_binop_logic_and,
- glsl_type::bool_type,
- cond_expr->clone(mem_ctx, NULL),
- assign->condition);
+ new(mem_ctx) ir_expression(ir_binop_logic_and,
+ glsl_type::bool_type,
+ cond_expr->clone(mem_ctx, NULL),
+ assign->condition);
}
}
}
@@ -210,7 +212,7 @@ ir_if_to_cond_assign_visitor::visit_leave(ir_if *ir)
/* Add the new condition variable to the hash table. This allows us to
* find this variable when lowering other (enclosing) if-statements.
*/
- hash_table_insert(this->condition_variables, then_var, then_var);
+ _mesa_hash_table_insert(this->condition_variables, then_var, then_var);
/* If there are instructions in the else-clause, store the inverse of the
* condition to a variable. Move all of the instructions from the
@@ -241,7 +243,7 @@ ir_if_to_cond_assign_visitor::visit_leave(ir_if *ir)
/* Add the new condition variable to the hash table. This allows us to
* find this variable when lowering other (enclosing) if-statements.
*/
- hash_table_insert(this->condition_variables, else_var, else_var);
+ _mesa_hash_table_insert(this->condition_variables, else_var, else_var);
}
ir->remove();
--
2.9.2
More information about the mesa-dev
mailing list