[PATCH 2/6] d3dcompiler: Store the arguments to a hlsl_ir_constructor as a fixed array.

Zebediah Figura zfigura at codeweavers.com
Fri Aug 9 09:52:45 CDT 2019


Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
 dlls/d3dcompiler_43/d3dcompiler_private.h |  3 ++-
 dlls/d3dcompiler_43/hlsl.y                |  8 +++++++-
 dlls/d3dcompiler_43/utils.c               | 10 ++++++----
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h
index e165f21897f..d6db46b4536 100644
--- a/dlls/d3dcompiler_43/d3dcompiler_private.h
+++ b/dlls/d3dcompiler_43/d3dcompiler_private.h
@@ -952,7 +952,8 @@ struct hlsl_ir_constant
 struct hlsl_ir_constructor
 {
     struct hlsl_ir_node node;
-    struct list *arguments;
+    struct hlsl_ir_node *args[16];
+    unsigned int args_count;
 };
 
 struct hlsl_scope
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y
index ba0fd5ceaff..0f9819062c7 100644
--- a/dlls/d3dcompiler_43/hlsl.y
+++ b/dlls/d3dcompiler_43/hlsl.y
@@ -2092,6 +2092,7 @@ postfix_expr:             primary_expr
                         | var_modifiers type '(' initializer_expr_list ')'
                             {
                                 struct hlsl_ir_constructor *constructor;
+                                struct hlsl_ir_node *instr;
 
                                 TRACE("%s constructor.\n", debug_hlsl_type($2));
                                 if ($1)
@@ -2120,7 +2121,12 @@ postfix_expr:             primary_expr
                                 constructor->node.type = HLSL_IR_CONSTRUCTOR;
                                 set_location(&constructor->node.loc, &@3);
                                 constructor->node.data_type = $2;
-                                constructor->arguments = $4;
+                                constructor->args_count = 0;
+                                LIST_FOR_EACH_ENTRY(instr, $4, struct hlsl_ir_node, entry)
+                                {
+                                    constructor->args[constructor->args_count++] = instr;
+                                }
+                                d3dcompiler_free($4);
 
                                 $$ = &constructor->node;
                             }
diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c
index a521eb65382..742b2623ddb 100644
--- a/dlls/d3dcompiler_43/utils.c
+++ b/dlls/d3dcompiler_43/utils.c
@@ -2122,12 +2122,12 @@ static void debug_dump_ir_expr(const struct hlsl_ir_expr *expr)
 
 static void debug_dump_ir_constructor(const struct hlsl_ir_constructor *constructor)
 {
-    struct hlsl_ir_node *arg;
+    unsigned int i;
 
     TRACE("%s (", debug_hlsl_type(constructor->node.data_type));
-    LIST_FOR_EACH_ENTRY(arg, constructor->arguments, struct hlsl_ir_node, entry)
+    for (i = 0; i < constructor->args_count; ++i)
     {
-        debug_dump_instr(arg);
+        debug_dump_instr(constructor->args[i]);
         TRACE(" ");
     }
     TRACE(")");
@@ -2349,7 +2349,9 @@ static void free_ir_swizzle(struct hlsl_ir_swizzle *swizzle)
 
 static void free_ir_constructor(struct hlsl_ir_constructor *constructor)
 {
-    free_instr_list(constructor->arguments);
+    unsigned int i;
+    for (i = 0; i < constructor->args_count; ++i)
+        free_instr(constructor->args[i]);
     d3dcompiler_free(constructor);
 }
 
-- 
2.20.1




More information about the wine-devel mailing list