#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
*/
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;
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;
+ for (var_ptr = variables; var_ptr; var_ptr = var_ptr->Next) {
+ unsigned new_index;
+ unsigned writemask;
+ struct rc_variable * var = var_ptr->Item;
- reader_data.ExitOnAbort = 1;
- rc_get_readers(c, inst, &reader_data, NULL, NULL, NULL);
-
- if (reader_data.Abort || reader_data.ReaderCount == 0)
+ 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);
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);
}
}