Commit 54387427 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

d3dcompiler: Separate out an hlsl_deref structure and store it in hlsl_ir_assignment directly.

parent bdbf0b43
...@@ -796,14 +796,6 @@ struct hlsl_ir_loop ...@@ -796,14 +796,6 @@ struct hlsl_ir_loop
struct list *body; struct list *body;
}; };
struct hlsl_ir_assignment
{
struct hlsl_ir_node node;
struct hlsl_ir_node *lhs;
struct hlsl_ir_node *rhs;
unsigned char writemask;
};
enum hlsl_ir_expr_op { enum hlsl_ir_expr_op {
HLSL_IR_UNOP_BIT_NOT = 0, HLSL_IR_UNOP_BIT_NOT = 0,
HLSL_IR_UNOP_LOGIC_NOT, HLSL_IR_UNOP_LOGIC_NOT,
...@@ -907,9 +899,8 @@ enum hlsl_ir_deref_type ...@@ -907,9 +899,8 @@ enum hlsl_ir_deref_type
HLSL_IR_DEREF_RECORD, HLSL_IR_DEREF_RECORD,
}; };
struct hlsl_ir_deref struct hlsl_deref
{ {
struct hlsl_ir_node node;
enum hlsl_ir_deref_type type; enum hlsl_ir_deref_type type;
union union
{ {
...@@ -927,6 +918,20 @@ struct hlsl_ir_deref ...@@ -927,6 +918,20 @@ struct hlsl_ir_deref
} v; } v;
}; };
struct hlsl_ir_deref
{
struct hlsl_ir_node node;
struct hlsl_deref src;
};
struct hlsl_ir_assignment
{
struct hlsl_ir_node node;
struct hlsl_deref lhs;
struct hlsl_ir_node *rhs;
unsigned char writemask;
};
struct hlsl_ir_constant struct hlsl_ir_constant
{ {
struct hlsl_ir_node node; struct hlsl_ir_node node;
......
...@@ -2123,9 +2123,9 @@ postfix_expr: primary_expr ...@@ -2123,9 +2123,9 @@ postfix_expr: primary_expr
free_instr_list($3); free_instr_list($3);
YYABORT; YYABORT;
} }
deref->type = HLSL_IR_DEREF_ARRAY; deref->src.type = HLSL_IR_DEREF_ARRAY;
deref->v.array.array = node_from_list($1); deref->src.v.array.array = node_from_list($1);
deref->v.array.index = node_from_list($3); deref->src.v.array.index = node_from_list($3);
$$ = append_binop($1, $3, &deref->node); $$ = append_binop($1, $3, &deref->node);
} }
......
...@@ -1380,8 +1380,8 @@ struct hlsl_ir_deref *new_var_deref(struct hlsl_ir_var *var) ...@@ -1380,8 +1380,8 @@ struct hlsl_ir_deref *new_var_deref(struct hlsl_ir_var *var)
} }
deref->node.type = HLSL_IR_DEREF; deref->node.type = HLSL_IR_DEREF;
deref->node.data_type = var->data_type; deref->node.data_type = var->data_type;
deref->type = HLSL_IR_DEREF_VAR; deref->src.type = HLSL_IR_DEREF_VAR;
deref->v.var = var; deref->src.v.var = var;
return deref; return deref;
} }
...@@ -1396,9 +1396,9 @@ struct hlsl_ir_deref *new_record_deref(struct hlsl_ir_node *record, struct hlsl_ ...@@ -1396,9 +1396,9 @@ struct hlsl_ir_deref *new_record_deref(struct hlsl_ir_node *record, struct hlsl_
} }
deref->node.type = HLSL_IR_DEREF; deref->node.type = HLSL_IR_DEREF;
deref->node.data_type = field->type; deref->node.data_type = field->type;
deref->type = HLSL_IR_DEREF_RECORD; deref->src.type = HLSL_IR_DEREF_RECORD;
deref->v.record.record = record; deref->src.v.record.record = record;
deref->v.record.field = field; deref->src.v.record.field = field;
return deref; return deref;
} }
...@@ -1547,13 +1547,13 @@ struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *lhs, enum parse_assign ...@@ -1547,13 +1547,13 @@ struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *lhs, enum parse_assign
rhs = implicit_conversion(rhs, type, &rhs->loc); rhs = implicit_conversion(rhs, type, &rhs->loc);
assign->lhs = lhs; assign->lhs = deref_from_node(lhs)->src;
if (assign_op != ASSIGN_OP_ASSIGN) if (assign_op != ASSIGN_OP_ASSIGN)
{ {
enum hlsl_ir_expr_op op = op_from_assignment(assign_op); enum hlsl_ir_expr_op op = op_from_assignment(assign_op);
struct hlsl_ir_node *expr; struct hlsl_ir_node *expr;
if (deref_from_node(lhs)->type != HLSL_IR_DEREF_VAR) if (assign->lhs.type != HLSL_IR_DEREF_VAR)
{ {
FIXME("LHS expression not supported in compound assignments yet.\n"); FIXME("LHS expression not supported in compound assignments yet.\n");
assign->rhs = rhs; assign->rhs = rhs;
...@@ -1567,7 +1567,12 @@ struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *lhs, enum parse_assign ...@@ -1567,7 +1567,12 @@ struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *lhs, enum parse_assign
} }
} }
else else
{
list_remove(&lhs->entry);
/* Don't recursively free the deref; we just copied its members. */
d3dcompiler_free(lhs);
assign->rhs = rhs; assign->rhs = rhs;
}
return &assign->node; return &assign->node;
} }
...@@ -1860,7 +1865,7 @@ static void debug_dump_ir_var(const struct hlsl_ir_var *var) ...@@ -1860,7 +1865,7 @@ static void debug_dump_ir_var(const struct hlsl_ir_var *var)
wine_dbg_printf(" : %s", debugstr_a(var->semantic)); wine_dbg_printf(" : %s", debugstr_a(var->semantic));
} }
static void debug_dump_ir_deref(const struct hlsl_ir_deref *deref) static void debug_dump_deref(const struct hlsl_deref *deref)
{ {
switch (deref->type) switch (deref->type)
{ {
...@@ -2048,7 +2053,7 @@ static const char *debug_writemask(DWORD writemask) ...@@ -2048,7 +2053,7 @@ static const char *debug_writemask(DWORD writemask)
static void debug_dump_ir_assignment(const struct hlsl_ir_assignment *assign) static void debug_dump_ir_assignment(const struct hlsl_ir_assignment *assign)
{ {
wine_dbg_printf("= ("); wine_dbg_printf("= (");
debug_dump_src(assign->lhs); debug_dump_deref(&assign->lhs);
if (assign->writemask != BWRITERSP_WRITEMASK_ALL) if (assign->writemask != BWRITERSP_WRITEMASK_ALL)
wine_dbg_printf("%s", debug_writemask(assign->writemask)); wine_dbg_printf("%s", debug_writemask(assign->writemask));
wine_dbg_printf(" "); wine_dbg_printf(" ");
...@@ -2129,7 +2134,7 @@ static void debug_dump_instr(const struct hlsl_ir_node *instr) ...@@ -2129,7 +2134,7 @@ static void debug_dump_instr(const struct hlsl_ir_node *instr)
debug_dump_ir_expr(expr_from_node(instr)); debug_dump_ir_expr(expr_from_node(instr));
break; break;
case HLSL_IR_DEREF: case HLSL_IR_DEREF:
debug_dump_ir_deref(deref_from_node(instr)); debug_dump_deref(&deref_from_node(instr)->src);
break; break;
case HLSL_IR_CONSTANT: case HLSL_IR_CONSTANT:
debug_dump_ir_constant(constant_from_node(instr)); debug_dump_ir_constant(constant_from_node(instr));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment