d3dcompiler: Introduce a new_unary_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
b89f027bc1
commit
b899965615
|
@ -1186,6 +1186,12 @@ void free_instr(struct hlsl_ir_node *node) DECLSPEC_HIDDEN;
|
||||||
void free_instr_list(struct list *list) DECLSPEC_HIDDEN;
|
void free_instr_list(struct list *list) DECLSPEC_HIDDEN;
|
||||||
void free_function_rb(struct wine_rb_entry *entry, void *context) 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;
|
||||||
|
}
|
||||||
|
|
||||||
#define MAKE_TAG(ch0, ch1, ch2, ch3) \
|
#define MAKE_TAG(ch0, ch1, ch2, ch3) \
|
||||||
((DWORD)(ch0) | ((DWORD)(ch1) << 8) | \
|
((DWORD)(ch0) | ((DWORD)(ch1) << 8) | \
|
||||||
|
|
|
@ -257,9 +257,8 @@ static void declare_predefined_types(struct hlsl_scope *scope)
|
||||||
|
|
||||||
static struct hlsl_ir_if *loop_condition(struct list *cond_list)
|
static struct hlsl_ir_if *loop_condition(struct list *cond_list)
|
||||||
{
|
{
|
||||||
|
struct hlsl_ir_node *cond, *not_cond;
|
||||||
struct hlsl_ir_if *out_cond;
|
struct hlsl_ir_if *out_cond;
|
||||||
struct hlsl_ir_expr *not_cond;
|
|
||||||
struct hlsl_ir_node *cond, *operands[3];
|
|
||||||
struct hlsl_ir_jump *jump;
|
struct hlsl_ir_jump *jump;
|
||||||
unsigned int count = list_count(cond_list);
|
unsigned int count = list_count(cond_list);
|
||||||
|
|
||||||
|
@ -276,16 +275,13 @@ static struct hlsl_ir_if *loop_condition(struct list *cond_list)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
out_cond->node.type = HLSL_IR_IF;
|
out_cond->node.type = HLSL_IR_IF;
|
||||||
operands[0] = cond;
|
if (!(not_cond = new_unary_expr(HLSL_IR_UNOP_LOGIC_NOT, cond, cond->loc)))
|
||||||
operands[1] = operands[2] = NULL;
|
|
||||||
not_cond = new_expr(HLSL_IR_UNOP_LOGIC_NOT, operands, &cond->loc);
|
|
||||||
if (!not_cond)
|
|
||||||
{
|
{
|
||||||
ERR("Out of memory.\n");
|
ERR("Out of memory.\n");
|
||||||
d3dcompiler_free(out_cond);
|
d3dcompiler_free(out_cond);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
out_cond->condition = ¬_cond->node;
|
out_cond->condition = not_cond;
|
||||||
jump = d3dcompiler_alloc(sizeof(*jump));
|
jump = d3dcompiler_alloc(sizeof(*jump));
|
||||||
if (!jump)
|
if (!jump)
|
||||||
{
|
{
|
||||||
|
@ -1931,7 +1927,6 @@ postfix_expr: primary_expr
|
||||||
}
|
}
|
||||||
| postfix_expr OP_INC
|
| postfix_expr OP_INC
|
||||||
{
|
{
|
||||||
struct hlsl_ir_node *operands[3];
|
|
||||||
struct source_location loc;
|
struct source_location loc;
|
||||||
|
|
||||||
set_location(&loc, &@2);
|
set_location(&loc, &@2);
|
||||||
|
@ -1941,16 +1936,13 @@ postfix_expr: primary_expr
|
||||||
"modifying a const expression");
|
"modifying a const expression");
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
operands[0] = $1;
|
$$ = new_unary_expr(HLSL_IR_UNOP_POSTINC, $1, loc);
|
||||||
operands[1] = operands[2] = NULL;
|
|
||||||
$$ = &new_expr(HLSL_IR_UNOP_POSTINC, operands, &loc)->node;
|
|
||||||
/* Post increment/decrement expressions are considered const */
|
/* Post increment/decrement expressions are considered const */
|
||||||
$$->data_type = clone_hlsl_type($$->data_type);
|
$$->data_type = clone_hlsl_type($$->data_type);
|
||||||
$$->data_type->modifiers |= HLSL_MODIFIER_CONST;
|
$$->data_type->modifiers |= HLSL_MODIFIER_CONST;
|
||||||
}
|
}
|
||||||
| postfix_expr OP_DEC
|
| postfix_expr OP_DEC
|
||||||
{
|
{
|
||||||
struct hlsl_ir_node *operands[3];
|
|
||||||
struct source_location loc;
|
struct source_location loc;
|
||||||
|
|
||||||
set_location(&loc, &@2);
|
set_location(&loc, &@2);
|
||||||
|
@ -1960,9 +1952,7 @@ postfix_expr: primary_expr
|
||||||
"modifying a const expression");
|
"modifying a const expression");
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
operands[0] = $1;
|
$$ = new_unary_expr(HLSL_IR_UNOP_POSTDEC, $1, loc);
|
||||||
operands[1] = operands[2] = NULL;
|
|
||||||
$$ = &new_expr(HLSL_IR_UNOP_POSTDEC, operands, &loc)->node;
|
|
||||||
/* Post increment/decrement expressions are considered const */
|
/* Post increment/decrement expressions are considered const */
|
||||||
$$->data_type = clone_hlsl_type($$->data_type);
|
$$->data_type = clone_hlsl_type($$->data_type);
|
||||||
$$->data_type->modifiers |= HLSL_MODIFIER_CONST;
|
$$->data_type->modifiers |= HLSL_MODIFIER_CONST;
|
||||||
|
@ -2125,7 +2115,6 @@ unary_expr: postfix_expr
|
||||||
}
|
}
|
||||||
| OP_INC unary_expr
|
| OP_INC unary_expr
|
||||||
{
|
{
|
||||||
struct hlsl_ir_node *operands[3];
|
|
||||||
struct source_location loc;
|
struct source_location loc;
|
||||||
|
|
||||||
set_location(&loc, &@1);
|
set_location(&loc, &@1);
|
||||||
|
@ -2135,13 +2124,10 @@ unary_expr: postfix_expr
|
||||||
"modifying a const expression");
|
"modifying a const expression");
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
operands[0] = $2;
|
$$ = new_unary_expr(HLSL_IR_UNOP_PREINC, $2, loc);
|
||||||
operands[1] = operands[2] = NULL;
|
|
||||||
$$ = &new_expr(HLSL_IR_UNOP_PREINC, operands, &loc)->node;
|
|
||||||
}
|
}
|
||||||
| OP_DEC unary_expr
|
| OP_DEC unary_expr
|
||||||
{
|
{
|
||||||
struct hlsl_ir_node *operands[3];
|
|
||||||
struct source_location loc;
|
struct source_location loc;
|
||||||
|
|
||||||
set_location(&loc, &@1);
|
set_location(&loc, &@1);
|
||||||
|
@ -2151,15 +2137,12 @@ unary_expr: postfix_expr
|
||||||
"modifying a const expression");
|
"modifying a const expression");
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
operands[0] = $2;
|
$$ = new_unary_expr(HLSL_IR_UNOP_PREDEC, $2, loc);
|
||||||
operands[1] = operands[2] = NULL;
|
|
||||||
$$ = &new_expr(HLSL_IR_UNOP_PREDEC, operands, &loc)->node;
|
|
||||||
}
|
}
|
||||||
| unary_op unary_expr
|
| unary_op unary_expr
|
||||||
{
|
{
|
||||||
enum hlsl_ir_expr_op ops[] = {0, HLSL_IR_UNOP_NEG,
|
enum hlsl_ir_expr_op ops[] = {0, HLSL_IR_UNOP_NEG,
|
||||||
HLSL_IR_UNOP_LOGIC_NOT, HLSL_IR_UNOP_BIT_NOT};
|
HLSL_IR_UNOP_LOGIC_NOT, HLSL_IR_UNOP_BIT_NOT};
|
||||||
struct hlsl_ir_node *operands[3];
|
|
||||||
struct source_location loc;
|
struct source_location loc;
|
||||||
|
|
||||||
if ($1 == UNARY_OP_PLUS)
|
if ($1 == UNARY_OP_PLUS)
|
||||||
|
@ -2168,10 +2151,8 @@ unary_expr: postfix_expr
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
operands[0] = $2;
|
|
||||||
operands[1] = operands[2] = NULL;
|
|
||||||
set_location(&loc, &@1);
|
set_location(&loc, &@1);
|
||||||
$$ = &new_expr(ops[$1], operands, &loc)->node;
|
$$ = new_unary_expr(ops[$1], $2, loc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* var_modifiers just to avoid shift/reduce conflicts */
|
/* var_modifiers just to avoid shift/reduce conflicts */
|
||||||
|
|
|
@ -1343,15 +1343,12 @@ struct hlsl_ir_expr *new_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node **ope
|
||||||
struct hlsl_ir_expr *new_cast(struct hlsl_ir_node *node, struct hlsl_type *type,
|
struct hlsl_ir_expr *new_cast(struct hlsl_ir_node *node, struct hlsl_type *type,
|
||||||
struct source_location *loc)
|
struct source_location *loc)
|
||||||
{
|
{
|
||||||
struct hlsl_ir_expr *cast;
|
struct hlsl_ir_node *cast;
|
||||||
struct hlsl_ir_node *operands[3];
|
|
||||||
|
|
||||||
operands[0] = node;
|
cast = new_unary_expr(HLSL_IR_UNOP_CAST, node, *loc);
|
||||||
operands[1] = operands[2] = NULL;
|
|
||||||
cast = new_expr(HLSL_IR_UNOP_CAST, operands, loc);
|
|
||||||
if (cast)
|
if (cast)
|
||||||
cast->node.data_type = type;
|
cast->data_type = type;
|
||||||
return cast;
|
return expr_from_node(cast);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct hlsl_ir_expr *hlsl_mul(struct hlsl_ir_node *op1, struct hlsl_ir_node *op2,
|
struct hlsl_ir_expr *hlsl_mul(struct hlsl_ir_node *op1, struct hlsl_ir_node *op2,
|
||||||
|
|
Loading…
Reference in New Issue