OSDN Git Service

r300/compiler: Use variable lists in the rename_regs pass
authorTom Stellard <thomas.stellard@amd.com>
Sun, 24 Jun 2012 18:23:26 +0000 (14:23 -0400)
committerTom Stellard <thomas.stellard@amd.com>
Mon, 27 Aug 2012 00:39:49 +0000 (20:39 -0400)
src/gallium/drivers/r300/compiler/radeon_rename_regs.c

index cafa057..7b29ece 100644 (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
  */
 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;
+       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);
@@ -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);
        }
 }