[Mesa-dev] [PATCH 2/3] glsl: Rename ir_constant::array_elements to ::const_elements

Ian Romanick idr at freedesktop.org
Tue Sep 12 16:41:02 UTC 2017


From: Ian Romanick <ian.d.romanick at intel.com>

The next patch will unify ::array_elements and ::components, so the
name ::array_elements wouldn't be appropriate.  A lot of things use
the names array_elements and components, so grepping for either is
pretty useless.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/compiler/glsl/glsl_to_nir.cpp                  |  2 +-
 src/compiler/glsl/ir.cpp                           | 24 +++++++++++-----------
 src/compiler/glsl/ir.h                             |  2 +-
 src/compiler/glsl/ir_clone.cpp                     |  4 ++--
 src/compiler/glsl/link_uniform_initializers.cpp    |  8 ++++----
 .../glsl/tests/uniform_initializer_utils.cpp       |  4 ++--
 src/mesa/program/ir_to_mesa.cpp                    |  2 +-
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp         |  2 +-
 8 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp
index bb2ba17..f3cf74d 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -302,7 +302,7 @@ constant_copy(ir_constant *ir, void *mem_ctx)
       ret->num_elements = ir->type->length;
 
       for (i = 0; i < ir->type->length; i++)
-         ret->elements[i] = constant_copy(ir->array_elements[i], mem_ctx);
+         ret->elements[i] = constant_copy(ir->const_elements[i], mem_ctx);
       break;
 
    default:
diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp
index 52ca836..c223ec6 100644
--- a/src/compiler/glsl/ir.cpp
+++ b/src/compiler/glsl/ir.cpp
@@ -627,14 +627,14 @@ ir_expression::variable_referenced() const
 ir_constant::ir_constant()
    : ir_rvalue(ir_type_constant)
 {
-   this->array_elements = NULL;
+   this->const_elements = NULL;
 }
 
 ir_constant::ir_constant(const struct glsl_type *type,
 			 const ir_constant_data *data)
    : ir_rvalue(ir_type_constant)
 {
-   this->array_elements = NULL;
+   this->const_elements = NULL;
 
    assert((type->base_type >= GLSL_TYPE_UINT)
 	  && (type->base_type <= GLSL_TYPE_IMAGE));
@@ -737,7 +737,7 @@ ir_constant::ir_constant(bool b, unsigned vector_elements)
 ir_constant::ir_constant(const ir_constant *c, unsigned i)
    : ir_rvalue(ir_type_constant)
 {
-   this->array_elements = NULL;
+   this->const_elements = NULL;
    this->type = c->type->get_base_type();
 
    switch (this->type->base_type) {
@@ -753,19 +753,19 @@ ir_constant::ir_constant(const ir_constant *c, unsigned i)
 ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list)
    : ir_rvalue(ir_type_constant)
 {
-   this->array_elements = NULL;
+   this->const_elements = NULL;
    this->type = type;
 
    assert(type->is_scalar() || type->is_vector() || type->is_matrix()
 	  || type->is_record() || type->is_array());
 
    if (type->is_array()) {
-      this->array_elements = ralloc_array(this, ir_constant *, type->length);
+      this->const_elements = ralloc_array(this, ir_constant *, type->length);
       unsigned i = 0;
       foreach_in_list(ir_constant, value, value_list) {
 	 assert(value->as_constant() != NULL);
 
-	 this->array_elements[i++] = value;
+	 this->const_elements[i++] = value;
       }
       return;
    }
@@ -924,10 +924,10 @@ ir_constant::zero(void *mem_ctx, const glsl_type *type)
    memset(&c->value, 0, sizeof(c->value));
 
    if (type->is_array()) {
-      c->array_elements = ralloc_array(c, ir_constant *, type->length);
+      c->const_elements = ralloc_array(c, ir_constant *, type->length);
 
       for (unsigned i = 0; i < type->length; i++)
-	 c->array_elements[i] = ir_constant::zero(c, type->fields.array);
+	 c->const_elements[i] = ir_constant::zero(c, type->fields.array);
    }
 
    if (type->is_record()) {
@@ -1100,7 +1100,7 @@ ir_constant::get_array_element(unsigned i) const
    else if (i >= this->type->length)
       i = this->type->length - 1;
 
-   return array_elements[i];
+   return const_elements[i];
 }
 
 ir_constant *
@@ -1181,7 +1181,7 @@ ir_constant::copy_offset(ir_constant *src, int offset)
    case GLSL_TYPE_ARRAY: {
       assert (src->type == this->type);
       for (unsigned i = 0; i < this->type->length; i++) {
-	 this->array_elements[i] = src->array_elements[i]->clone(this, NULL);
+	 this->const_elements[i] = src->const_elements[i]->clone(this, NULL);
       }
       break;
    }
@@ -1243,7 +1243,7 @@ ir_constant::has_value(const ir_constant *c) const
 
    if (this->type->is_array()) {
       for (unsigned i = 0; i < this->type->length; i++) {
-	 if (!this->array_elements[i]->has_value(c->array_elements[i]))
+	 if (!this->const_elements[i]->has_value(c->const_elements[i]))
 	    return false;
       }
       return true;
@@ -1976,7 +1976,7 @@ steal_memory(ir_instruction *ir, void *new_ctx)
 	 }
       } else if (constant->type->is_array()) {
 	 for (unsigned int i = 0; i < constant->type->length; i++) {
-	    steal_memory(constant->array_elements[i], ir);
+	    steal_memory(constant->const_elements[i], ir);
 	 }
       }
    }
diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h
index e2b7277..d87f7c3 100644
--- a/src/compiler/glsl/ir.h
+++ b/src/compiler/glsl/ir.h
@@ -2263,7 +2263,7 @@ public:
    union ir_constant_data value;
 
    /* Array elements */
-   ir_constant **array_elements;
+   ir_constant **const_elements;
 
    /* Structure fields */
    exec_list components;
diff --git a/src/compiler/glsl/ir_clone.cpp b/src/compiler/glsl/ir_clone.cpp
index 4fb9fa3..114367c 100644
--- a/src/compiler/glsl/ir_clone.cpp
+++ b/src/compiler/glsl/ir_clone.cpp
@@ -364,9 +364,9 @@ ir_constant::clone(void *mem_ctx, struct hash_table *ht) const
       ir_constant *c = new(mem_ctx) ir_constant;
 
       c->type = this->type;
-      c->array_elements = ralloc_array(c, ir_constant *, this->type->length);
+      c->const_elements = ralloc_array(c, ir_constant *, this->type->length);
       for (unsigned i = 0; i < this->type->length; i++) {
-	 c->array_elements[i] = this->array_elements[i]->clone(mem_ctx, NULL);
+         c->const_elements[i] = this->const_elements[i]->clone(mem_ctx, NULL);
       }
       return c;
    }
