[PATCH 5/5] d3dcompiler: Rename HLSL_IR_DEREF to HLSL_IR_LOAD.

Zebediah Figura z.figura12 at gmail.com
Mon May 4 15:03:46 CDT 2020


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

diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h
index 983057d543c..b1dfcbda3d1 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,
@@ -848,7 +848,7 @@ struct hlsl_deref
     DWORD writemask;
 };
 
-struct hlsl_ir_deref
+struct hlsl_ir_load
 {
     struct hlsl_ir_node node;
     struct hlsl_deref src;
@@ -1005,10 +1005,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 24157c8fdc9..9ee4f9e89ba 100644
--- a/dlls/d3dcompiler_43/hlsl.y
+++ b/dlls/d3dcompiler_43/hlsl.y
@@ -561,32 +561,32 @@ 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;
+    init_node(&load->node, HLSL_IR_LOAD, var->data_type, loc);
+    load->src.var = var;
     if (type_is_single_reg(var->data_type))
-        deref->src.writemask = (1 << var->data_type->dimx) - 1;
-    return deref;
+        load->src.writemask = (1 << var->data_type->dimx) - 1;
+    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)
@@ -614,18 +614,18 @@ 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;
+    init_node(&load->node, HLSL_IR_LOAD, data_type, loc);
+    load->src.var = var;
+    load->src.offset = offset;
     if (type_is_single_reg(data_type))
-        deref->src.writemask = (1 << data_type->dimx) - 1;
-    list_add_after(&offset->entry, &deref->node.entry);
-    return deref;
+        load->src.writemask = (1 << data_type->dimx) - 1;
+    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;
@@ -634,16 +634,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)
     {
@@ -678,7 +678,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,
@@ -687,7 +687,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))
@@ -711,14 +711,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
@@ -809,7 +808,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
@@ -865,9 +864,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);
         }
@@ -1225,8 +1224,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;
@@ -2252,7 +2251,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)))
@@ -2262,9 +2261,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
@@ -2329,14 +2328,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;
                                         }
                                     }
@@ -2369,7 +2368,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)
                                 {
@@ -2379,13 +2378,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. */
@@ -2818,15 +2817,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);
@@ -2853,6 +2843,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