Zebediah Figura : vkd3d-shader/hlsl: Get rid of the unary_op rule.
Alexandre Julliard
julliard at winehq.org
Mon Sep 27 15:20:04 CDT 2021
Module: vkd3d
Branch: master
Commit: 8930bb734f5c2ef85b70fcfa7f779d3cbc2b0237
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=8930bb734f5c2ef85b70fcfa7f779d3cbc2b0237
Author: Zebediah Figura <zfigura at codeweavers.com>
Date: Thu Sep 23 16:47:04 2021 -0500
vkd3d-shader/hlsl: Get rid of the unary_op rule.
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
libs/vkd3d-shader/hlsl.y | 51 +++++++++++++-----------------------------------
1 file changed, 14 insertions(+), 37 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
index b8d147a..42a6768 100644
--- a/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d-shader/hlsl.y
@@ -80,14 +80,6 @@ struct parse_if_body
struct list *else_instrs;
};
-enum parse_unary_op
-{
- UNARY_OP_PLUS,
- UNARY_OP_MINUS,
- UNARY_OP_LOGICNOT,
- UNARY_OP_BITNOT,
-};
-
enum parse_assign_op
{
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_variable_def *variable_def;
struct parse_if_body if_body;
- enum parse_unary_op unary_op;
enum parse_assign_op assign_op;
struct hlsl_reg_reservation reg_reservation;
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> typedef_type
-%type <unary_op> unary_op
-
%type <variable_def> type_spec
%type <variable_def> variable_def
@@ -3037,16 +3026,22 @@ unary_expr:
}
$$ = $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};
-
- if ($1 == UNARY_OP_PLUS)
- $$ = $2;
- else
- $$ = add_unary_expr(ctx, $2, ops[$1], @1);
+ $$ = $2;
+ }
+ | '-' unary_expr
+ {
+ $$ = add_unary_expr(ctx, $2, HLSL_OP1_NEG, @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 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);
}
-unary_op:
- '+'
- {
- $$ = UNARY_OP_PLUS;
- }
- | '-'
- {
- $$ = UNARY_OP_MINUS;
- }
- | '!'
- {
- $$ = UNARY_OP_LOGICNOT;
- }
- | '~'
- {
- $$ = UNARY_OP_BITNOT;
- }
-
mul_expr:
unary_expr
| mul_expr '*' unary_expr
More information about the wine-cvs
mailing list