[PATCH v2] d3dcompiler: Append the instruction to its list in new_return().

Matteo Bruni mbruni at codeweavers.com
Mon Jun 22 15:53:00 CDT 2020


From: Zebediah Figura <z.figura12 at gmail.com>

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
---
v2: Get rid of the "jump" variables.

 dlls/d3dcompiler_43/hlsl.y | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y
index 511a43d156a..5d8d7c56a76 100644
--- a/dlls/d3dcompiler_43/hlsl.y
+++ b/dlls/d3dcompiler_43/hlsl.y
@@ -562,7 +562,8 @@ static struct hlsl_ir_assignment *make_simple_assignment(struct hlsl_ir_var *lhs
     return new_assignment(lhs, NULL, rhs, 0, rhs->loc);
 }
 
-static struct hlsl_ir_jump *new_return(struct hlsl_ir_node *return_value, struct source_location loc)
+static struct hlsl_ir_jump *add_return(struct list *instrs,
+        struct hlsl_ir_node *return_value, struct source_location loc)
 {
     struct hlsl_type *return_type = hlsl_ctx.cur_function->return_type;
     struct hlsl_ir_jump *jump;
@@ -591,6 +592,7 @@ static struct hlsl_ir_jump *new_return(struct hlsl_ir_node *return_value, struct
     }
     init_node(&jump->node, HLSL_IR_JUMP, NULL, loc);
     jump->type = HLSL_IR_JUMP_RETURN;
+    list_add_tail(instrs, &jump->node.entry);
 
     return jump;
 }
@@ -2160,24 +2162,22 @@ statement:                declaration_statement
                         | selection_statement
                         | loop_statement
 
-jump_statement:           KW_RETURN expr ';'
-                            {
-                                struct hlsl_ir_jump *jump;
-                                if (!(jump = new_return(node_from_list($2), get_location(&@1))))
-                                    YYABORT;
+jump_statement:
 
-                                $$ = $2;
-                                list_add_tail($$, &jump->node.entry);
-                            }
-                        | KW_RETURN ';'
-                            {
-                                struct hlsl_ir_jump *jump;
-                                if (!(jump = new_return(NULL, get_location(&@1))))
-                                    YYABORT;
-                                $$ = d3dcompiler_alloc(sizeof(*$$));
-                                list_init($$);
-                                list_add_tail($$, &jump->node.entry);
-                            }
+      KW_RETURN expr ';'
+        {
+            if (!add_return($2, node_from_list($2), get_location(&@1)))
+                YYABORT;
+            $$ = $2;
+        }
+    | KW_RETURN ';'
+        {
+            if (!($$ = d3dcompiler_alloc(sizeof(*$$))))
+                YYABORT;
+            list_init($$);
+            if (!add_return($$, NULL, get_location(&@1)))
+                YYABORT;
+        }
 
 selection_statement:      KW_IF '(' expr ')' if_body
                             {
-- 
2.26.2




More information about the wine-devel mailing list