util/ra: Add a function for making all conflicts on a register transitive
authorJason Ekstrand <jason.ekstrand@intel.com>
Sat, 15 Aug 2015 16:43:05 +0000 (09:43 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Wed, 19 Aug 2015 00:48:45 +0000 (17:48 -0700)
Reviewed-by: Eric Anholt <eric@anholt.net>
src/util/register_allocate.c
src/util/register_allocate.h

index 436e008b01a778b0ae35d581dec1bf578c3c8868..c9867e35e357375e313bbbb30cfb1e13f6cb1e2a 100644 (file)
@@ -266,6 +266,29 @@ ra_add_transitive_reg_conflict(struct ra_regs *regs,
    }
 }
 
    }
 }
 
+/**
+ * Makes every conflict on the given register transitive.  In other words,
+ * every register that conflicts with r will now conflict with every other
+ * register conflicting with r.
+ *
+ * This can simplify code for setting up multiple register classes
+ * which are aggregates of some base hardware registers, compared to
+ * explicitly using ra_add_reg_conflict.
+ */
+void
+ra_make_reg_conflicts_transitive(struct ra_regs *regs, unsigned int r)
+{
+   struct ra_reg *reg = &regs->regs[r];
+   BITSET_WORD tmp;
+   int c;
+
+   BITSET_FOREACH_SET(c, tmp, reg->conflicts, regs->count) {
+      struct ra_reg *other = &regs->regs[c];
+      for (unsigned i = 0; i < BITSET_WORDS(regs->count); i++)
+         other->conflicts[i] |= reg->conflicts[i];
+   }
+}
+
 unsigned int
 ra_alloc_reg_class(struct ra_regs *regs)
 {
 unsigned int
 ra_alloc_reg_class(struct ra_regs *regs)
 {
index 61f182eff49a928331792bbc591631c818a7f27c..ed3854cec7dbfc568b21bee378fe3f794ac7a618 100644 (file)
@@ -51,6 +51,7 @@ void ra_add_reg_conflict(struct ra_regs *regs,
                         unsigned int r1, unsigned int r2);
 void ra_add_transitive_reg_conflict(struct ra_regs *regs,
                                    unsigned int base_reg, unsigned int reg);
                         unsigned int r1, unsigned int r2);
 void ra_add_transitive_reg_conflict(struct ra_regs *regs,
                                    unsigned int base_reg, unsigned int reg);
+void ra_make_reg_conflicts_transitive(struct ra_regs *regs, unsigned int reg);
 void ra_class_add_reg(struct ra_regs *regs, unsigned int c, unsigned int reg);
 void ra_set_num_conflicts(struct ra_regs *regs, unsigned int class_a,
                           unsigned int class_b, unsigned int num_conflicts);
 void ra_class_add_reg(struct ra_regs *regs, unsigned int c, unsigned int reg);
 void ra_set_num_conflicts(struct ra_regs *regs, unsigned int class_a,
                           unsigned int class_b, unsigned int num_conflicts);