d3dcompiler: Store the loop body directly in the hlsr_ir_loop structure.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2020-07-05 17:45:36 -05:00 committed by Alexandre Julliard
parent 0a9f2d8b0a
commit 644dbf0644
3 changed files with 13 additions and 15 deletions

View File

@ -750,7 +750,7 @@ struct hlsl_ir_loop
{
struct hlsl_ir_node node;
/* loop condition is stored in the body (as "if (!condition) break;") */
struct list *body;
struct list body;
unsigned int next_index; /* liveness index of the end of the loop */
};

View File

@ -360,24 +360,21 @@ static struct list *create_loop(enum loop_type type, struct list *init, struct l
goto oom;
init_node(&loop->node, HLSL_IR_LOOP, NULL, loc);
list_add_tail(list, &loop->node.entry);
loop->body = d3dcompiler_alloc(sizeof(*loop->body));
if (!loop->body)
goto oom;
list_init(loop->body);
list_init(&loop->body);
if (!append_conditional_break(cond))
goto oom;
if (type != LOOP_DO_WHILE)
list_move_tail(loop->body, cond);
list_move_tail(&loop->body, cond);
list_move_tail(loop->body, body);
list_move_tail(&loop->body, body);
if (iter)
list_move_tail(loop->body, iter);
list_move_tail(&loop->body, iter);
if (type == LOOP_DO_WHILE)
list_move_tail(loop->body, cond);
list_move_tail(&loop->body, cond);
d3dcompiler_free(init);
d3dcompiler_free(cond);
@ -386,8 +383,6 @@ static struct list *create_loop(enum loop_type type, struct list *init, struct l
oom:
ERR("Out of memory.\n");
if (loop)
d3dcompiler_free(loop->body);
d3dcompiler_free(loop);
d3dcompiler_free(cond_jump);
d3dcompiler_free(list);
@ -2857,7 +2852,7 @@ static unsigned int index_instructions(struct list *instrs, unsigned int index)
}
else if (instr->type == HLSL_IR_LOOP)
{
index = index_instructions(loop_from_node(instr)->body, index);
index = index_instructions(&loop_from_node(instr)->body, index);
loop_from_node(instr)->next_index = index;
}
}
@ -2919,7 +2914,7 @@ static void compute_liveness_recurse(struct list *instrs, unsigned int loop_firs
case HLSL_IR_LOOP:
{
struct hlsl_ir_loop *loop = loop_from_node(instr);
compute_liveness_recurse(loop->body, loop_first ? loop_first : instr->index,
compute_liveness_recurse(&loop->body, loop_first ? loop_first : instr->index,
loop_last ? loop_last : loop->next_index);
break;
}

View File

@ -2027,7 +2027,7 @@ static void debug_dump_ir_if(const struct hlsl_ir_if *if_node)
static void debug_dump_ir_loop(const struct hlsl_ir_loop *loop)
{
wine_dbg_printf("for (;;)\n{\n");
debug_dump_instr_list(loop->body);
debug_dump_instr_list(&loop->body);
wine_dbg_printf("}\n");
}
@ -2165,7 +2165,10 @@ static void free_ir_if(struct hlsl_ir_if *if_node)
static void free_ir_loop(struct hlsl_ir_loop *loop)
{
free_instr_list(loop->body);
struct hlsl_ir_node *node, *next_node;
LIST_FOR_EACH_ENTRY_SAFE(node, next_node, &loop->body, struct hlsl_ir_node, entry)
free_instr(node);
d3dcompiler_free(loop);
}