vkd3d-shader/hlsl: Introduce an hlsl_block_add_instr() helper.

This commit is contained in:
Zebediah Figura 2022-11-11 21:13:50 -06:00 committed by Alexandre Julliard
parent e27ceddfb4
commit ceac81b816
Notes: Alexandre Julliard 2023-04-06 22:22:24 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/138
4 changed files with 23 additions and 18 deletions

View File

@ -490,7 +490,7 @@ static bool init_deref_from_component_index(struct hlsl_ctx *ctx, struct hlsl_bl
hlsl_free_instr_list(&block->instrs);
return false;
}
list_add_tail(&block->instrs, &c->node.entry);
hlsl_block_add_instr(block, &c->node);
hlsl_src_from_node(&deref->path[deref_path_len++], &c->node);
}
@ -1029,7 +1029,7 @@ struct hlsl_ir_store *hlsl_new_store_component(struct hlsl_ctx *ctx, struct hlsl
if (type_is_single_reg(rhs->data_type))
store->writemask = (1 << rhs->data_type->dimx) - 1;
list_add_tail(&block->instrs, &store->node.entry);
hlsl_block_add_instr(block, &store->node);
return store;
}
@ -1217,7 +1217,7 @@ struct hlsl_ir_load *hlsl_new_load_component(struct hlsl_ctx *ctx, struct hlsl_b
}
list_move_tail(&block->instrs, &comp_path_block.instrs);
list_add_tail(&block->instrs, &load->node.entry);
hlsl_block_add_instr(block, &load->node);
return load;
}
@ -1622,11 +1622,11 @@ struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx,
if (!(constant = hlsl_new_bool_constant(ctx, false, loc)))
return decl;
list_add_tail(&decl->body.instrs, &constant->node.entry);
hlsl_block_add_instr(&decl->body, &constant->node);
if (!(store = hlsl_new_simple_store(ctx, decl->early_return_var, &constant->node)))
return decl;
list_add_tail(&decl->body.instrs, &store->node.entry);
hlsl_block_add_instr(&decl->body, &store->node);
return decl;
}

View File

@ -857,6 +857,11 @@ static inline struct hlsl_ir_swizzle *hlsl_ir_swizzle(const struct hlsl_ir_node
return CONTAINING_RECORD(node, struct hlsl_ir_swizzle, node);
}
static inline void hlsl_block_add_instr(struct hlsl_block *block, struct hlsl_ir_node *instr)
{
list_add_tail(&block->instrs, &instr->entry);
}
static inline void hlsl_src_from_node(struct hlsl_src *src, struct hlsl_ir_node *node)
{
src->node = node;

View File

@ -425,7 +425,7 @@ static bool append_conditional_break(struct hlsl_ctx *ctx, struct list *cond_lis
if (!(jump = hlsl_new_jump(ctx, HLSL_IR_JUMP_BREAK, condition->loc)))
return false;
list_add_head(&iff->then_instrs.instrs, &jump->node.entry);
hlsl_block_add_instr(&iff->then_instrs, &jump->node);
return true;
}

View File

@ -41,11 +41,11 @@ static struct hlsl_ir_node *new_offset_from_path_index(struct hlsl_ctx *ctx, str
{
if (!(c = hlsl_new_uint_constant(ctx, 4, loc)))
return NULL;
list_add_tail(&block->instrs, &c->node.entry);
hlsl_block_add_instr(block, &c->node);
if (!(idx_offset = hlsl_new_binary_expr(ctx, HLSL_OP2_MUL, &c->node, idx)))
return NULL;
list_add_tail(&block->instrs, &idx_offset->entry);
hlsl_block_add_instr(block, idx_offset);
break;
}
@ -56,11 +56,11 @@ static struct hlsl_ir_node *new_offset_from_path_index(struct hlsl_ctx *ctx, str
if (!(c = hlsl_new_uint_constant(ctx, size, loc)))
return NULL;
list_add_tail(&block->instrs, &c->node.entry);
hlsl_block_add_instr(block, &c->node);
if (!(idx_offset = hlsl_new_binary_expr(ctx, HLSL_OP2_MUL, &c->node, idx)))
return NULL;
list_add_tail(&block->instrs, &idx_offset->entry);
hlsl_block_add_instr(block, idx_offset);
break;
}
@ -72,7 +72,7 @@ static struct hlsl_ir_node *new_offset_from_path_index(struct hlsl_ctx *ctx, str
if (!(c = hlsl_new_uint_constant(ctx, field->reg_offset[regset], loc)))
return NULL;
list_add_tail(&block->instrs, &c->node.entry);
hlsl_block_add_instr(block, &c->node);
idx_offset = &c->node;
@ -87,7 +87,7 @@ static struct hlsl_ir_node *new_offset_from_path_index(struct hlsl_ctx *ctx, str
{
if (!(idx_offset = hlsl_new_binary_expr(ctx, HLSL_OP2_ADD, offset, idx_offset)))
return NULL;
list_add_tail(&block->instrs, &idx_offset->entry);
hlsl_block_add_instr(block, idx_offset);
}
return idx_offset;
@ -530,7 +530,7 @@ static void insert_early_return_break(struct hlsl_ctx *ctx,
if (!(jump = hlsl_new_jump(ctx, HLSL_IR_JUMP_BREAK, cf_instr->loc)))
return;
list_add_tail(&iff->then_instrs.instrs, &jump->node.entry);
hlsl_block_add_instr(&iff->then_instrs, &jump->node);
}
/* Remove HLSL_IR_JUMP_RETURN calls by altering subsequent control flow. */
@ -687,15 +687,15 @@ static bool lower_return(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *fun
if (!(load = hlsl_new_var_load(ctx, func->early_return_var, cf_instr->loc)))
return false;
list_add_tail(&block->instrs, &load->node.entry);
hlsl_block_add_instr(block, &load->node);
if (!(not = hlsl_new_unary_expr(ctx, HLSL_OP1_LOGIC_NOT, &load->node, cf_instr->loc)))
return false;
list_add_tail(&block->instrs, &not->entry);
hlsl_block_add_instr(block, not);
if (!(iff = hlsl_new_if(ctx, not, cf_instr->loc)))
return false;
list_add_tail(&block->instrs, &iff->node.entry);
hlsl_block_add_instr(block, &iff->node);
list_move_slice_tail(&iff->then_instrs.instrs, list_next(&block->instrs, &cf_instr->entry), tail);
@ -1943,11 +1943,11 @@ struct hlsl_ir_load *hlsl_add_conditional(struct hlsl_ctx *ctx, struct list *ins
if (!(store = hlsl_new_simple_store(ctx, var, if_true)))
return NULL;
list_add_tail(&iff->then_instrs.instrs, &store->node.entry);
hlsl_block_add_instr(&iff->then_instrs, &store->node);
if (!(store = hlsl_new_simple_store(ctx, var, if_false)))
return NULL;
list_add_tail(&iff->else_instrs.instrs, &store->node.entry);
hlsl_block_add_instr(&iff->else_instrs, &store->node);
if (!(load = hlsl_new_var_load(ctx, var, condition->loc)))
return NULL;