[PATCH v2 2/3] d3dcompiler: Rename HLSL_IR_DEREF to HLSL_IR_LOAD.

Zebediah Figura z.figura12 at gmail.com
Tue May 19 20:17:33 CDT 2020


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

diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h
index 31cf1ed582d..6c2f234c4dd 100644
--- a/dlls/d3dcompiler_43/d3dcompiler_private.h
+++ b/dlls/d3dcompiler_43/d3dcompiler_private.h
@@ -648,9 +648,9 @@ enum hlsl_ir_node_type
     HLSL_IR_ASSIGNMENT = 0,
     HLSL_IR_CONSTANT,
     HLSL_IR_CONSTRUCTOR,
-    HLSL_IR_DEREF,
     HLSL_IR_EXPR,
     HLSL_IR_IF,
+    HLSL_IR_LOAD,
     HLSL_IR_LOOP,
     HLSL_IR_JUMP,
     HLSL_IR_SWIZZLE,
@@ -847,7 +847,7 @@ struct hlsl_deref
     struct hlsl_ir_node *offset;
 };
 
-struct hlsl_ir_deref
+struct hlsl_ir_load
 {
     struct hlsl_ir_node node;
     struct hlsl_deref src;
@@ -1004,10 +1004,10 @@ static inline struct hlsl_ir_expr *expr_from_node(const struct hlsl_ir_node *nod
     return CONTAINING_RECORD(node, struct hlsl_ir_expr, node);
 }
 
-static inline struct hlsl_ir_deref *deref_from_node(const struct hlsl_ir_node *node)
+static inline struct hlsl_ir_load *load_from_node(const struct hlsl_ir_node *node)
 {
-    assert(node->type == HLSL_IR_DEREF);
-    return CONTAINING_RECORD(node, struct hlsl_ir_deref, node);
+    assert(node->type == HLSL_IR_LOAD);
+    return CONTAINING_RECORD(node, struct hlsl_ir_load, node);
 }
 
 static inline struct hlsl_ir_constant *constant_from_node(const struct hlsl_ir_node *node)
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y
index 67177ad831b..5130114976e 100644
--- a/dlls/d3dcompiler_43/hlsl.y
+++ b/dlls/d3dcompiler_43/hlsl.y
@@ -561,30 +561,30 @@ static struct hlsl_ir_constant *new_uint_constant(unsigned int n, const struct s
     return c;
 }
 
-static struct hlsl_ir_deref *new_var_deref(struct hlsl_ir_var *var, const struct source_location loc)
+static struct hlsl_ir_load *new_var_load(struct hlsl_ir_var *var, const struct source_location loc)
 {
-    struct hlsl_ir_deref *deref = d3dcompiler_alloc(sizeof(*deref));
+    struct hlsl_ir_load *load = d3dcompiler_alloc(sizeof(*load));
 
-    if (!deref)
+    if (!load)
     {
         ERR("Out of memory.\n");
         return NULL;
     }
-    init_node(&deref->node, HLSL_IR_DEREF, var->data_type, loc);
-    deref->src.var = var;
-    return deref;
+    init_node(&load->node, HLSL_IR_LOAD, var->data_type, loc);
+    load->src.var = var;
+    return load;
 }
 
-static struct hlsl_ir_deref *new_deref(struct hlsl_ir_node *var_node, struct hlsl_ir_node *offset,
+static struct hlsl_ir_load *new_load(struct hlsl_ir_node *var_node, struct hlsl_ir_node *offset,
         struct hlsl_type *data_type, const struct source_location loc)
 {
     struct hlsl_ir_node *add = NULL;
-    struct hlsl_ir_deref *deref;
+    struct hlsl_ir_load *load;
     struct hlsl_ir_var *var;
 
-    if (var_node->type == HLSL_IR_DEREF)
+    if (var_node->type == HLSL_IR_LOAD)
     {
-        const struct hlsl_deref *src = &deref_from_node(var_node)->src;
+        const struct hlsl_deref *src = &load_from_node(var_node)->src;
 
         var = src->var;
         if (src->offset)
@@ -612,16 +612,16 @@ static struct hlsl_ir_deref *new_deref(struct hlsl_ir_node *var_node, struct hls
         list_add_after(&var_node->entry, &assign->node.entry);
     }
 
-    if (!(deref = d3dcompiler_alloc(sizeof(*deref))))
+    if (!(load = d3dcompiler_alloc(sizeof(*load))))
         return NULL;
-    init_node(&deref->node, HLSL_IR_DEREF, data_type, loc);
-    deref->src.var = var;
-    deref->src.offset = offset;
-    list_add_after(&offset->entry, &deref->node.entry);
-    return deref;
+    init_node(&load->node, HLSL_IR_LOAD, data_type, loc);
+    load->src.var = var;
+    load->src.offset = offset;
+    list_add_after(&offset->entry, &load->node.entry);
+    return load;
 }
 
-static struct hlsl_ir_deref *new_record_deref(struct hlsl_ir_node *record,
+static struct hlsl_ir_load *new_record_load(struct hlsl_ir_node *record,
         const struct hlsl_struct_field *field, const struct source_location loc)
 {
     struct hlsl_ir_constant *c;
@@ -630,16 +630,16 @@ static struct hlsl_ir_deref *new_record_deref(struct hlsl_ir_node *record,
         return NULL;
     list_add_after(&record->entry, &c->node.entry);
 
-    return new_deref(record, &c->node, field->type, loc);
+    return new_load(record, &c->node, field->type, loc);
 }
 
-static struct hlsl_ir_deref *new_array_deref(struct hlsl_ir_node *array,
+static struct hlsl_ir_load *new_array_load(struct hlsl_ir_node *array,
         struct hlsl_ir_node *index, const struct source_location loc)
 {
     const struct hlsl_type *expr_type = array->data_type;
     struct hlsl_type *data_type;
 
-    TRACE("Array dereference from type %s.\n", debug_hlsl_type(expr_type));
+    TRACE("Array load from type %s.\n", debug_hlsl_type(expr_type));
 
     if (expr_type->type == HLSL_CLASS_ARRAY)
     {
@@ -674,7 +674,7 @@ static struct hlsl_ir_deref *new_array_deref(struct hlsl_ir_node *array,
         index = mul;
     }
 
-    return new_deref(array, index, data_type, loc);
+    return new_load(array, index, data_type, loc);
 }
 
 static void struct_var_initializer(struct list *list, struct hlsl_ir_var *var,
@@ -683,7 +683,7 @@ static void struct_var_initializer(struct list *list, struct hlsl_ir_var *var,
     struct hlsl_type *type = var->data_type;
     struct hlsl_struct_field *field;
     struct hlsl_ir_node *assignment;
-    struct hlsl_ir_deref *deref;
+    struct hlsl_ir_load *load;
     unsigned int i = 0;
 
     if (initializer_size(initializer) != components_count_type(type))
@@ -707,14 +707,13 @@ static void struct_var_initializer(struct list *list, struct hlsl_ir_var *var,
         }
         if (components_count_type(field->type) == components_count_type(node->data_type))
         {
-            deref = new_record_deref(&new_var_deref(var, var->loc)->node, field, node->loc);
-            if (!deref)
+            if (!(load = new_record_load(&new_var_load(var, var->loc)->node, field, node->loc)))
             {
                 ERR("Out of memory.\n");
                 break;
             }
-            list_add_tail(list, &deref->node.entry);
-            assignment = make_assignment(&deref->node, ASSIGN_OP_ASSIGN, node);
+            list_add_tail(list, &load->node.entry);
+            assignment = make_assignment(&load->node, ASSIGN_OP_ASSIGN, node);
             list_add_tail(list, &assignment->entry);
         }
         else
@@ -805,7 +804,7 @@ static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers,
         if (v->initializer.args_count)
         {
             unsigned int size = initializer_size(&v->initializer);
-            struct hlsl_ir_deref *deref;
+            struct hlsl_ir_load *load;
 
             TRACE("Variable with initializer.\n");
             if (type->type <= HLSL_CLASS_LAST_NUMERIC
@@ -861,9 +860,9 @@ static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers,
             list_move_tail(statements_list, v->initializer.instrs);
             d3dcompiler_free(v->initializer.instrs);
 
-            deref = new_var_deref(var, var->loc);
-            list_add_tail(statements_list, &deref->node.entry);
-            assignment = make_assignment(&deref->node, ASSIGN_OP_ASSIGN, v->initializer.args[0]);
+            load = new_var_load(var, var->loc);
+            list_add_tail(statements_list, &load->node.entry);
+            assignment = make_assignment(&load->node, ASSIGN_OP_ASSIGN, v->initializer.args[0]);
             d3dcompiler_free(v->initializer.args);
             list_add_tail(statements_list, &assignment->entry);
         }
@@ -1221,8 +1220,8 @@ static unsigned int evaluate_array_dimension(struct hlsl_ir_node *node)
         }
     }
     case HLSL_IR_CONSTRUCTOR:
-    case HLSL_IR_DEREF:
     case HLSL_IR_EXPR:
+    case HLSL_IR_LOAD:
     case HLSL_IR_SWIZZLE:
         FIXME("Unhandled type %s.\n", debug_node_type(node->type));
         return 0;
@@ -2248,7 +2247,7 @@ primary_expr:             C_FLOAT
                             }
                         | VAR_IDENTIFIER
                             {
-                                struct hlsl_ir_deref *deref;
+                                struct hlsl_ir_load *load;
                                 struct hlsl_ir_var *var;
 
                                 if (!(var = get_variable(hlsl_ctx.cur_scope, $1)))
@@ -2258,9 +2257,9 @@ primary_expr:             C_FLOAT
                                     set_parse_status(&hlsl_ctx.status, PARSE_ERR);
                                     YYABORT;
                                 }
-                                if ((deref = new_var_deref(var, get_location(&@1))))
+                                if ((load = new_var_load(var, get_location(&@1))))
                                 {
-                                    if (!($$ = make_list(&deref->node)))
+                                    if (!($$ = make_list(&load->node)))
                                         YYABORT;
                                 }
                                 else
@@ -2325,14 +2324,14 @@ postfix_expr:             primary_expr
                                     {
                                         if (!strcmp($3, field->name))
                                         {
-                                            struct hlsl_ir_deref *deref = new_record_deref(node, field, loc);
+                                            struct hlsl_ir_load *load = new_record_load(node, field, loc);
 
-                                            if (!deref)
+                                            if (!load)
                                             {
                                                 ERR("Out of memory\n");
                                                 YYABORT;
                                             }
-                                            $$ = append_unop($1, &deref->node);
+                                            $$ = append_unop($1, &load->node);
                                             break;
                                         }
                                     }
@@ -2365,7 +2364,7 @@ postfix_expr:             primary_expr
                             }
                         | postfix_expr '[' expr ']'
                             {
-                                struct hlsl_ir_deref *deref;
+                                struct hlsl_ir_load *load;
 
                                 if (node_from_list($3)->data_type->type != HLSL_CLASS_SCALAR)
                                 {
@@ -2375,13 +2374,13 @@ postfix_expr:             primary_expr
                                     YYABORT;
                                 }
 
-                                if (!(deref = new_array_deref(node_from_list($1), node_from_list($3), get_location(&@2))))
+                                if (!(load = new_array_load(node_from_list($1), node_from_list($3), get_location(&@2))))
                                 {
                                     free_instr_list($1);
                                     free_instr_list($3);
                                     YYABORT;
                                 }
-                                $$ = append_binop($1, $3, &deref->node);
+                                $$ = append_binop($1, $3, &load->node);
                             }
                           /* "var_modifiers" doesn't make sense in this case, but it's needed
                              in the grammar to avoid shift/reduce conflicts. */
@@ -2814,15 +2813,6 @@ static void compute_liveness_recurse(struct list *instrs, unsigned int loop_firs
                 constructor->args[i]->last_read = instr->index;
             break;
         }
-        case HLSL_IR_DEREF:
-        {
-            struct hlsl_ir_deref *deref = deref_from_node(instr);
-            var = deref->src.var;
-            var->last_read = loop_last ? max(instr->index, loop_last) : instr->index;
-            if (deref->src.offset)
-                deref->src.offset->last_read = instr->index;
-            break;
-        }
         case HLSL_IR_EXPR:
         {
             struct hlsl_ir_expr *expr = expr_from_node(instr);
@@ -2849,6 +2839,15 @@ static void compute_liveness_recurse(struct list *instrs, unsigned int loop_firs
                 jump->return_value->last_read = instr->index;
             break;
         }
+        case HLSL_IR_LOAD:
+        {
+            struct hlsl_ir_load *load = load_from_node(instr);
+            var = load->src.var;
+            var->last_read = loop_last ? max(instr->index, loop_last) : instr->index;
+            if (load->src.offset)
+                load->src.offset->last_read = instr->index;
+            break;
+        }
         case HLSL_IR_LOOP:
         {
             struct hlsl_ir_loop *loop = loop_from_node(instr);
diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c
index 4b1f99de65d..440ad491884 100644
--- a/dlls/d3dcompiler_43/utils.c
+++ b/dlls/d3dcompiler_43/utils.c
@@ -1450,7 +1450,7 @@ struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *lhs, enum parse_assign
         return NULL;
     }
 
-    while (lhs->type != HLSL_IR_DEREF)
+    while (lhs->type != HLSL_IR_LOAD)
     {
         struct hlsl_ir_node *lhs_inner;
 
@@ -1527,7 +1527,7 @@ struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *lhs, enum parse_assign
 
     rhs = implicit_conversion(rhs, type, &rhs->loc);
 
-    assign->lhs = deref_from_node(lhs)->src;
+    assign->lhs = load_from_node(lhs)->src;
     if (assign_op != ASSIGN_OP_ASSIGN)
     {
         enum hlsl_ir_expr_op op = op_from_assignment(assign_op);
@@ -1791,9 +1791,9 @@ const char *debug_node_type(enum hlsl_ir_node_type type)
         "HLSL_IR_ASSIGNMENT",
         "HLSL_IR_CONSTANT",
         "HLSL_IR_CONSTRUCTOR",
-        "HLSL_IR_DEREF",
         "HLSL_IR_EXPR",
         "HLSL_IR_IF",
+        "HLSL_IR_LOAD",
         "HLSL_IR_LOOP",
         "HLSL_IR_JUMP",
         "HLSL_IR_SWIZZLE",
@@ -2096,8 +2096,8 @@ static void debug_dump_instr(const struct hlsl_ir_node *instr)
         case HLSL_IR_EXPR:
             debug_dump_ir_expr(expr_from_node(instr));
             break;
-        case HLSL_IR_DEREF:
-            debug_dump_deref(&deref_from_node(instr)->src);
+        case HLSL_IR_LOAD:
+            debug_dump_deref(&load_from_node(instr)->src);
             break;
         case HLSL_IR_CONSTANT:
             debug_dump_ir_constant(constant_from_node(instr));
@@ -2195,9 +2195,9 @@ static void free_ir_constant(struct hlsl_ir_constant *constant)
     d3dcompiler_free(constant);
 }
 
-static void free_ir_deref(struct hlsl_ir_deref *deref)
+static void free_ir_load(struct hlsl_ir_load *load)
 {
-    d3dcompiler_free(deref);
+    d3dcompiler_free(load);
 }
 
 static void free_ir_swizzle(struct hlsl_ir_swizzle *swizzle)
@@ -2245,8 +2245,8 @@ void free_instr(struct hlsl_ir_node *node)
         case HLSL_IR_CONSTANT:
             free_ir_constant(constant_from_node(node));
             break;
-        case HLSL_IR_DEREF:
-            free_ir_deref(deref_from_node(node));
+        case HLSL_IR_LOAD:
+            free_ir_load(load_from_node(node));
             break;
         case HLSL_IR_SWIZZLE:
             free_ir_swizzle(swizzle_from_node(node));
-- 
2.26.2




More information about the wine-devel mailing list