Matteo Bruni : d3dcompiler: Parse relational operators, stub out more rules .

Alexandre Julliard julliard at winehq.org
Wed Jul 18 12:44:41 CDT 2012


Module: wine
Branch: master
Commit: 6c92d78c8c48bfd2ffb2ccdc863597dce1bb75a6
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=6c92d78c8c48bfd2ffb2ccdc863597dce1bb75a6

Author: Matteo Bruni <mbruni at codeweavers.com>
Date:   Wed Jul 18 16:25:15 2012 +0200

d3dcompiler: Parse relational operators, stub out more rules.

---

 dlls/d3dcompiler_43/d3dcompiler_private.h |   12 +++++
 dlls/d3dcompiler_43/hlsl.y                |   74 +++++++++++++++++++++++++++
 dlls/d3dcompiler_43/utils.c               |   78 +++++++++++++++++++++++++++++
 3 files changed, 164 insertions(+), 0 deletions(-)

diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h
index 32d9c9d..32d378a 100644
--- a/dlls/d3dcompiler_43/d3dcompiler_private.h
+++ b/dlls/d3dcompiler_43/d3dcompiler_private.h
@@ -984,6 +984,18 @@ struct hlsl_ir_expr *hlsl_add(struct hlsl_ir_node *op1, struct hlsl_ir_node *op2
         struct source_location *loc) DECLSPEC_HIDDEN;
 struct hlsl_ir_expr *hlsl_sub(struct hlsl_ir_node *op1, struct hlsl_ir_node *op2,
         struct source_location *loc) DECLSPEC_HIDDEN;
+struct hlsl_ir_expr *hlsl_lt(struct hlsl_ir_node *op1, struct hlsl_ir_node *op2,
+        struct source_location *loc) DECLSPEC_HIDDEN;
+struct hlsl_ir_expr *hlsl_gt(struct hlsl_ir_node *op1, struct hlsl_ir_node *op2,
+        struct source_location *loc) DECLSPEC_HIDDEN;
+struct hlsl_ir_expr *hlsl_le(struct hlsl_ir_node *op1, struct hlsl_ir_node *op2,
+        struct source_location *loc) DECLSPEC_HIDDEN;
+struct hlsl_ir_expr *hlsl_ge(struct hlsl_ir_node *op1, struct hlsl_ir_node *op2,
+        struct source_location *loc) DECLSPEC_HIDDEN;
+struct hlsl_ir_expr *hlsl_eq(struct hlsl_ir_node *op1, struct hlsl_ir_node *op2,
+        struct source_location *loc) DECLSPEC_HIDDEN;
+struct hlsl_ir_expr *hlsl_ne(struct hlsl_ir_node *op1, struct hlsl_ir_node *op2,
+        struct source_location *loc) DECLSPEC_HIDDEN;
 struct hlsl_ir_deref *new_var_deref(struct hlsl_ir_var *var) DECLSPEC_HIDDEN;
 void push_scope(struct hlsl_parse_ctx *ctx) DECLSPEC_HIDDEN;
 BOOL pop_scope(struct hlsl_parse_ctx *ctx) DECLSPEC_HIDDEN;
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y
index 799aa12..8dd2e70 100644
--- a/dlls/d3dcompiler_43/hlsl.y
+++ b/dlls/d3dcompiler_43/hlsl.y
@@ -1012,46 +1012,120 @@ shift_expr:               add_expr
                             {
                                 $$ = $1;
                             }
+                        | shift_expr OP_LEFTSHIFT add_expr
+                            {
+                                FIXME("Left shift\n");
+                            }
+                        | shift_expr OP_RIGHTSHIFT add_expr
+                            {
+                                FIXME("Right shift\n");
+                            }
 
 relational_expr:          shift_expr
                             {
                                 $$ = $1;
                             }
+                        | relational_expr '<' shift_expr
+                            {
+                                struct source_location loc;
+
+                                set_location(&loc, &@2);
+                                $$ = &hlsl_lt($1, $3, &loc)->node;
+                            }
+                        | relational_expr '>' shift_expr
+                            {
+                                struct source_location loc;
+
+                                set_location(&loc, &@2);
+                                $$ = &hlsl_gt($1, $3, &loc)->node;
+                            }
+                        | relational_expr OP_LE shift_expr
+                            {
+                                struct source_location loc;
+
+                                set_location(&loc, &@2);
+                                $$ = &hlsl_le($1, $3, &loc)->node;
+                            }
+                        | relational_expr OP_GE shift_expr
+                            {
+                                struct source_location loc;
+
+                                set_location(&loc, &@2);
+                                $$ = &hlsl_ge($1, $3, &loc)->node;
+                            }
 
 equality_expr:            relational_expr
                             {
                                 $$ = $1;
                             }
+                        | equality_expr OP_EQ relational_expr
+                            {
+                                struct source_location loc;
+
+                                set_location(&loc, &@2);
+                                $$ = &hlsl_eq($1, $3, &loc)->node;
+                            }
+                        | equality_expr OP_NE relational_expr
+                            {
+                                struct source_location loc;
+
+                                set_location(&loc, &@2);
+                                $$ = &hlsl_ne($1, $3, &loc)->node;
+                            }
 
 bitand_expr:              equality_expr
                             {
                                 $$ = $1;
                             }
+                        | bitand_expr '&' equality_expr
+                            {
+                                FIXME("bitwise AND\n");
+                            }
 
 bitxor_expr:              bitand_expr
                             {
                                 $$ = $1;
                             }
+                        | bitxor_expr '^' bitand_expr
+                            {
+                                FIXME("bitwise XOR\n");
+                            }
 
 bitor_expr:               bitxor_expr
                             {
                                 $$ = $1;
                             }
+                        | bitor_expr '|' bitxor_expr
+                            {
+                                FIXME("bitwise OR\n");
+                            }
 
 logicand_expr:            bitor_expr
                             {
                                 $$ = $1;
                             }
+                        | logicand_expr OP_AND bitor_expr
+                            {
+                                FIXME("logic AND\n");
+                            }
 
 logicor_expr:             logicand_expr
                             {
                                 $$ = $1;
                             }
+                        | logicor_expr OP_OR logicand_expr
+                            {
+                                FIXME("logic OR\n");
+                            }
 
 conditional_expr:         logicor_expr
                             {
                                 $$ = $1;
                             }
+                        | logicor_expr '?' expr ':' assignment_expr
+                            {
+                                FIXME("ternary operator\n");
+                            }
 
 assignment_expr:          conditional_expr
                             {
diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c
index f10d6a6..afb441c 100644
--- a/dlls/d3dcompiler_43/utils.c
+++ b/dlls/d3dcompiler_43/utils.c
@@ -1246,6 +1246,84 @@ struct hlsl_ir_expr *hlsl_sub(struct hlsl_ir_node *op1, struct hlsl_ir_node *op2
     return expr;
 }
 
+struct hlsl_ir_expr *hlsl_lt(struct hlsl_ir_node *op1, struct hlsl_ir_node *op2,
+        struct source_location *loc)
+{
+    struct hlsl_ir_expr *expr;
+    struct hlsl_ir_node *ops[3];
+
+    ops[0] = op1;
+    ops[1] = op2;
+    ops[2] = NULL;
+    expr = new_expr(HLSL_IR_BINOP_LESS, ops, loc);
+    return expr;
+}
+
+struct hlsl_ir_expr *hlsl_gt(struct hlsl_ir_node *op1, struct hlsl_ir_node *op2,
+        struct source_location *loc)
+{
+    struct hlsl_ir_expr *expr;
+    struct hlsl_ir_node *ops[3];
+
+    ops[0] = op1;
+    ops[1] = op2;
+    ops[2] = NULL;
+    expr = new_expr(HLSL_IR_BINOP_GREATER, ops, loc);
+    return expr;
+}
+
+struct hlsl_ir_expr *hlsl_le(struct hlsl_ir_node *op1, struct hlsl_ir_node *op2,
+        struct source_location *loc)
+{
+    struct hlsl_ir_expr *expr;
+    struct hlsl_ir_node *ops[3];
+
+    ops[0] = op1;
+    ops[1] = op2;
+    ops[2] = NULL;
+    expr = new_expr(HLSL_IR_BINOP_LEQUAL, ops, loc);
+    return expr;
+}
+
+struct hlsl_ir_expr *hlsl_ge(struct hlsl_ir_node *op1, struct hlsl_ir_node *op2,
+        struct source_location *loc)
+{
+    struct hlsl_ir_expr *expr;
+    struct hlsl_ir_node *ops[3];
+
+    ops[0] = op1;
+    ops[1] = op2;
+    ops[2] = NULL;
+    expr = new_expr(HLSL_IR_BINOP_GEQUAL, ops, loc);
+    return expr;
+}
+
+struct hlsl_ir_expr *hlsl_eq(struct hlsl_ir_node *op1, struct hlsl_ir_node *op2,
+        struct source_location *loc)
+{
+    struct hlsl_ir_expr *expr;
+    struct hlsl_ir_node *ops[3];
+
+    ops[0] = op1;
+    ops[1] = op2;
+    ops[2] = NULL;
+    expr = new_expr(HLSL_IR_BINOP_EQUAL, ops, loc);
+    return expr;
+}
+
+struct hlsl_ir_expr *hlsl_ne(struct hlsl_ir_node *op1, struct hlsl_ir_node *op2,
+        struct source_location *loc)
+{
+    struct hlsl_ir_expr *expr;
+    struct hlsl_ir_node *ops[3];
+
+    ops[0] = op1;
+    ops[1] = op2;
+    ops[2] = NULL;
+    expr = new_expr(HLSL_IR_BINOP_NEQUAL, ops, loc);
+    return expr;
+}
+
 struct hlsl_ir_deref *new_var_deref(struct hlsl_ir_var *var)
 {
     struct hlsl_ir_deref *deref = d3dcompiler_alloc(sizeof(*deref));




More information about the wine-cvs mailing list