glsl/opt_array_splitting: Fix indentation

Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
This commit is contained in:
Iago Toral Quiroga 2016-03-03 09:12:16 +01:00
parent 4a60002424
commit 283c8372cb
1 changed files with 26 additions and 28 deletions

View File

@ -55,9 +55,9 @@ public:
this->components = NULL; this->components = NULL;
this->mem_ctx = NULL; this->mem_ctx = NULL;
if (var->type->is_array()) if (var->type->is_array())
this->size = var->type->length; this->size = var->type->length;
else else
this->size = var->type->matrix_columns; this->size = var->type->matrix_columns;
} }
ir_variable *var; /* The key: the variable's pointer. */ ir_variable *var; /* The key: the variable's pointer. */
@ -137,7 +137,7 @@ ir_array_reference_visitor::get_variable_entry(ir_variable *var)
foreach_in_list(variable_entry, entry, &this->variable_list) { foreach_in_list(variable_entry, entry, &this->variable_list) {
if (entry->var == var) if (entry->var == var)
return entry; return entry;
} }
variable_entry *entry = new(mem_ctx) variable_entry(var); variable_entry *entry = new(mem_ctx) variable_entry(var);
@ -218,7 +218,7 @@ ir_array_reference_visitor::visit_enter(ir_function_signature *ir)
bool bool
ir_array_reference_visitor::get_split_list(exec_list *instructions, ir_array_reference_visitor::get_split_list(exec_list *instructions,
bool linked) bool linked)
{ {
visit_list_elements(this, instructions); visit_list_elements(this, instructions);
@ -227,25 +227,25 @@ ir_array_reference_visitor::get_split_list(exec_list *instructions,
*/ */
if (!linked) { if (!linked) {
foreach_in_list(ir_instruction, node, instructions) { foreach_in_list(ir_instruction, node, instructions) {
ir_variable *var = node->as_variable(); ir_variable *var = node->as_variable();
if (var) { if (var) {
variable_entry *entry = get_variable_entry(var); variable_entry *entry = get_variable_entry(var);
if (entry) if (entry)
entry->remove(); entry->remove();
} }
} }
} }
/* Trim out variables we found that we can't split. */ /* Trim out variables we found that we can't split. */
foreach_in_list_safe(variable_entry, entry, &variable_list) { foreach_in_list_safe(variable_entry, entry, &variable_list) {
if (debug) { if (debug) {
printf("array %s@%p: decl %d, split %d\n", printf("array %s@%p: decl %d, split %d\n",
entry->var->name, (void *) entry->var, entry->declaration, entry->var->name, (void *) entry->var, entry->declaration,
entry->split); entry->split);
} }
if (!(entry->declaration && entry->split)) { if (!(entry->declaration && entry->split)) {
entry->remove(); entry->remove();
} }
} }
@ -283,7 +283,7 @@ ir_array_splitting_visitor::get_splitting_entry(ir_variable *var)
foreach_in_list(variable_entry, entry, this->variable_list) { foreach_in_list(variable_entry, entry, this->variable_list) {
if (entry->var == var) { if (entry->var == var) {
return entry; return entry;
} }
} }
@ -311,7 +311,7 @@ ir_array_splitting_visitor::split_deref(ir_dereference **deref)
if (constant->value.i[0] >= 0 && constant->value.i[0] < (int)entry->size) { if (constant->value.i[0] >= 0 && constant->value.i[0] < (int)entry->size) {
*deref = new(entry->mem_ctx) *deref = new(entry->mem_ctx)
ir_dereference_variable(entry->components[constant->value.i[0]]); ir_dereference_variable(entry->components[constant->value.i[0]]);
} else { } else {
/* There was a constant array access beyond the end of the /* There was a constant array access beyond the end of the
* array. This might have happened due to constant folding * array. This might have happened due to constant folding
@ -320,8 +320,8 @@ ir_array_splitting_visitor::split_deref(ir_dereference **deref)
* variable. * variable.
*/ */
ir_variable *temp = new(entry->mem_ctx) ir_variable(deref_array->type, ir_variable *temp = new(entry->mem_ctx) ir_variable(deref_array->type,
"undef", "undef",
ir_var_temporary); ir_var_temporary);
entry->components[0]->insert_before(temp); entry->components[0]->insert_before(temp);
*deref = new(entry->mem_ctx) ir_dereference_variable(temp); *deref = new(entry->mem_ctx) ir_dereference_variable(temp);
} }
@ -383,23 +383,21 @@ optimize_split_arrays(exec_list *instructions, bool linked)
const struct glsl_type *subtype; const struct glsl_type *subtype;
if (type->is_matrix()) if (type->is_matrix())
subtype = type->column_type(); subtype = type->column_type();
else else
subtype = type->fields.array; subtype = type->fields.array;
entry->mem_ctx = ralloc_parent(entry->var); entry->mem_ctx = ralloc_parent(entry->var);
entry->components = ralloc_array(mem_ctx, entry->components = ralloc_array(mem_ctx, ir_variable *, entry->size);
ir_variable *,
entry->size);
for (unsigned int i = 0; i < entry->size; i++) { for (unsigned int i = 0; i < entry->size; i++) {
const char *name = ralloc_asprintf(mem_ctx, "%s_%d", const char *name = ralloc_asprintf(mem_ctx, "%s_%d",
entry->var->name, i); entry->var->name, i);
entry->components[i] = entry->components[i] =
new(entry->mem_ctx) ir_variable(subtype, name, ir_var_temporary); new(entry->mem_ctx) ir_variable(subtype, name, ir_var_temporary);
entry->var->insert_before(entry->components[i]); entry->var->insert_before(entry->components[i]);
} }
entry->var->remove(); entry->var->remove();