Zebediah Figura : vkd3d-shader: Factor out hlsl_new_loop().
Alexandre Julliard
julliard at winehq.org
Tue Mar 2 15:31:17 CST 2021
Module: vkd3d
Branch: master
Commit: 0f4d62b09d424f9233ec58c6e2fd078611fcaa30
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=0f4d62b09d424f9233ec58c6e2fd078611fcaa30
Author: Zebediah Figura <zfigura at codeweavers.com>
Date: Sat Feb 27 18:03:14 2021 -0600
vkd3d-shader: Factor out hlsl_new_loop().
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
libs/vkd3d-shader/hlsl.c | 11 +++++++++++
libs/vkd3d-shader/hlsl.h | 1 +
libs/vkd3d-shader/hlsl.y | 4 +---
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c
index 1b388d5..4e73060 100644
--- a/libs/vkd3d-shader/hlsl.c
+++ b/libs/vkd3d-shader/hlsl.c
@@ -510,6 +510,17 @@ struct hlsl_ir_jump *hlsl_new_jump(enum hlsl_ir_jump_type type, struct vkd3d_sha
return jump;
}
+struct hlsl_ir_loop *hlsl_new_loop(struct vkd3d_shader_location loc)
+{
+ struct hlsl_ir_loop *loop;
+
+ if (!(loop = vkd3d_calloc(1, sizeof(*loop))))
+ return NULL;
+ init_node(&loop->node, HLSL_IR_LOOP, NULL, loc);
+ list_init(&loop->body);
+ return loop;
+}
+
bool hlsl_type_is_void(const struct hlsl_type *type)
{
return type->type == HLSL_CLASS_OBJECT && type->base_type == HLSL_TYPE_VOID;
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h
index c3b5d56..36e7dd0 100644
--- a/libs/vkd3d-shader/hlsl.h
+++ b/libs/vkd3d-shader/hlsl.h
@@ -530,6 +530,7 @@ struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx, struct hl
struct list *parameters, const char *semantic, struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
struct hlsl_ir_if *hlsl_new_if(struct hlsl_ir_node *condition, struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
struct hlsl_ir_jump *hlsl_new_jump(enum hlsl_ir_jump_type type, struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
+struct hlsl_ir_loop *hlsl_new_loop(struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
struct hlsl_ir_assignment *hlsl_new_simple_assignment(struct hlsl_ir_var *lhs,
struct hlsl_ir_node *rhs) DECLSPEC_HIDDEN;
struct hlsl_type *hlsl_new_struct_type(struct hlsl_ctx *ctx, const char *name, struct list *fields) DECLSPEC_HIDDEN;
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
index 45b9742..1341de1 100644
--- a/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d-shader/hlsl.y
@@ -403,11 +403,9 @@ static struct list *create_loop(enum loop_type type, struct list *init, struct l
if (init)
list_move_head(list, init);
- if (!(loop = vkd3d_calloc(1, sizeof(*loop))))
+ if (!(loop = hlsl_new_loop(loc)))
goto oom;
- init_node(&loop->node, HLSL_IR_LOOP, NULL, loc);
list_add_tail(list, &loop->node.entry);
- list_init(&loop->body);
if (!append_conditional_break(cond))
goto oom;
More information about the wine-cvs
mailing list