d3dcompiler: Introduce a new_binary_expr() helper.
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:
parent
b899965615
commit
cf5ccf29a9
|
@ -1142,28 +1142,6 @@ struct hlsl_ir_expr *new_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node **ope
|
|||
struct source_location *loc) DECLSPEC_HIDDEN;
|
||||
struct hlsl_ir_expr *new_cast(struct hlsl_ir_node *node, struct hlsl_type *type,
|
||||
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,
|
||||
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;
|
||||
struct hlsl_ir_deref *new_record_deref(struct hlsl_ir_node *record, struct hlsl_struct_field *field) DECLSPEC_HIDDEN;
|
||||
struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *left, enum parse_assign_op assign_op,
|
||||
|
@ -1193,6 +1171,13 @@ static inline struct hlsl_ir_node *new_unary_expr(enum hlsl_ir_expr_op op,
|
|||
return &new_expr(op, operands, &loc)->node;
|
||||
}
|
||||
|
||||
static inline struct hlsl_ir_node *new_binary_expr(enum hlsl_ir_expr_op op,
|
||||
struct hlsl_ir_node *op1, struct hlsl_ir_node *op2, struct source_location loc)
|
||||
{
|
||||
struct hlsl_ir_node *operands[3] = {op1, op2};
|
||||
return &new_expr(op, operands, &loc)->node;
|
||||
}
|
||||
|
||||
#define MAKE_TAG(ch0, ch1, ch2, ch3) \
|
||||
((DWORD)(ch0) | ((DWORD)(ch1) << 8) | \
|
||||
((DWORD)(ch2) << 16) | ((DWORD)(ch3) << 24 ))
|
||||
|
|
|
@ -2214,21 +2214,21 @@ mul_expr: unary_expr
|
|||
struct source_location loc;
|
||||
|
||||
set_location(&loc, &@2);
|
||||
$$ = &hlsl_mul($1, $3, &loc)->node;
|
||||
$$ = new_binary_expr(HLSL_IR_BINOP_MUL, $1, $3, loc);
|
||||
}
|
||||
| mul_expr '/' unary_expr
|
||||
{
|
||||
struct source_location loc;
|
||||
|
||||
set_location(&loc, &@2);
|
||||
$$ = &hlsl_div($1, $3, &loc)->node;
|
||||
$$ = new_binary_expr(HLSL_IR_BINOP_DIV, $1, $3, loc);
|
||||
}
|
||||
| mul_expr '%' unary_expr
|
||||
{
|
||||
struct source_location loc;
|
||||
|
||||
set_location(&loc, &@2);
|
||||
$$ = &hlsl_mod($1, $3, &loc)->node;
|
||||
$$ = new_binary_expr(HLSL_IR_BINOP_MOD, $1, $3, loc);
|
||||
}
|
||||
|
||||
add_expr: mul_expr
|
||||
|
@ -2240,14 +2240,14 @@ add_expr: mul_expr
|
|||
struct source_location loc;
|
||||
|
||||
set_location(&loc, &@2);
|
||||
$$ = &hlsl_add($1, $3, &loc)->node;
|
||||
$$ = new_binary_expr(HLSL_IR_BINOP_ADD, $1, $3, loc);
|
||||
}
|
||||
| add_expr '-' mul_expr
|
||||
{
|
||||
struct source_location loc;
|
||||
|
||||
set_location(&loc, &@2);
|
||||
$$ = &hlsl_sub($1, $3, &loc)->node;
|
||||
$$ = new_binary_expr(HLSL_IR_BINOP_SUB, $1, $3, loc);
|
||||
}
|
||||
|
||||
shift_expr: add_expr
|
||||
|
@ -2272,28 +2272,28 @@ relational_expr: shift_expr
|
|||
struct source_location loc;
|
||||
|
||||
set_location(&loc, &@2);
|
||||
$$ = &hlsl_lt($1, $3, &loc)->node;
|
||||
$$ = new_binary_expr(HLSL_IR_BINOP_LESS, $1, $3, loc);
|
||||
}
|
||||
| relational_expr '>' shift_expr
|
||||
{
|
||||
struct source_location loc;
|
||||
|
||||
set_location(&loc, &@2);
|
||||
$$ = &hlsl_gt($1, $3, &loc)->node;
|
||||
$$ = new_binary_expr(HLSL_IR_BINOP_GREATER, $1, $3, loc);
|
||||
}
|
||||
| relational_expr OP_LE shift_expr
|
||||
{
|
||||
struct source_location loc;
|
||||
|
||||
set_location(&loc, &@2);
|
||||
$$ = &hlsl_le($1, $3, &loc)->node;
|
||||
$$ = new_binary_expr(HLSL_IR_BINOP_LEQUAL, $1, $3, loc);
|
||||
}
|
||||
| relational_expr OP_GE shift_expr
|
||||
{
|
||||
struct source_location loc;
|
||||
|
||||
set_location(&loc, &@2);
|
||||
$$ = &hlsl_ge($1, $3, &loc)->node;
|
||||
$$ = new_binary_expr(HLSL_IR_BINOP_GEQUAL, $1, $3, loc);
|
||||
}
|
||||
|
||||
equality_expr: relational_expr
|
||||
|
@ -2305,14 +2305,14 @@ equality_expr: relational_expr
|
|||
struct source_location loc;
|
||||
|
||||
set_location(&loc, &@2);
|
||||
$$ = &hlsl_eq($1, $3, &loc)->node;
|
||||
$$ = new_binary_expr(HLSL_IR_BINOP_EQUAL, $1, $3, loc);
|
||||
}
|
||||
| equality_expr OP_NE relational_expr
|
||||
{
|
||||
struct source_location loc;
|
||||
|
||||
set_location(&loc, &@2);
|
||||
$$ = &hlsl_ne($1, $3, &loc)->node;
|
||||
$$ = new_binary_expr(HLSL_IR_BINOP_NEQUAL, $1, $3, loc);
|
||||
}
|
||||
|
||||
bitand_expr: equality_expr
|
||||
|
|
|
@ -1351,149 +1351,6 @@ struct hlsl_ir_expr *new_cast(struct hlsl_ir_node *node, struct hlsl_type *type,
|
|||
return expr_from_node(cast);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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_ADD, ops, loc);
|
||||
return expr;
|
||||
}
|
||||
|
||||
struct hlsl_ir_expr *hlsl_sub(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_SUB, ops, loc);
|
||||
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));
|
||||
|
@ -1553,7 +1410,6 @@ static enum hlsl_ir_expr_op op_from_assignment(enum parse_assign_op op)
|
|||
struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *left, enum parse_assign_op assign_op,
|
||||
DWORD writemask, struct hlsl_ir_node *right)
|
||||
{
|
||||
struct hlsl_ir_expr *expr;
|
||||
struct hlsl_ir_assignment *assign = d3dcompiler_alloc(sizeof(*assign));
|
||||
struct hlsl_type *type;
|
||||
struct hlsl_ir_node *lhs, *rhs;
|
||||
|
@ -1643,8 +1499,8 @@ struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *left, enum parse_assig
|
|||
assign->lhs = lhs;
|
||||
if (assign_op != ASSIGN_OP_ASSIGN)
|
||||
{
|
||||
struct hlsl_ir_node *operands[3];
|
||||
enum hlsl_ir_expr_op op = op_from_assignment(assign_op);
|
||||
struct hlsl_ir_node *expr;
|
||||
|
||||
if (lhs->type != HLSL_IR_DEREF || deref_from_node(lhs)->type != HLSL_IR_DEREF_VAR)
|
||||
{
|
||||
|
@ -1657,11 +1513,8 @@ struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *left, enum parse_assig
|
|||
|
||||
TRACE("Adding an expression for the compound assignment.\n");
|
||||
new_deref = new_var_deref(lhs_deref->v.var);
|
||||
operands[0] = &new_deref->node;
|
||||
operands[1] = rhs;
|
||||
operands[2] = NULL;
|
||||
expr = new_expr(op, operands, &left->loc);
|
||||
assign->rhs = &expr->node;
|
||||
expr = new_binary_expr(op, &new_deref->node, rhs, left->loc);
|
||||
assign->rhs = expr;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue