glsl: Add ir_assignment constructor that takes just a write mask

The other constructor that takes a write mask and a condition will be
removed shortly.

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 17:38:05 -08:00
committed by Marge Bot
parent afee5dc63f
commit 710adf2e60
6 changed files with 26 additions and 12 deletions
+7 -8
View File
@@ -1265,8 +1265,7 @@ process_vec_mat_constructor(exec_list *instructions,
assert(var->type->is_vector());
assert(i < 4);
ir_dereference *lhs = new(ctx) ir_dereference_variable(var);
assignment = new(ctx) ir_assignment(lhs, rhs, NULL,
(unsigned)(1 << i));
assignment = new(ctx) ir_assignment(lhs, rhs, 1u << i);
}
instructions->push_tail(assignment);
@@ -1463,7 +1462,7 @@ emit_inline_vector_constructor(const glsl_type *type,
assert(rhs->type == lhs->type);
ir_instruction *inst = new(ctx) ir_assignment(lhs, rhs, NULL, mask);
ir_instruction *inst = new(ctx) ir_assignment(lhs, rhs, mask);
instructions->push_tail(inst);
} else {
unsigned base_component = 0;
@@ -1533,7 +1532,7 @@ emit_inline_vector_constructor(const glsl_type *type,
ir_rvalue *rhs = new(ctx) ir_constant(rhs_type, &data);
ir_instruction *inst =
new(ctx) ir_assignment(lhs, rhs, NULL, constant_mask);
new(ctx) ir_assignment(lhs, rhs, constant_mask);
instructions->push_tail(inst);
}
@@ -1567,7 +1566,7 @@ emit_inline_vector_constructor(const glsl_type *type,
new(ctx) ir_swizzle(param, 0, 1, 2, 3, rhs_components);
ir_instruction *inst =
new(ctx) ir_assignment(lhs, rhs, NULL, write_mask);
new(ctx) ir_assignment(lhs, rhs, write_mask);
instructions->push_tail(inst);
}
@@ -1618,7 +1617,7 @@ assign_to_matrix_column(ir_variable *var, unsigned column, unsigned row_base,
/* Mask of fields to be written in the assignment. */
const unsigned write_mask = ((1U << count) - 1) << row_base;
return new(mem_ctx) ir_assignment(column_ref, src, NULL, write_mask);
return new(mem_ctx) ir_assignment(column_ref, src, write_mask);
}
@@ -1686,7 +1685,7 @@ emit_inline_matrix_constructor(const glsl_type *type,
ir_dereference *const rhs_ref =
new(ctx) ir_dereference_variable(rhs_var);
inst = new(ctx) ir_assignment(rhs_ref, first_param, NULL, 0x01);
inst = new(ctx) ir_assignment(rhs_ref, first_param, 0x01);
instructions->push_tail(inst);
/* Assign the temporary vector to each column of the destination matrix
@@ -1835,7 +1834,7 @@ emit_inline_matrix_constructor(const glsl_type *type,
}
ir_instruction *inst =
new(ctx) ir_assignment(lhs, rhs, NULL, write_mask);
new(ctx) ir_assignment(lhs, rhs, write_mask);
instructions->push_tail(inst);
}
} else {
+14
View File
@@ -23,6 +23,7 @@
#include <string.h>
#include "ir.h"
#include "util/half_float.h"
#include "util/bitscan.h"
#include "compiler/glsl_types.h"
#include "glsl_parser_extras.h"
@@ -168,6 +169,19 @@ ir_assignment::ir_assignment(ir_dereference *lhs, ir_rvalue *rhs,
}
}
ir_assignment::ir_assignment(ir_dereference *lhs, ir_rvalue *rhs,
unsigned write_mask)
: ir_instruction(ir_type_assignment)
{
this->condition = NULL;
this->rhs = rhs;
this->lhs = lhs;
this->write_mask = write_mask;
if (lhs->type->is_scalar() || lhs->type->is_vector())
assert(util_bitcount(write_mask) == this->rhs->type->vector_elements);
}
ir_assignment::ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs,
ir_rvalue *condition)
: ir_instruction(ir_type_assignment)
+2
View File
@@ -1475,6 +1475,8 @@ public:
ir_assignment(ir_dereference *lhs, ir_rvalue *rhs, ir_rvalue *condition,
unsigned write_mask);
ir_assignment(ir_dereference *lhs, ir_rvalue *rhs, unsigned write_mask);
virtual ir_assignment *clone(void *mem_ctx, struct hash_table *ht) const;
virtual ir_constant *constant_expression_value(void *mem_ctx,
-1
View File
@@ -58,7 +58,6 @@ assign(deref lhs, operand rhs, int writemask)
ir_assignment *assign = new(mem_ctx) ir_assignment(lhs.val,
rhs.val,
NULL,
writemask);
return assign;
+1 -1
View File
@@ -271,7 +271,7 @@ ir_mat_op_to_vec_visitor::do_equal_mat_mat(ir_dereference *result,
new(this->mem_ctx) ir_dereference_variable(tmp_bvec);
ir_assignment *const assign =
new(this->mem_ctx) ir_assignment(lhs, cmp, NULL, (1U << i));
new(this->mem_ctx) ir_assignment(lhs, cmp, 1U << i);
this->base_ir->insert_before(assign);
}
+2 -2
View File
@@ -191,7 +191,7 @@ lower_vector_visitor::handle_rvalue(ir_rvalue **rvalue)
&d);
ir_dereference *const lhs = new(mem_ctx) ir_dereference_variable(temp);
ir_assignment *const assign =
new(mem_ctx) ir_assignment(lhs, c, NULL, write_mask);
new(mem_ctx) ir_assignment(lhs, c, write_mask);
this->base_ir->insert_before(assign);
}
@@ -204,7 +204,7 @@ lower_vector_visitor::handle_rvalue(ir_rvalue **rvalue)
ir_dereference *const lhs = new(mem_ctx) ir_dereference_variable(temp);
ir_assignment *const assign =
new(mem_ctx) ir_assignment(lhs, expr->operands[i], NULL, (1U << i));
new(mem_ctx) ir_assignment(lhs, expr->operands[i], 1U << i);
this->base_ir->insert_before(assign);
assigned++;