Giovanni Mascellani : vkd3d-shader/hlsl: Parse left shift.

Alexandre Julliard julliard at winehq.org
Wed Mar 2 14:33:17 CST 2022


Module: vkd3d
Branch: master
Commit: 6fa13816579c58f35e99fb83f6761f47e6f3e4df
URL:    https://source.winehq.org/git/vkd3d.git/?a=commit;h=6fa13816579c58f35e99fb83f6761f47e6f3e4df

Author: Giovanni Mascellani <gmascellani at codeweavers.com>
Date:   Thu Feb 24 12:45:18 2022 -0600

vkd3d-shader/hlsl: Parse left shift.

Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Francisco Casas <fcasas 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.y | 45 ++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
index 4cdb471..7c7c89e 100644
--- a/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d-shader/hlsl.y
@@ -1171,6 +1171,49 @@ static struct list *add_binary_logical_expr_merge(struct hlsl_ctx *ctx, struct l
     return list1;
 }
 
+static struct hlsl_ir_expr *add_binary_shift_expr(struct hlsl_ctx *ctx, struct list *instrs,
+        enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg1, struct hlsl_ir_node *arg2,
+        const struct vkd3d_shader_location *loc)
+{
+    enum hlsl_base_type base = arg1->data_type->base_type;
+    struct hlsl_ir_node *args[HLSL_MAX_OPERANDS] = {0};
+    struct hlsl_type *return_type, *integer_type;
+    enum hlsl_type_class type;
+    unsigned int dimx, dimy;
+
+    check_integer_type(ctx, arg1);
+    check_integer_type(ctx, arg2);
+
+    if (base == HLSL_TYPE_BOOL)
+        base = HLSL_TYPE_INT;
+
+    if (!expr_common_shape(ctx, arg1->data_type, arg2->data_type, loc, &type, &dimx, &dimy))
+        return NULL;
+
+    return_type = hlsl_get_numeric_type(ctx, type, base, dimx, dimy);
+    integer_type = hlsl_get_numeric_type(ctx, type, HLSL_TYPE_INT, dimx, dimy);
+
+    if (!(args[0] = add_implicit_conversion(ctx, instrs, arg1, return_type, loc)))
+        return NULL;
+
+    if (!(args[1] = add_implicit_conversion(ctx, instrs, arg2, integer_type, loc)))
+        return NULL;
+
+    return add_expr(ctx, instrs, op, args, return_type, loc);
+}
+
+static struct list *add_binary_shift_expr_merge(struct hlsl_ctx *ctx, struct list *list1, struct list *list2,
+        enum hlsl_ir_expr_op op, const struct vkd3d_shader_location *loc)
+{
+    struct hlsl_ir_node *arg1 = node_from_list(list1), *arg2 = node_from_list(list2);
+
+    list_move_tail(list1, list2);
+    vkd3d_free(list2);
+    add_binary_shift_expr(ctx, list1, op, arg1, arg2, loc);
+
+    return list1;
+}
+
 static enum hlsl_ir_expr_op op_from_assignment(enum parse_assign_op op)
 {
     static const enum hlsl_ir_expr_op ops[] =
@@ -3637,7 +3680,7 @@ shift_expr:
       add_expr
     | shift_expr OP_LEFTSHIFT add_expr
         {
-            hlsl_fixme(ctx, &@$, "Left shift.");
+            $$ = add_binary_shift_expr_merge(ctx, $1, $3, HLSL_OP2_LSHIFT, &@2);
         }
     | shift_expr OP_RIGHTSHIFT add_expr
         {




More information about the wine-cvs mailing list