glsl/cs: update main.cpp to use the ".comp" extension for compute shaders.
[mesa.git] / src / glsl / opt_array_splitting.cpp
index 67733ca6ba6895d72db149b8f59e42f8c7cfe5d7..f37d0902201e4a2a49bd250423c5ad22e8d6aca2 100644 (file)
 #include "ir.h"
 #include "ir_visitor.h"
 #include "ir_rvalue_visitor.h"
-#include "ir_print_visitor.h"
 #include "glsl_types.h"
 
 static bool debug = false;
 
+namespace {
+
 namespace opt_array_splitting {
 
 class variable_entry : public exec_node
@@ -78,6 +79,7 @@ public:
 };
 
 } /* namespace */
+
 using namespace opt_array_splitting;
 
 /**
@@ -113,13 +115,15 @@ public:
    void *mem_ctx;
 };
 
+} /* namespace */
+
 variable_entry *
 ir_array_reference_visitor::get_variable_entry(ir_variable *var)
 {
    assert(var);
 
-   if (var->mode != ir_var_auto &&
-       var->mode != ir_var_temporary)
+   if (var->data.mode != ir_var_auto &&
+       var->data.mode != ir_var_temporary)
       return NULL;
 
    if (!(var->type->is_array() || var->type->is_matrix()))
@@ -128,11 +132,11 @@ ir_array_reference_visitor::get_variable_entry(ir_variable *var)
    /* If the array hasn't been sized yet, we can't split it.  After
     * linking, this should be resolved.
     */
-   if (var->type->is_array() && var->type->length == 0)
+   if (var->type->is_unsized_array())
       return NULL;
 
-   foreach_iter(exec_list_iterator, iter, this->variable_list) {
-      variable_entry *entry = (variable_entry *)iter.get();
+   foreach_list(n, &this->variable_list) {
+      variable_entry *entry = (variable_entry *) n;
       if (entry->var == var)
         return entry;
    }
@@ -220,8 +224,8 @@ ir_array_reference_visitor::get_split_list(exec_list *instructions,
    }
 
    /* Trim out variables we found that we can't split. */
-   foreach_iter(exec_list_iterator, iter, variable_list) {
-      variable_entry *entry = (variable_entry *)iter.get();
+   foreach_list_safe(n, &variable_list) {
+      variable_entry *entry = (variable_entry *) n;
 
       if (debug) {
         printf("array %s@%p: decl %d, split %d\n",
@@ -266,8 +270,8 @@ ir_array_splitting_visitor::get_splitting_entry(ir_variable *var)
 {
    assert(var);
 
-   foreach_iter(exec_list_iterator, iter, *this->variable_list) {
-      variable_entry *entry = (variable_entry *)iter.get();
+   foreach_list(n, this->variable_list) {
+      variable_entry *entry = (variable_entry *) n;
       if (entry->var == var) {
         return entry;
       }
@@ -364,8 +368,8 @@ optimize_split_arrays(exec_list *instructions, bool linked)
    /* Replace the decls of the arrays to be split with their split
     * components.
     */
-   foreach_iter(exec_list_iterator, iter, refs.variable_list) {
-      variable_entry *entry = (variable_entry *)iter.get();
+   foreach_list(n, &refs.variable_list) {
+      variable_entry *entry = (variable_entry *) n;
       const struct glsl_type *type = entry->var->type;
       const struct glsl_type *subtype;