From: Zebediah Figura zfigura@codeweavers.com
--- libs/vkd3d-shader/hlsl.c | 10 +++++----- libs/vkd3d-shader/hlsl.h | 5 +++++ libs/vkd3d-shader/hlsl.y | 2 +- libs/vkd3d-shader/hlsl_codegen.c | 24 ++++++++++++------------ 4 files changed, 23 insertions(+), 18 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 6d015c20..c2ee2c81 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -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; } diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index c8e267d2..22425d38 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -850,6 +850,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; diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index afcc4575..d4c1e9fe 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -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; }
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 6c529f19..7dc2dea2 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -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, ¬->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;