[PATCH v2 1/3] d3dcompiler: Store derefs as an offset to a variable.
Matteo Bruni
matteo.mystral at gmail.com
Fri May 22 13:38:56 CDT 2020
On Wed, May 20, 2020 at 3:18 AM Zebediah Figura <z.figura12 at gmail.com> wrote:
>
> @@ -633,17 +660,21 @@ static struct hlsl_ir_deref *new_array_deref(struct hlsl_ir_node *array,
> return NULL;
> }
>
> - if (!(array = get_var_deref(array)))
> - return NULL;
> + if (data_type->reg_size > 1)
> + {
Doesn't this need to happen even for reg_size == 1 now that we're
using a scalar offset?
> + struct hlsl_ir_constant *c;
> + struct hlsl_ir_node *mul;
>
> - if (!(deref = d3dcompiler_alloc(sizeof(*deref))))
> - return NULL;
> + if (!(c = new_uint_constant(data_type->reg_size * 4, loc)))
> + return NULL;
> + list_add_after(&index->entry, &c->node.entry);
> + if (!(mul = new_binary_expr(HLSL_IR_BINOP_MUL, index, &c->node, loc)))
> + return NULL;
> + list_add_after(&c->node.entry, &mul->entry);
> + index = mul;
> + }
>
> - init_node(&deref->node, HLSL_IR_DEREF, data_type, loc);
> - deref->src.type = HLSL_IR_DEREF_ARRAY;
> - deref->src.v.array.array = array;
> - deref->src.v.array.index = index;
> - return deref;
> + return new_deref(array, index, data_type, loc);
> }
>
> static void struct_var_initializer(struct list *list, struct hlsl_ir_var *var,
> @@ -1513,12 +1490,6 @@ struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *lhs, enum parse_assign
> lhs = lhs_inner;
> }
>
> - if (!validate_lhs_deref(lhs))
> - {
> - d3dcompiler_free(assign);
> - return NULL;
> - }
> -
> TRACE("Creating proper assignment expression.\n");
> if (writemask == BWRITERSP_WRITEMASK_ALL)
> type = lhs->data_type;
> @@ -1562,26 +1533,12 @@ struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *lhs, enum parse_assign
> enum hlsl_ir_expr_op op = op_from_assignment(assign_op);
> struct hlsl_ir_node *expr;
>
> - if (assign->lhs.type != HLSL_IR_DEREF_VAR)
> - {
> - FIXME("LHS expression not supported in compound assignments yet.\n");
> - assign->rhs = rhs;
> - }
> - else
> - {
> - TRACE("Adding an expression for the compound assignment.\n");
> - expr = new_binary_expr(op, lhs, rhs, lhs->loc);
> - list_add_after(&rhs->entry, &expr->entry);
> - assign->rhs = expr;
> - }
> - }
> - else
> - {
> - list_remove(&lhs->entry);
> - /* Don't recursively free the deref; we just copied its members. */
> - d3dcompiler_free(lhs);
> - assign->rhs = rhs;
> + TRACE("Adding an expression for the compound assignment.\n");
> + expr = new_binary_expr(op, lhs, rhs, lhs->loc);
> + list_add_after(&rhs->entry, &expr->entry);
> + rhs = expr;
> }
> + assign->rhs = rhs;
I guess this is one of the cases where using a struct hlsl_deref for
both lvalues and rvalues comes in handy (to some degree).
More information about the wine-devel
mailing list