Module: vkd3d Branch: master Commit: 7ee66351c8e4cdf52f6c5e803d7584d270cb68e7 URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/7ee66351c8e4cdf52f6c5e803d7584...
Author: Zebediah Figura zfigura@codeweavers.com Date: Thu Nov 10 20:05:53 2022 -0600
vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_if().
---
libs/vkd3d-shader/hlsl.c | 8 ++++---- libs/vkd3d-shader/hlsl.h | 2 +- libs/vkd3d-shader/hlsl.y | 11 +++++------ libs/vkd3d-shader/hlsl_codegen.c | 13 ++++++------- 4 files changed, 16 insertions(+), 18 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 9eccdd0e..5f683767 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -1208,7 +1208,7 @@ struct hlsl_ir_node *hlsl_new_binary_expr(struct hlsl_ctx *ctx, enum hlsl_ir_exp return hlsl_new_expr(ctx, op, operands, arg1->data_type, &arg1->loc); }
-struct hlsl_ir_if *hlsl_new_if(struct hlsl_ctx *ctx, struct hlsl_ir_node *condition, +struct hlsl_ir_node *hlsl_new_if(struct hlsl_ctx *ctx, struct hlsl_ir_node *condition, struct hlsl_block *then_block, struct hlsl_block *else_block, const struct vkd3d_shader_location *loc) { struct hlsl_ir_if *iff; @@ -1222,7 +1222,7 @@ struct hlsl_ir_if *hlsl_new_if(struct hlsl_ctx *ctx, struct hlsl_ir_node *condit hlsl_block_init(&iff->else_block); if (else_block) hlsl_block_add_block(&iff->else_block, else_block); - return iff; + return &iff->node; }
struct hlsl_ir_load *hlsl_new_load_index(struct hlsl_ctx *ctx, const struct hlsl_deref *deref, @@ -1521,7 +1521,7 @@ static struct hlsl_ir_node *clone_expr(struct hlsl_ctx *ctx, struct clone_instr_ static struct hlsl_ir_node *clone_if(struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_if *src) { struct hlsl_block then_block, else_block; - struct hlsl_ir_if *dst; + struct hlsl_ir_node *dst;
if (!clone_block(ctx, &then_block, &src->then_block, map)) return NULL; @@ -1538,7 +1538,7 @@ static struct hlsl_ir_node *clone_if(struct hlsl_ctx *ctx, struct clone_instr_ma return NULL; }
- return &dst->node; + return dst; }
static struct hlsl_ir_node *clone_jump(struct hlsl_ctx *ctx, struct hlsl_ir_jump *src) diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 16dcdb29..7a13c46f 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -1067,7 +1067,7 @@ struct hlsl_ir_node *hlsl_new_float_constant(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx, struct hlsl_type *return_type, const struct hlsl_func_parameters *parameters, const struct hlsl_semantic *semantic, const struct vkd3d_shader_location *loc); -struct hlsl_ir_if *hlsl_new_if(struct hlsl_ctx *ctx, struct hlsl_ir_node *condition, +struct hlsl_ir_node *hlsl_new_if(struct hlsl_ctx *ctx, struct hlsl_ir_node *condition, struct hlsl_block *then_block, struct hlsl_block *else_block, const struct vkd3d_shader_location *loc); struct hlsl_ir_constant *hlsl_new_int_constant(struct hlsl_ctx *ctx, int n, const struct vkd3d_shader_location *loc); diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 4e7a4baa..45bc545f 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -406,10 +406,9 @@ static DWORD add_modifiers(struct hlsl_ctx *ctx, DWORD modifiers, DWORD mod, con
static bool append_conditional_break(struct hlsl_ctx *ctx, struct list *cond_list) { - struct hlsl_ir_node *condition, *not; + struct hlsl_ir_node *condition, *not, *iff; struct hlsl_block then_block; struct hlsl_ir_jump *jump; - struct hlsl_ir_if *iff;
/* E.g. "for (i = 0; ; ++i)". */ if (list_empty(cond_list)) @@ -428,7 +427,7 @@ static bool append_conditional_break(struct hlsl_ctx *ctx, struct list *cond_lis
if (!(iff = hlsl_new_if(ctx, not, &then_block, NULL, &condition->loc))) return false; - list_add_tail(cond_list, &iff->node.entry); + list_add_tail(cond_list, &iff->entry); return true; }
@@ -5245,7 +5244,7 @@ selection_statement: { struct hlsl_ir_node *condition = node_from_list($3); struct hlsl_block then_block, else_block; - struct hlsl_ir_if *instr; + struct hlsl_ir_node *instr;
hlsl_block_init(&then_block); list_move_tail(&then_block.instrs, $5.then_block); @@ -5262,12 +5261,12 @@ selection_statement: struct vkd3d_string_buffer *string;
if ((string = hlsl_type_to_string(ctx, condition->data_type))) - hlsl_error(ctx, &instr->node.loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, + hlsl_error(ctx, &instr->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "if condition type %s is not scalar.", string->buffer); hlsl_release_string_buffer(ctx, string); } $$ = $3; - list_add_tail($$, &instr->node.entry); + list_add_tail($$, &instr->entry); }
if_body: diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index e20abf83..d63bccdf 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -519,7 +519,7 @@ static void insert_early_return_break(struct hlsl_ctx *ctx, struct hlsl_block then_block; struct hlsl_ir_jump *jump; struct hlsl_ir_load *load; - struct hlsl_ir_if *iff; + struct hlsl_ir_node *iff;
hlsl_block_init(&then_block);
@@ -533,7 +533,7 @@ static void insert_early_return_break(struct hlsl_ctx *ctx,
if (!(iff = hlsl_new_if(ctx, &load->node, &then_block, NULL, &cf_instr->loc))) return; - list_add_after(&load->node.entry, &iff->node.entry); + list_add_after(&load->node.entry, &iff->entry); }
/* Remove HLSL_IR_JUMP_RETURN calls by altering subsequent control flow. */ @@ -678,10 +678,9 @@ static bool lower_return(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *fun else if (cf_instr) { struct list *tail = list_tail(&block->instrs); + struct hlsl_ir_node *not, *iff; struct hlsl_block then_block; struct hlsl_ir_load *load; - struct hlsl_ir_node *not; - struct hlsl_ir_if *iff;
/* If we're in a loop, we should have used "break" instead. */ assert(!in_loop); @@ -703,7 +702,7 @@ static bool lower_return(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *fun
if (!(iff = hlsl_new_if(ctx, not, &then_block, NULL, &cf_instr->loc))) return false; - list_add_tail(&block->instrs, &iff->node.entry); + list_add_tail(&block->instrs, &iff->entry); }
return has_early_return; @@ -2006,8 +2005,8 @@ struct hlsl_ir_load *hlsl_add_conditional(struct hlsl_ctx *ctx, struct list *ins struct hlsl_block then_block, else_block; struct hlsl_ir_store *store; struct hlsl_ir_load *load; + struct hlsl_ir_node *iff; struct hlsl_ir_var *var; - struct hlsl_ir_if *iff;
assert(hlsl_types_are_equal(if_true->data_type, if_false->data_type));
@@ -2027,7 +2026,7 @@ struct hlsl_ir_load *hlsl_add_conditional(struct hlsl_ctx *ctx, struct list *ins
if (!(iff = hlsl_new_if(ctx, condition, &then_block, &else_block, &condition->loc))) return NULL; - list_add_tail(instrs, &iff->node.entry); + list_add_tail(instrs, &iff->entry);
if (!(load = hlsl_new_var_load(ctx, var, condition->loc))) return NULL;