d3dcompiler: Create the expression in append_binop().

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2020-06-22 17:47:18 -05:00 committed by Alexandre Julliard
parent 13b2587d4f
commit 6083b1dd39
1 changed files with 63 additions and 76 deletions

View File

@ -1193,12 +1193,14 @@ static struct list *append_unop(struct list *list, struct hlsl_ir_node *node)
return list; return list;
} }
static struct list *append_binop(struct list *first, struct list *second, struct hlsl_ir_node *node) static struct list *add_binary_expr(struct list *list1, struct list *list2,
enum hlsl_ir_expr_op op, struct source_location loc)
{ {
list_move_tail(first, second); struct hlsl_ir_node *arg1 = node_from_list(list1), *arg2 = node_from_list(list2);
d3dcompiler_free(second); list_move_tail(list1, list2);
list_add_tail(first, &node->entry); d3dcompiler_free(list2);
return first; list_add_tail(list1, &new_binary_expr(op, arg1, arg2, loc)->entry);
return list1;
} }
static struct list *make_list(struct hlsl_ir_node *node) static struct list *make_list(struct hlsl_ir_node *node)
@ -2578,39 +2580,32 @@ unary_op: '+'
$$ = UNARY_OP_BITNOT; $$ = UNARY_OP_BITNOT;
} }
mul_expr: unary_expr mul_expr:
{
$$ = $1; unary_expr
}
| mul_expr '*' unary_expr | mul_expr '*' unary_expr
{ {
$$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_MUL, $$ = add_binary_expr($1, $3, HLSL_IR_BINOP_MUL, get_location(&@2));
node_from_list($1), node_from_list($3), get_location(&@2)));
} }
| mul_expr '/' unary_expr | mul_expr '/' unary_expr
{ {
$$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_DIV, $$ = add_binary_expr($1, $3, HLSL_IR_BINOP_DIV, get_location(&@2));
node_from_list($1), node_from_list($3), get_location(&@2)));
} }
| mul_expr '%' unary_expr | mul_expr '%' unary_expr
{ {
$$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_MOD, $$ = add_binary_expr($1, $3, HLSL_IR_BINOP_MOD, get_location(&@2));
node_from_list($1), node_from_list($3), get_location(&@2)));
} }
add_expr: mul_expr add_expr:
{
$$ = $1; mul_expr
}
| add_expr '+' mul_expr | add_expr '+' mul_expr
{ {
$$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_ADD, $$ = add_binary_expr($1, $3, HLSL_IR_BINOP_ADD, get_location(&@2));
node_from_list($1), node_from_list($3), get_location(&@2)));
} }
| add_expr '-' mul_expr | add_expr '-' mul_expr
{ {
$$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_SUB, $$ = add_binary_expr($1, $3, HLSL_IR_BINOP_SUB, get_location(&@2));
node_from_list($1), node_from_list($3), get_location(&@2)));
} }
shift_expr: add_expr shift_expr: add_expr
@ -2626,44 +2621,36 @@ shift_expr: add_expr
FIXME("Right shift\n"); FIXME("Right shift\n");
} }
relational_expr: shift_expr relational_expr:
{
$$ = $1; shift_expr
}
| relational_expr '<' shift_expr | relational_expr '<' shift_expr
{ {
$$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_LESS, $$ = add_binary_expr($1, $3, HLSL_IR_BINOP_LESS, get_location(&@2));
node_from_list($1), node_from_list($3), get_location(&@2)));
} }
| relational_expr '>' shift_expr | relational_expr '>' shift_expr
{ {
$$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_GREATER, $$ = add_binary_expr($1, $3, HLSL_IR_BINOP_GREATER, get_location(&@2));
node_from_list($1), node_from_list($3), get_location(&@2)));
} }
| relational_expr OP_LE shift_expr | relational_expr OP_LE shift_expr
{ {
$$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_LEQUAL, $$ = add_binary_expr($1, $3, HLSL_IR_BINOP_LEQUAL, get_location(&@2));
node_from_list($1), node_from_list($3), get_location(&@2)));
} }
| relational_expr OP_GE shift_expr | relational_expr OP_GE shift_expr
{ {
$$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_GEQUAL, $$ = add_binary_expr($1, $3, HLSL_IR_BINOP_GEQUAL, get_location(&@2));
node_from_list($1), node_from_list($3), get_location(&@2)));
} }
equality_expr: relational_expr equality_expr:
{
$$ = $1; relational_expr
}
| equality_expr OP_EQ relational_expr | equality_expr OP_EQ relational_expr
{ {
$$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_EQUAL, $$ = add_binary_expr($1, $3, HLSL_IR_BINOP_EQUAL, get_location(&@2));
node_from_list($1), node_from_list($3), get_location(&@2)));
} }
| equality_expr OP_NE relational_expr | equality_expr OP_NE relational_expr
{ {
$$ = append_binop($1, $3, new_binary_expr(HLSL_IR_BINOP_NEQUAL, $$ = add_binary_expr($1, $3, HLSL_IR_BINOP_NEQUAL, get_location(&@2));
node_from_list($1), node_from_list($3), get_location(&@2)));
} }
bitand_expr: equality_expr bitand_expr: equality_expr