glsl: Make ir_assignment::condition private

And add get_condition().

This proof that nothing remains that could possibly set ::condition to
anything other than NULL.

v2: Fix bad rebase.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14573>
This commit is contained in:
Ian Romanick
2022-01-14 18:56:41 -08:00
committed by Marge Bot
parent 5208c116f2
commit fb630cd783
18 changed files with 45 additions and 34 deletions

View File

@@ -1718,8 +1718,8 @@ nir_visitor::visit(ir_assignment *ir)
nir_deref_instr *rhs = evaluate_deref(ir->rhs);
enum gl_access_qualifier lhs_qualifiers = deref_get_qualifier(lhs);
enum gl_access_qualifier rhs_qualifiers = deref_get_qualifier(rhs);
if (ir->condition) {
nir_push_if(&b, evaluate_rvalue(ir->condition));
if (ir->get_condition()) {
nir_push_if(&b, evaluate_rvalue(ir->get_condition()));
nir_copy_deref_with_access(&b, lhs, rhs, lhs_qualifiers,
rhs_qualifiers);
nir_pop_if(&b, NULL);
@@ -1763,8 +1763,8 @@ nir_visitor::visit(ir_assignment *ir)
}
enum gl_access_qualifier qualifiers = deref_get_qualifier(lhs_deref);
if (ir->condition) {
nir_push_if(&b, evaluate_rvalue(ir->condition));
if (ir->get_condition()) {
nir_push_if(&b, evaluate_rvalue(ir->get_condition()));
nir_store_deref_with_access(&b, lhs_deref, src, write_mask,
qualifiers);
nir_pop_if(&b, NULL);

View File

@@ -153,7 +153,7 @@ ir_assignment::ir_assignment(ir_dereference *lhs, ir_rvalue *rhs,
unsigned write_mask)
: ir_instruction(ir_type_assignment)
{
this->condition = NULL;
this->unused_condition = NULL;
this->rhs = rhs;
this->lhs = lhs;
this->write_mask = write_mask;
@@ -165,7 +165,7 @@ ir_assignment::ir_assignment(ir_dereference *lhs, ir_rvalue *rhs,
ir_assignment::ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs)
: ir_instruction(ir_type_assignment)
{
this->condition = NULL;
this->unused_condition = NULL;
this->rhs = rhs;
/* If the RHS is a vector type, assume that all components of the vector

View File

@@ -1521,8 +1521,19 @@ public:
/**
* Optional condition for the assignment.
*/
ir_rvalue *condition;
private:
ir_rvalue *unused_condition;
public:
inline ir_rvalue *get_condition()
{
return unused_condition;
}
inline const ir_rvalue *get_condition() const
{
return unused_condition;
}
/**
* Component mask written

View File

@@ -507,7 +507,7 @@ ir_builder_print_visitor::visit_enter(ir_assignment *ir)
if (s != visit_continue)
return (s == visit_continue_with_parent) ? visit_continue : s;
assert(ir->condition == NULL);
assert(ir->get_condition() == NULL);
const struct hash_entry *const he_lhs =
_mesa_hash_table_search(index_map, ir->lhs);
@@ -529,7 +529,7 @@ ir_builder_print_visitor::visit_leave(ir_assignment *ir)
const struct hash_entry *const he_rhs =
_mesa_hash_table_search(index_map, ir->rhs);
assert(ir->condition == NULL);
assert(ir->get_condition() == NULL);
assert(ir->lhs && ir->rhs);
print_with_indent("body.emit(assign(r%04X, r%04X, 0x%02x));\n\n",

View File

@@ -259,7 +259,7 @@ ir_texture::clone(void *mem_ctx, struct hash_table *ht) const
ir_assignment *
ir_assignment::clone(void *mem_ctx, struct hash_table *ht) const
{
assert(this->condition == NULL);
assert(this->get_condition() == NULL);
return new(mem_ctx) ir_assignment(this->lhs->clone(mem_ctx, ht),
this->rhs->clone(mem_ctx, ht),

View File

@@ -1070,9 +1070,9 @@ bool ir_function_signature::constant_expression_evaluate_expression_list(void *m
/* (assign [condition] (write-mask) (ref) (value)) */
case ir_type_assignment: {
ir_assignment *asg = inst->as_assignment();
if (asg->condition) {
if (asg->get_condition()) {
ir_constant *cond =
asg->condition->constant_expression_value(mem_ctx,
asg->get_condition()->constant_expression_value(mem_ctx,
variable_context);
if (!cond)
return false;

View File

@@ -312,8 +312,8 @@ ir_assignment::accept(ir_hierarchical_visitor *v)
if (s != visit_continue)
return (s == visit_continue_with_parent) ? visit_continue : s;
if (this->condition)
s = this->condition->accept(v);
if (this->get_condition())
s = this->get_condition()->accept(v);
return (s == visit_stop) ? s : v->visit_leave(this);
}

View File

@@ -444,8 +444,8 @@ void ir_print_visitor::visit(ir_assignment *ir)
{
fprintf(f, "(assign ");
if (ir->condition)
ir->condition->accept(this);
if (ir->get_condition())
ir->get_condition()->accept(this);
char mask[5];
unsigned j = 0;

View File

@@ -71,7 +71,7 @@ find_initial_value(ir_loop *loop, ir_variable *var)
ir_variable *assignee = assign->lhs->whole_variable_referenced();
if (assignee == var)
return (assign->condition != NULL) ? NULL : assign->rhs;
return (assign->get_condition() != NULL) ? NULL : assign->rhs;
break;
}
@@ -241,7 +241,7 @@ incremented_before_terminator(ir_loop *loop, ir_variable *var,
ir_variable *assignee = assign->lhs->whole_variable_referenced();
if (assignee == var) {
assert(assign->condition == NULL);
assert(assign->get_condition() == NULL);
return true;
}
@@ -276,7 +276,7 @@ loop_variable::record_reference(bool in_assignee,
assert(current_assignment != NULL);
if (in_conditional_code_or_nested_loop ||
current_assignment->condition != NULL) {
current_assignment->get_condition() != NULL) {
this->conditional_or_nested_assignment = true;
}

View File

@@ -193,7 +193,7 @@ move_block_to_cond_assign(void *mem_ctx,
_mesa_set_search(
set, assign->lhs->variable_referenced()) != NULL;
if (!assign->condition) {
if (!assign->get_condition()) {
if (assign_to_cv) {
assign->rhs =
new(mem_ctx) ir_expression(ir_binop_logic_and,

View File

@@ -385,11 +385,11 @@ public:
* condition! This is acomplished by wrapping the new conditional
* assignments in an if-statement that uses the original condition.
*/
if (orig_assign != NULL && orig_assign->condition != NULL) {
if (orig_assign != NULL && orig_assign->get_condition() != NULL) {
/* No need to clone the condition because the IR that it hangs on is
* going to be removed from the instruction sequence.
*/
ir_if *if_stmt = new(mem_ctx) ir_if(orig_assign->condition);
ir_if *if_stmt = new(mem_ctx) ir_if(orig_assign->get_condition());
ir_factory then_body(&if_stmt->then_instructions, body.mem_ctx);
sg.generate(0, length, then_body);

View File

@@ -416,7 +416,7 @@ ir_array_splitting_visitor::visit_leave(ir_assignment *ir)
new(mem_ctx) ir_dereference_array(ir->rhs->clone(mem_ctx, NULL),
new(mem_ctx) ir_constant(i));
assert(ir->condition == NULL);
assert(ir->get_condition() == NULL);
ir_assignment *assign_i = new(mem_ctx) ir_assignment(lhs_i, rhs_i);

View File

@@ -486,7 +486,7 @@ ir_constant_propagation_visitor::add_constant(ir_assignment *ir)
{
acp_entry *entry;
if (ir->condition)
if (ir->get_condition())
return;
if (!ir->write_mask)

View File

@@ -119,7 +119,7 @@ ir_constant_variable_visitor::visit_enter(ir_assignment *ir)
/* OK, now find if we actually have all the right conditions for
* this to be a constant value assigned to the var.
*/
if (ir->condition)
if (ir->get_condition())
return visit_continue;
ir_variable *var = ir->whole_variable_written();

View File

@@ -654,7 +654,7 @@ ir_copy_propagation_elements_visitor::kill(kill_entry *k)
void
ir_copy_propagation_elements_visitor::add_copy(ir_assignment *ir)
{
if (ir->condition)
if (ir->get_condition())
return;
{

View File

@@ -175,7 +175,7 @@ process_assignment(void *lin_ctx, ir_assignment *ir, exec_list *assignments)
bool progress = false;
kill_for_derefs_visitor v(assignments);
if (ir->condition == NULL) {
if (ir->get_condition() == NULL) {
/* If this is an assignment of the form "foo = foo;", remove the whole
* instruction and be done with it.
*/
@@ -188,8 +188,8 @@ process_assignment(void *lin_ctx, ir_assignment *ir, exec_list *assignments)
/* Kill assignment entries for things used to produce this assignment. */
ir->rhs->accept(&v);
if (ir->condition) {
ir->condition->accept(&v);
if (ir->get_condition()) {
ir->get_condition()->accept(&v);
}
/* Kill assignment enties used as array indices.
@@ -199,7 +199,7 @@ process_assignment(void *lin_ctx, ir_assignment *ir, exec_list *assignments)
assert(var);
/* Now, check if we did a whole-variable assignment. */
if (!ir->condition) {
if (!ir->get_condition()) {
ir_dereference_variable *deref_var = ir->lhs->as_dereference_variable();
/* If it's a vector type, we can do per-channel elimination of

View File

@@ -161,7 +161,7 @@ ir_structure_reference_visitor::visit_enter(ir_assignment *ir)
if (ir->lhs->as_dereference_variable() &&
ir->rhs->as_dereference_variable() &&
!ir->condition) {
!ir->get_condition()) {
/* We'll split copies of a structure to copies of components, so don't
* descend to the ir_dereference_variables.
*/
@@ -264,7 +264,7 @@ ir_structure_splitting_visitor::visit_leave(ir_assignment *ir)
variable_entry *rhs_entry = rhs_deref ? get_splitting_entry(rhs_deref->var) : NULL;
const glsl_type *type = ir->rhs->type;
if ((lhs_entry || rhs_entry) && !ir->condition) {
if ((lhs_entry || rhs_entry) && !ir->get_condition()) {
for (unsigned int i = 0; i < type->length; i++) {
ir_dereference *new_lhs, *new_rhs;
void *mem_ctx = lhs_entry ? lhs_entry->mem_ctx : rhs_entry->mem_ctx;

View File

@@ -3387,8 +3387,8 @@ glsl_to_tgsi_visitor::visit(ir_assignment *ir)
assert(l.file != PROGRAM_UNDEFINED);
assert(r.file != PROGRAM_UNDEFINED);
if (ir->condition) {
const bool switch_order = this->process_move_condition(ir->condition);
if (ir->get_condition()) {
const bool switch_order = this->process_move_condition(ir->get_condition());
st_src_reg condition = this->result;
emit_block_mov(ir, ir->lhs->type, &l, &r, &condition, switch_order);