From: Zebediah Figura zfigura@codeweavers.com
--- 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 494103d2..99ebc905 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -1142,7 +1142,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; @@ -1156,7 +1156,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) list_move_tail(&iff->else_block.instrs, &else_block->instrs); - return iff; + return &iff->node; }
struct hlsl_ir_load *hlsl_new_load_index(struct hlsl_ctx *ctx, const struct hlsl_deref *deref, @@ -1418,7 +1418,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; @@ -1435,7 +1435,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 24f9e1f2..21bda978 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -1052,7 +1052,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 91bbeae4..cad83239 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; }
@@ -5257,7 +5256,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); @@ -5274,12 +5273,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 0e252dac..93623802 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; @@ -1932,8 +1931,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));
@@ -1953,7 +1952,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;