vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_bool_constant().

This commit is contained in:
Zebediah Figura 2022-11-10 19:37:41 -06:00 committed by Alexandre Julliard
parent 0654d88edd
commit 1bf3aa9275
Notes: Alexandre Julliard 2023-04-18 22:35:06 +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/153
4 changed files with 13 additions and 13 deletions

View File

@ -1128,14 +1128,14 @@ struct hlsl_ir_constant *hlsl_new_constant(struct hlsl_ctx *ctx, struct hlsl_typ
return c;
}
struct hlsl_ir_constant *hlsl_new_bool_constant(struct hlsl_ctx *ctx, bool b, const struct vkd3d_shader_location *loc)
struct hlsl_ir_node *hlsl_new_bool_constant(struct hlsl_ctx *ctx, bool b, const struct vkd3d_shader_location *loc)
{
struct hlsl_ir_constant *c;
if ((c = hlsl_new_constant(ctx, hlsl_get_scalar_type(ctx, HLSL_TYPE_BOOL), loc)))
c->value[0].u = b ? ~0u : 0;
return c;
return &c->node;
}
struct hlsl_ir_constant *hlsl_new_float_constant(struct hlsl_ctx *ctx, float f,
@ -1711,7 +1711,7 @@ struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx,
const struct hlsl_semantic *semantic, const struct vkd3d_shader_location *loc)
{
struct hlsl_ir_function_decl *decl;
struct hlsl_ir_constant *constant;
struct hlsl_ir_node *constant;
struct hlsl_ir_store *store;
if (!(decl = hlsl_alloc(ctx, sizeof(*decl))))
@ -1737,9 +1737,9 @@ struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx,
if (!(constant = hlsl_new_bool_constant(ctx, false, loc)))
return decl;
hlsl_block_add_instr(&decl->body, &constant->node);
hlsl_block_add_instr(&decl->body, constant);
if (!(store = hlsl_new_simple_store(ctx, decl->early_return_var, &constant->node)))
if (!(store = hlsl_new_simple_store(ctx, decl->early_return_var, constant)))
return decl;
hlsl_block_add_instr(&decl->body, &store->node);

View File

@ -1048,7 +1048,7 @@ const char *hlsl_jump_type_to_string(enum hlsl_ir_jump_type type);
struct hlsl_type *hlsl_new_array_type(struct hlsl_ctx *ctx, struct hlsl_type *basic_type, unsigned int array_size);
struct hlsl_ir_node *hlsl_new_binary_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg1,
struct hlsl_ir_node *arg2);
struct hlsl_ir_constant *hlsl_new_bool_constant(struct hlsl_ctx *ctx, bool b, const struct vkd3d_shader_location *loc);
struct hlsl_ir_node *hlsl_new_bool_constant(struct hlsl_ctx *ctx, bool b, const struct vkd3d_shader_location *loc);
struct hlsl_buffer *hlsl_new_buffer(struct hlsl_ctx *ctx, enum hlsl_buffer_type type, const char *name,
const struct hlsl_reg_reservation *reservation, struct vkd3d_shader_location loc);
struct hlsl_ir_node *hlsl_new_call(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *decl,

View File

@ -5350,13 +5350,13 @@ primary_expr:
}
| boolean
{
struct hlsl_ir_constant *c;
struct hlsl_ir_node *c;
if (!(c = hlsl_new_bool_constant(ctx, $1, &@1)))
YYABORT;
if (!($$ = make_list(ctx, &c->node)))
if (!($$ = make_list(ctx, c)))
{
hlsl_free_instr(&c->node);
hlsl_free_instr(c);
YYABORT;
}
}

View File

@ -628,18 +628,18 @@ static bool lower_return(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *fun
else if (instr->type == HLSL_IR_JUMP)
{
struct hlsl_ir_jump *jump = hlsl_ir_jump(instr);
struct hlsl_ir_constant *constant;
struct hlsl_ir_node *constant;
struct hlsl_ir_store *store;
if (jump->type == HLSL_IR_JUMP_RETURN)
{
if (!(constant = hlsl_new_bool_constant(ctx, true, &jump->node.loc)))
return false;
list_add_before(&jump->node.entry, &constant->node.entry);
list_add_before(&jump->node.entry, &constant->entry);
if (!(store = hlsl_new_simple_store(ctx, func->early_return_var, &constant->node)))
if (!(store = hlsl_new_simple_store(ctx, func->early_return_var, constant)))
return false;
list_add_after(&constant->node.entry, &store->node.entry);
list_add_after(&constant->entry, &store->node.entry);
has_early_return = true;
if (in_loop)