r300/compiler: Use variable lists in the rename_regs pass

This commit is contained in:
Tom Stellard 2012-06-24 14:23:26 -04:00
parent 7540f25a34
commit 07c71d6ede

View file

@ -32,8 +32,9 @@
#include "radeon_rename_regs.h"
#include "radeon_compiler.h"
#include "radeon_dataflow.h"
#include "radeon_list.h"
#include "radeon_program.h"
#include "radeon_variable.h"
/**
* This function renames registers in an attempt to get the code close to
@ -45,11 +46,11 @@
*/
void rc_rename_regs(struct radeon_compiler *c, void *user)
{
unsigned int i, used_length;
int new_index;
unsigned int used_length;
struct rc_instruction * inst;
struct rc_reader_data reader_data;
unsigned char * used;
struct rc_list * variables;
struct rc_list * var_ptr;
/* XXX Remove this once the register allocation works with flow control. */
for(inst = c->Program.Instructions.Next;
@ -64,18 +65,16 @@ void rc_rename_regs(struct radeon_compiler *c, void *user)
memset(used, 0, sizeof(unsigned char) * used_length);
rc_get_used_temporaries(c, used, used_length);
for(inst = c->Program.Instructions.Next;
inst != &c->Program.Instructions;
inst = inst->Next) {
variables = rc_get_variables(c);
if (inst->U.I.DstReg.File != RC_FILE_TEMPORARY)
continue;
reader_data.ExitOnAbort = 1;
rc_get_readers(c, inst, &reader_data, NULL, NULL, NULL);
if (reader_data.Abort || reader_data.ReaderCount == 0)
for (var_ptr = variables; var_ptr; var_ptr = var_ptr->Next) {
unsigned new_index;
unsigned writemask;
struct rc_variable * var = var_ptr->Item;
if (var->Inst->U.I.DstReg.File != RC_FILE_TEMPORARY) {
continue;
}
new_index = rc_find_free_temporary_list(c, used, used_length,
RC_MASK_XYZW);
@ -84,9 +83,7 @@ void rc_rename_regs(struct radeon_compiler *c, void *user)
return;
}
reader_data.Writer->U.I.DstReg.Index = new_index;
for(i = 0; i < reader_data.ReaderCount; i++) {
reader_data.Readers[i].U.I.Src->Index = new_index;
}
writemask = rc_variable_writemask_sum(var);
rc_variable_change_dst(var, new_index, writemask);
}
}