mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_jump().
This commit is contained in:
parent
dfe056596a
commit
e5ec431784
Notes:
Alexandre Julliard
2023-04-20 22:58:03 +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/169
@ -1384,7 +1384,7 @@ struct hlsl_ir_node *hlsl_new_index(struct hlsl_ctx *ctx, struct hlsl_ir_node *v
|
||||
return &index->node;
|
||||
}
|
||||
|
||||
struct hlsl_ir_jump *hlsl_new_jump(struct hlsl_ctx *ctx, enum hlsl_ir_jump_type type,
|
||||
struct hlsl_ir_node *hlsl_new_jump(struct hlsl_ctx *ctx, enum hlsl_ir_jump_type type,
|
||||
const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
struct hlsl_ir_jump *jump;
|
||||
@ -1393,7 +1393,7 @@ struct hlsl_ir_jump *hlsl_new_jump(struct hlsl_ctx *ctx, enum hlsl_ir_jump_type
|
||||
return NULL;
|
||||
init_node(&jump->node, HLSL_IR_JUMP, NULL, loc);
|
||||
jump->type = type;
|
||||
return jump;
|
||||
return &jump->node;
|
||||
}
|
||||
|
||||
struct hlsl_ir_loop *hlsl_new_loop(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc)
|
||||
@ -1543,11 +1543,7 @@ static struct hlsl_ir_node *clone_if(struct hlsl_ctx *ctx, struct clone_instr_ma
|
||||
|
||||
static struct hlsl_ir_node *clone_jump(struct hlsl_ctx *ctx, struct hlsl_ir_jump *src)
|
||||
{
|
||||
struct hlsl_ir_jump *dst;
|
||||
|
||||
if (!(dst = hlsl_new_jump(ctx, src->type, &src->node.loc)))
|
||||
return NULL;
|
||||
return &dst->node;
|
||||
return hlsl_new_jump(ctx, src->type, &src->node.loc);
|
||||
}
|
||||
|
||||
static struct hlsl_ir_node *clone_load(struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_load *src)
|
||||
|
@ -1070,8 +1070,8 @@ struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx,
|
||||
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_node *hlsl_new_int_constant(struct hlsl_ctx *ctx, int32_t n, const struct vkd3d_shader_location *loc);
|
||||
struct hlsl_ir_jump *hlsl_new_jump(struct hlsl_ctx *ctx, enum hlsl_ir_jump_type type,
|
||||
const struct vkd3d_shader_location *loc);
|
||||
struct hlsl_ir_node *hlsl_new_jump(struct hlsl_ctx *ctx,
|
||||
enum hlsl_ir_jump_type type, const struct vkd3d_shader_location *loc);
|
||||
|
||||
void hlsl_init_simple_deref_from_var(struct hlsl_deref *deref, struct hlsl_ir_var *var);
|
||||
|
||||
|
@ -407,9 +407,8 @@ static DWORD add_modifiers(struct hlsl_ctx *ctx, DWORD modifiers, DWORD mod,
|
||||
|
||||
static bool append_conditional_break(struct hlsl_ctx *ctx, struct list *cond_list)
|
||||
{
|
||||
struct hlsl_ir_node *condition, *not, *iff;
|
||||
struct hlsl_ir_node *condition, *not, *iff, *jump;
|
||||
struct hlsl_block then_block;
|
||||
struct hlsl_ir_jump *jump;
|
||||
|
||||
/* E.g. "for (i = 0; ; ++i)". */
|
||||
if (list_empty(cond_list))
|
||||
@ -424,7 +423,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;
|
||||
hlsl_block_add_instr(&then_block, &jump->node);
|
||||
hlsl_block_add_instr(&then_block, jump);
|
||||
|
||||
if (!(iff = hlsl_new_if(ctx, not, &then_block, NULL, &condition->loc)))
|
||||
return false;
|
||||
@ -585,11 +584,11 @@ static struct hlsl_ir_swizzle *get_swizzle(struct hlsl_ctx *ctx, struct hlsl_ir_
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct hlsl_ir_jump *add_return(struct hlsl_ctx *ctx, struct list *instrs,
|
||||
static bool add_return(struct hlsl_ctx *ctx, struct list *instrs,
|
||||
struct hlsl_ir_node *return_value, const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
struct hlsl_type *return_type = ctx->cur_function->return_type;
|
||||
struct hlsl_ir_jump *jump;
|
||||
struct hlsl_ir_node *jump;
|
||||
|
||||
if (ctx->cur_function->return_var)
|
||||
{
|
||||
@ -598,16 +597,16 @@ static struct hlsl_ir_jump *add_return(struct hlsl_ctx *ctx, struct list *instrs
|
||||
struct hlsl_ir_store *store;
|
||||
|
||||
if (!(return_value = add_implicit_conversion(ctx, instrs, return_value, return_type, loc)))
|
||||
return NULL;
|
||||
return false;
|
||||
|
||||
if (!(store = hlsl_new_simple_store(ctx, ctx->cur_function->return_var, return_value)))
|
||||
return NULL;
|
||||
return false;
|
||||
list_add_after(&return_value->entry, &store->node.entry);
|
||||
}
|
||||
else
|
||||
{
|
||||
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RETURN, "Non-void functions must return a value.");
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -617,10 +616,10 @@ static struct hlsl_ir_jump *add_return(struct hlsl_ctx *ctx, struct list *instrs
|
||||
}
|
||||
|
||||
if (!(jump = hlsl_new_jump(ctx, HLSL_IR_JUMP_RETURN, loc)))
|
||||
return NULL;
|
||||
list_add_tail(instrs, &jump->node.entry);
|
||||
return false;
|
||||
list_add_tail(instrs, &jump->entry);
|
||||
|
||||
return jump;
|
||||
return true;
|
||||
}
|
||||
|
||||
static struct hlsl_ir_load *add_load_component(struct hlsl_ctx *ctx, struct list *instrs, struct hlsl_ir_node *var_instr,
|
||||
|
@ -516,10 +516,9 @@ static bool find_recursive_calls(struct hlsl_ctx *ctx, struct hlsl_ir_node *inst
|
||||
static void insert_early_return_break(struct hlsl_ctx *ctx,
|
||||
struct hlsl_ir_function_decl *func, struct hlsl_ir_node *cf_instr)
|
||||
{
|
||||
struct hlsl_ir_node *iff, *jump;
|
||||
struct hlsl_block then_block;
|
||||
struct hlsl_ir_jump *jump;
|
||||
struct hlsl_ir_load *load;
|
||||
struct hlsl_ir_node *iff;
|
||||
|
||||
hlsl_block_init(&then_block);
|
||||
|
||||
@ -529,7 +528,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;
|
||||
hlsl_block_add_instr(&then_block, &jump->node);
|
||||
hlsl_block_add_instr(&then_block, jump);
|
||||
|
||||
if (!(iff = hlsl_new_if(ctx, &load->node, &then_block, NULL, &cf_instr->loc)))
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user