d3dcompiler: Add the node to the instruction list in new_expr().
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
6083b1dd39
commit
7260f978f3
|
@ -1059,9 +1059,18 @@ static inline void init_node(struct hlsl_ir_node *node, enum hlsl_ir_node_type t
|
|||
|
||||
struct hlsl_ir_node *add_assignment(struct list *instrs, struct hlsl_ir_node *lhs,
|
||||
enum parse_assign_op assign_op, struct hlsl_ir_node *rhs) DECLSPEC_HIDDEN;
|
||||
struct hlsl_ir_expr *add_expr(struct list *instrs, enum hlsl_ir_expr_op op, struct hlsl_ir_node *operands[3],
|
||||
struct source_location *loc) DECLSPEC_HIDDEN;
|
||||
struct hlsl_ir_node *add_implicit_conversion(struct list *instrs, struct hlsl_ir_node *node, struct hlsl_type *type,
|
||||
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_node *new_binary_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg1,
|
||||
struct hlsl_ir_node *arg2) DECLSPEC_HIDDEN;
|
||||
struct hlsl_ir_node *new_unary_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg,
|
||||
struct source_location loc) DECLSPEC_HIDDEN;
|
||||
|
||||
BOOL add_declaration(struct hlsl_scope *scope, struct hlsl_ir_var *decl, BOOL local_var) DECLSPEC_HIDDEN;
|
||||
struct hlsl_ir_var *get_variable(struct hlsl_scope *scope, const char *name) DECLSPEC_HIDDEN;
|
||||
void free_declaration(struct hlsl_ir_var *decl) DECLSPEC_HIDDEN;
|
||||
|
@ -1075,10 +1084,6 @@ BOOL find_function(const char *name) DECLSPEC_HIDDEN;
|
|||
unsigned int components_count_type(struct hlsl_type *type) DECLSPEC_HIDDEN;
|
||||
BOOL compare_hlsl_types(const struct hlsl_type *t1, const struct hlsl_type *t2) DECLSPEC_HIDDEN;
|
||||
BOOL compatible_data_types(struct hlsl_type *s1, struct hlsl_type *s2) 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 *new_cast(struct hlsl_ir_node *node, struct hlsl_type *type,
|
||||
struct source_location *loc) DECLSPEC_HIDDEN;
|
||||
void push_scope(struct hlsl_parse_ctx *ctx) DECLSPEC_HIDDEN;
|
||||
BOOL pop_scope(struct hlsl_parse_ctx *ctx) DECLSPEC_HIDDEN;
|
||||
void init_functions_tree(struct wine_rb_tree *funcs) DECLSPEC_HIDDEN;
|
||||
|
@ -1098,20 +1103,6 @@ void free_instr(struct hlsl_ir_node *node) DECLSPEC_HIDDEN;
|
|||
void free_instr_list(struct list *list) DECLSPEC_HIDDEN;
|
||||
void free_function_rb(struct wine_rb_entry *entry, void *context) DECLSPEC_HIDDEN;
|
||||
|
||||
static inline struct hlsl_ir_node *new_unary_expr(enum hlsl_ir_expr_op op,
|
||||
struct hlsl_ir_node *op1, struct source_location loc)
|
||||
{
|
||||
struct hlsl_ir_node *operands[3] = {op1};
|
||||
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 ))
|
||||
|
|
|
@ -608,6 +608,34 @@ static struct hlsl_ir_constant *new_uint_constant(unsigned int n, const struct s
|
|||
return c;
|
||||
}
|
||||
|
||||
struct hlsl_ir_node *new_unary_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg, struct source_location loc)
|
||||
{
|
||||
struct hlsl_ir_expr *expr;
|
||||
|
||||
if (!(expr = d3dcompiler_alloc(sizeof(*expr))))
|
||||
return NULL;
|
||||
init_node(&expr->node, HLSL_IR_EXPR, arg->data_type, loc);
|
||||
expr->op = op;
|
||||
expr->operands[0] = arg;
|
||||
return &expr->node;
|
||||
}
|
||||
|
||||
struct hlsl_ir_node *new_binary_expr(enum hlsl_ir_expr_op op,
|
||||
struct hlsl_ir_node *arg1, struct hlsl_ir_node *arg2)
|
||||
{
|
||||
struct hlsl_ir_expr *expr;
|
||||
|
||||
assert(compare_hlsl_types(arg1->data_type, arg2->data_type));
|
||||
|
||||
if (!(expr = d3dcompiler_alloc(sizeof(*expr))))
|
||||
return NULL;
|
||||
init_node(&expr->node, HLSL_IR_EXPR, arg1->data_type, arg1->loc);
|
||||
expr->op = op;
|
||||
expr->operands[0] = arg1;
|
||||
expr->operands[1] = arg2;
|
||||
return &expr->node;
|
||||
}
|
||||
|
||||
static struct hlsl_ir_load *new_var_load(struct hlsl_ir_var *var, const struct source_location loc)
|
||||
{
|
||||
struct hlsl_ir_load *load = d3dcompiler_alloc(sizeof(*load));
|
||||
|
@ -636,7 +664,7 @@ static struct hlsl_ir_load *add_load(struct list *instrs, struct hlsl_ir_node *v
|
|||
var = src->var;
|
||||
if (src->offset)
|
||||
{
|
||||
if (!(add = new_binary_expr(HLSL_IR_BINOP_ADD, src->offset, offset, loc)))
|
||||
if (!(add = new_binary_expr(HLSL_IR_BINOP_ADD, src->offset, offset)))
|
||||
return NULL;
|
||||
list_add_tail(instrs, &add->entry);
|
||||
offset = add;
|
||||
|
@ -712,7 +740,7 @@ static struct hlsl_ir_load *add_array_load(struct list *instrs, struct hlsl_ir_n
|
|||
if (!(c = new_uint_constant(data_type->reg_size * 4, loc)))
|
||||
return NULL;
|
||||
list_add_tail(instrs, &c->node.entry);
|
||||
if (!(mul = new_binary_expr(HLSL_IR_BINOP_MUL, index, &c->node, loc)))
|
||||
if (!(mul = new_binary_expr(HLSL_IR_BINOP_MUL, index, &c->node)))
|
||||
return NULL;
|
||||
list_add_tail(instrs, &mul->entry);
|
||||
index = mul;
|
||||
|
@ -1196,10 +1224,10 @@ static struct list *append_unop(struct list *list, 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)
|
||||
{
|
||||
struct hlsl_ir_node *arg1 = node_from_list(list1), *arg2 = node_from_list(list2);
|
||||
struct hlsl_ir_node *args[3] = {node_from_list(list1), node_from_list(list2)};
|
||||
list_move_tail(list1, list2);
|
||||
d3dcompiler_free(list2);
|
||||
list_add_tail(list1, &new_binary_expr(op, arg1, arg2, loc)->entry);
|
||||
add_expr(list1, op, args, &loc);
|
||||
return list1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1328,7 +1328,7 @@ struct hlsl_ir_node *add_implicit_conversion(struct list *instrs, struct hlsl_ir
|
|||
return &cast->node;
|
||||
}
|
||||
|
||||
struct hlsl_ir_expr *new_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node **operands,
|
||||
struct hlsl_ir_expr *add_expr(struct list *instrs, enum hlsl_ir_expr_op op, struct hlsl_ir_node *operands[3],
|
||||
struct source_location *loc)
|
||||
{
|
||||
struct hlsl_ir_expr *expr;
|
||||
|
@ -1372,6 +1372,7 @@ struct hlsl_ir_expr *new_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node **ope
|
|||
expr->operands[0] = operands[0];
|
||||
expr->operands[1] = operands[1];
|
||||
expr->operands[2] = operands[2];
|
||||
list_add_tail(instrs, &expr->node.entry);
|
||||
|
||||
return expr;
|
||||
}
|
||||
|
@ -1519,7 +1520,7 @@ struct hlsl_ir_node *add_assignment(struct list *instrs, struct hlsl_ir_node *lh
|
|||
struct hlsl_ir_node *expr;
|
||||
|
||||
TRACE("Adding an expression for the compound assignment.\n");
|
||||
expr = new_binary_expr(op, lhs, rhs, lhs->loc);
|
||||
expr = new_binary_expr(op, lhs, rhs);
|
||||
list_add_after(&rhs->entry, &expr->entry);
|
||||
rhs = expr;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue