[PATCH 4/5] d3dcompiler: Parse multiplicative expressions.
Matteo Bruni
mbruni at codeweavers.com
Wed Jul 18 09:25:14 CDT 2012
---
dlls/d3dcompiler_43/d3dcompiler_private.h | 6 ++++
dlls/d3dcompiler_43/hlsl.y | 21 +++++++++++++++
dlls/d3dcompiler_43/utils.c | 39 +++++++++++++++++++++++++++++
3 files changed, 66 insertions(+), 0 deletions(-)
diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h
index 515bb3b..32d9c9d 100644
--- a/dlls/d3dcompiler_43/d3dcompiler_private.h
+++ b/dlls/d3dcompiler_43/d3dcompiler_private.h
@@ -974,6 +974,12 @@ BOOL find_function(const char *name) DECLSPEC_HIDDEN;
unsigned int components_count_type(struct hlsl_type *type) DECLSPEC_HIDDEN;
struct hlsl_ir_expr *new_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node **operands,
struct source_location *loc) DECLSPEC_HIDDEN;
+struct hlsl_ir_expr *hlsl_mul(struct hlsl_ir_node *op1, struct hlsl_ir_node *op2,
+ struct source_location *loc) DECLSPEC_HIDDEN;
+struct hlsl_ir_expr *hlsl_div(struct hlsl_ir_node *op1, struct hlsl_ir_node *op2,
+ struct source_location *loc) DECLSPEC_HIDDEN;
+struct hlsl_ir_expr *hlsl_mod(struct hlsl_ir_node *op1, struct hlsl_ir_node *op2,
+ struct source_location *loc) DECLSPEC_HIDDEN;
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,
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y
index 836dffd..799aa12 100644
--- a/dlls/d3dcompiler_43/hlsl.y
+++ b/dlls/d3dcompiler_43/hlsl.y
@@ -967,6 +967,27 @@ mul_expr: unary_expr
{
$$ = $1;
}
+ | mul_expr '*' unary_expr
+ {
+ struct source_location loc;
+
+ set_location(&loc, &@2);
+ $$ = &hlsl_mul($1, $3, &loc)->node;
+ }
+ | mul_expr '/' unary_expr
+ {
+ struct source_location loc;
+
+ set_location(&loc, &@2);
+ $$ = &hlsl_div($1, $3, &loc)->node;
+ }
+ | mul_expr '%' unary_expr
+ {
+ struct source_location loc;
+
+ set_location(&loc, &@2);
+ $$ = &hlsl_mod($1, $3, &loc)->node;
+ }
add_expr: mul_expr
{
diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c
index 4c24e0a..f10d6a6 100644
--- a/dlls/d3dcompiler_43/utils.c
+++ b/dlls/d3dcompiler_43/utils.c
@@ -1181,6 +1181,45 @@ struct hlsl_ir_expr *new_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node **ope
return expr;
}
+struct hlsl_ir_expr *hlsl_mul(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_MUL, ops, loc);
+ return expr;
+}
+
+struct hlsl_ir_expr *hlsl_div(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_DIV, ops, loc);
+ return expr;
+}
+
+struct hlsl_ir_expr *hlsl_mod(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_MOD, ops, loc);
+ return expr;
+}
+
struct hlsl_ir_expr *hlsl_add(struct hlsl_ir_node *op1, struct hlsl_ir_node *op2,
struct source_location *loc)
{
--
1.7.8.6
More information about the wine-patches
mailing list