Mesa (master): mesa: Add a convenience interface for register allocator conflicts setup.

Eric Anholt anholt at kemper.freedesktop.org
Wed Aug 10 11:16:51 PDT 2011


Module: Mesa
Branch: master
Commit: fa43477fa33c068915283d511b64e3d6470ccd73
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=fa43477fa33c068915283d511b64e3d6470ccd73

Author: Eric Anholt <eric at anholt.net>
Date:   Wed May  4 13:27:33 2011 -0700

mesa: Add a convenience interface for register allocator conflicts setup.

---

 src/mesa/program/register_allocate.c |   21 +++++++++++++++++++++
 src/mesa/program/register_allocate.h |    2 ++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/src/mesa/program/register_allocate.c b/src/mesa/program/register_allocate.c
index de96eb4..f5b5174 100644
--- a/src/mesa/program/register_allocate.c
+++ b/src/mesa/program/register_allocate.c
@@ -200,6 +200,27 @@ ra_add_reg_conflict(struct ra_regs *regs, unsigned int r1, unsigned int r2)
    }
 }
 
+/**
+ * Adds a conflict between base_reg and reg, and also between reg and
+ * anything that base_reg conflicts with.
+ *
+ * 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_add_transitive_reg_conflict(struct ra_regs *regs,
+			       unsigned int base_reg, unsigned int reg)
+{
+   int i;
+
+   ra_add_reg_conflict(regs, reg, base_reg);
+
+   for (i = 0; i < regs->regs[base_reg].num_conflicts; i++) {
+      ra_add_reg_conflict(regs, reg, regs->regs[base_reg].conflict_list[i]);
+   }
+}
+
 unsigned int
 ra_alloc_reg_class(struct ra_regs *regs)
 {
diff --git a/src/mesa/program/register_allocate.h b/src/mesa/program/register_allocate.h
index 5b95833..ee2e58a 100644
--- a/src/mesa/program/register_allocate.h
+++ b/src/mesa/program/register_allocate.h
@@ -40,6 +40,8 @@ struct ra_regs *ra_alloc_reg_set(unsigned int count);
 unsigned int ra_alloc_reg_class(struct ra_regs *regs);
 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);
 void ra_class_add_reg(struct ra_regs *regs, unsigned int c, unsigned int reg);
 void ra_set_finalize(struct ra_regs *regs);
 /** @} */



More information about the mesa-commit mailing list