Zebediah Figura : vkd3d-shader: Factor out hlsl_new_jump().
Alexandre Julliard
julliard at winehq.org
Tue Mar 2 15:31:17 CST 2021
Module: vkd3d
Branch: master
Commit: ccd67dcf37ba6415240541c39a9a2bc2576f5529
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=ccd67dcf37ba6415240541c39a9a2bc2576f5529
Author: Zebediah Figura <zfigura at codeweavers.com>
Date: Sat Feb 27 18:03:13 2021 -0600
vkd3d-shader: Factor out hlsl_new_jump().
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet 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 | 8 ++------
3 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c
index 1d76777..1b388d5 100644
--- a/libs/vkd3d-shader/hlsl.c
+++ b/libs/vkd3d-shader/hlsl.c
@@ -499,6 +499,17 @@ struct hlsl_ir_swizzle *hlsl_new_swizzle(struct hlsl_ctx *ctx, DWORD s, unsigned
return swizzle;
}
+struct hlsl_ir_jump *hlsl_new_jump(enum hlsl_ir_jump_type type, struct vkd3d_shader_location loc)
+{
+ struct hlsl_ir_jump *jump;
+
+ if (!(jump = vkd3d_malloc(sizeof(*jump))))
+ return NULL;
+ init_node(&jump->node, HLSL_IR_JUMP, NULL, loc);
+ jump->type = type;
+ return jump;
+}
+
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 8107b26..c3b5d56 100644
--- a/libs/vkd3d-shader/hlsl.h
+++ b/libs/vkd3d-shader/hlsl.h
@@ -529,6 +529,7 @@ struct hlsl_ir_expr *hlsl_new_cast(struct hlsl_ir_node *node, struct hlsl_type *
struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx, struct hlsl_type *return_type,
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_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 5ad50b0..45b9742 100644
--- a/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d-shader/hlsl.y
@@ -377,10 +377,8 @@ static bool append_conditional_break(struct list *cond_list)
return false;
list_add_tail(cond_list, &iff->node.entry);
- if (!(jump = vkd3d_malloc(sizeof(*jump))))
+ if (!(jump = hlsl_new_jump(HLSL_IR_JUMP_BREAK, condition->loc)))
return false;
- init_node(&jump->node, HLSL_IR_JUMP, NULL, condition->loc);
- jump->type = HLSL_IR_JUMP_BREAK;
list_add_head(&iff->then_instrs, &jump->node.entry);
return true;
}
@@ -563,10 +561,8 @@ static struct hlsl_ir_jump *add_return(struct hlsl_ctx *ctx, struct list *instrs
return NULL;
}
- if (!(jump = vkd3d_malloc(sizeof(*jump))))
+ if (!(jump = hlsl_new_jump(HLSL_IR_JUMP_RETURN, loc)))
return NULL;
- init_node(&jump->node, HLSL_IR_JUMP, NULL, loc);
- jump->type = HLSL_IR_JUMP_RETURN;
list_add_tail(instrs, &jump->node.entry);
return jump;
More information about the wine-cvs
mailing list