diff --git a/src/compiler/glsl/link_uniform_initializers.cpp b/src/compiler/glsl/link_uniform_initializers.cpp
index 01754cd..beb9038 100644
--- a/src/compiler/glsl/link_uniform_initializers.cpp
+++ b/src/compiler/glsl/link_uniform_initializers.cpp
@@ -227,7 +227,7 @@ set_uniform_initializer(void *mem_ctx, gl_shader_program *prog,
          const char *element_name = ralloc_asprintf(mem_ctx, "%s[%d]", name, i);
 
          set_uniform_initializer(mem_ctx, prog, element_name,
-                                 element_type, val->array_elements[i],
+                                 element_type, val->const_elements[i],
                                  boolean_true);
       }
       return;
@@ -240,15 +240,15 @@ set_uniform_initializer(void *mem_ctx, gl_shader_program *prog,
 
    if (val->type->is_array()) {
       const enum glsl_base_type base_type =
-         val->array_elements[0]->type->base_type;
-      const unsigned int elements = val->array_elements[0]->type->components();
+         val->const_elements[0]->type->base_type;
+      const unsigned int elements = val->const_elements[0]->type->components();
       unsigned int idx = 0;
       unsigned dmul = glsl_base_type_is_64bit(base_type) ? 2 : 1;
 
       assert(val->type->length >= storage->array_elements);
       for (unsigned int i = 0; i < storage->array_elements; i++) {
          copy_constant_to_storage(& storage->storage[idx],
-                                  val->array_elements[i],
+                                  val->const_elements[i],
                                   base_type,
                                   elements,
                                   boolean_true);
diff --git a/src/compiler/glsl/tests/uniform_initializer_utils.cpp b/src/compiler/glsl/tests/uniform_initializer_utils.cpp
index 9a66eba..c5502b6 100644
--- a/src/compiler/glsl/tests/uniform_initializer_utils.cpp
+++ b/src/compiler/glsl/tests/uniform_initializer_utils.cpp
@@ -215,11 +215,11 @@ verify_data(gl_constant_value *storage, unsigned storage_array_size,
             unsigned int boolean_true)
 {
    if (val->type->is_array()) {
-      const glsl_type *const element_type = val->array_elements[0]->type;
+      const glsl_type *const element_type = val->const_elements[0]->type;
 
       for (unsigned i = 0; i < storage_array_size; i++) {
 	 verify_data(storage + (i * element_type->components()), 0,
-		     val->array_elements[i], 0, boolean_true);
+                     val->const_elements[i], 0, boolean_true);
       }
 
       const unsigned components = element_type->components();
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 11207dd..432ec746 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -1940,7 +1940,7 @@ ir_to_mesa_visitor::visit(ir_constant *ir)
       assert(size > 0);
 
       for (i = 0; i < ir->type->length; i++) {
-	 ir->array_elements[i]->accept(this);
+	 ir->const_elements[i]->accept(this);
 	 src = this->result;
 	 for (int j = 0; j < size; j++) {
 	    emit(ir, OPCODE_MOV, temp, src);
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index cf6e8f8..5531fc0 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -2997,7 +2997,7 @@ glsl_to_tgsi_visitor::visit(ir_constant *ir)
       in_array++;
 
       for (i = 0; i < ir->type->length; i++) {
-         ir->array_elements[i]->accept(this);
+         ir->const_elements[i]->accept(this);
          src = this->result;
          for (int j = 0; j < size; j++) {
             emit_asm(ir, TGSI_OPCODE_MOV, temp, src);
-- 
2.9.5



More information about the mesa-dev mailing list