vkd3d-shader/hlsl: Get rid of the unary_op rule.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-09-23 16:47:04 -05:00 committed by Alexandre Julliard
parent 9a627494a3
commit 8930bb734f

View File

@ -80,14 +80,6 @@ struct parse_if_body
struct list *else_instrs; struct list *else_instrs;
}; };
enum parse_unary_op
{
UNARY_OP_PLUS,
UNARY_OP_MINUS,
UNARY_OP_LOGICNOT,
UNARY_OP_BITNOT,
};
enum parse_assign_op enum parse_assign_op
{ {
ASSIGN_OP_ASSIGN, ASSIGN_OP_ASSIGN,
@ -1798,7 +1790,6 @@ static struct list *add_constructor(struct hlsl_ctx *ctx, struct hlsl_type *type
struct parse_array_sizes arrays; struct parse_array_sizes arrays;
struct parse_variable_def *variable_def; struct parse_variable_def *variable_def;
struct parse_if_body if_body; struct parse_if_body if_body;
enum parse_unary_op unary_op;
enum parse_assign_op assign_op; enum parse_assign_op assign_op;
struct hlsl_reg_reservation reg_reservation; struct hlsl_reg_reservation reg_reservation;
struct parse_colon_attribute colon_attribute; struct parse_colon_attribute colon_attribute;
@ -1987,8 +1978,6 @@ static struct list *add_constructor(struct hlsl_ctx *ctx, struct hlsl_type *type
%type <type> type %type <type> type
%type <type> typedef_type %type <type> typedef_type
%type <unary_op> unary_op
%type <variable_def> type_spec %type <variable_def> type_spec
%type <variable_def> variable_def %type <variable_def> variable_def
@ -3037,16 +3026,22 @@ unary_expr:
} }
$$ = $2; $$ = $2;
} }
| unary_op unary_expr | '+' unary_expr
{ {
static const enum hlsl_ir_expr_op ops[] = {0, HLSL_OP1_NEG, HLSL_OP1_LOGIC_NOT, HLSL_OP1_BIT_NOT}; $$ = $2;
}
if ($1 == UNARY_OP_PLUS) | '-' unary_expr
$$ = $2; {
else $$ = add_unary_expr(ctx, $2, HLSL_OP1_NEG, @1);
$$ = add_unary_expr(ctx, $2, ops[$1], @1); }
| '~' unary_expr
{
$$ = add_unary_expr(ctx, $2, HLSL_OP1_BIT_NOT, @1);
}
| '!' unary_expr
{
$$ = add_unary_expr(ctx, $2, HLSL_OP1_LOGIC_NOT, @1);
} }
/* var_modifiers is necessary to avoid shift/reduce conflicts. */ /* var_modifiers is necessary to avoid shift/reduce conflicts. */
| '(' var_modifiers type arrays ')' unary_expr | '(' var_modifiers type arrays ')' unary_expr
{ {
@ -3082,24 +3077,6 @@ unary_expr:
$$ = append_unop($6, &hlsl_new_cast(ctx, node_from_list($6), dst_type, &@3)->node); $$ = append_unop($6, &hlsl_new_cast(ctx, node_from_list($6), dst_type, &@3)->node);
} }
unary_op:
'+'
{
$$ = UNARY_OP_PLUS;
}
| '-'
{
$$ = UNARY_OP_MINUS;
}
| '!'
{
$$ = UNARY_OP_LOGICNOT;
}
| '~'
{
$$ = UNARY_OP_BITNOT;
}
mul_expr: mul_expr:
unary_expr unary_expr
| mul_expr '*' unary_expr | mul_expr '*' unary_expr