ra: Create a reg_belongs_to_class() helper function.
authorKenneth Graunke <kenneth@whitecape.org>
Sat, 22 Feb 2014 03:31:44 +0000 (19:31 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 18 Mar 2014 17:15:23 +0000 (10:15 -0700)
This is a little easier to read.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Christoph Brill <egore911@gmail.com>
src/mesa/program/register_allocate.c

index edde7309c7f761af852f8236211122beb6d9f589..c763b9602dafd32a0668681551e73ccee4b77085 100644 (file)
@@ -283,6 +283,15 @@ ra_class_add_reg(struct ra_regs *regs, unsigned int c, unsigned int r)
    class->p++;
 }
 
+/**
+ * Returns true if the register belongs to the given class.
+ */
+static bool
+reg_belongs_to_class(unsigned int r, struct ra_class *c)
+{
+   return c->regs[r];
+}
+
 /**
  * Must be called after all conflicts and register classes have been
  * set up and before the register set is used for allocation.
@@ -319,7 +328,7 @@ ra_set_finalize(struct ra_regs *regs, unsigned int **q_values)
            int conflicts = 0;
            int i;
 
-           if (!regs->classes[c]->regs[rc])
+            if (!reg_belongs_to_class(rc, regs->classes[c]))
               continue;
 
            for (i = 0; i < regs->regs[rc].num_conflicts; i++) {
@@ -479,7 +488,7 @@ ra_select(struct ra_graph *g)
        */
       for (ri = 0; ri < g->regs->count; ri++) {
          r = (start_search_reg + ri) % g->regs->count;
-        if (!c->regs[r])
+         if (!reg_belongs_to_class(r, c))
            continue;
 
         /* Check if any of our neighbors conflict with this register choice. */