util/ra: spiff out select_reg_callback
[mesa.git] / src / util / register_allocate.h
index fcd4d9394e041ef77214496aa9ef47ac16b294f7..7d8459b1eff09fb3913afd4951e02a94524f53de 100644 (file)
@@ -83,10 +83,28 @@ void ra_resize_interference_graph(struct ra_graph *g, unsigned int count);
 void ra_set_node_class(struct ra_graph *g, unsigned int n, unsigned int c);
 unsigned int ra_get_node_class(struct ra_graph *g, unsigned int n);
 unsigned int ra_add_node(struct ra_graph *g, unsigned int c);
+
+/** @{ Register selection callback.
+ *
+ * The register allocator can use either one of two built-in register
+ * selection behaviors (ie. lowest-available or round-robin), or the
+ * user can implement it's own selection policy by setting an register
+ * selection callback.  The parameters to the callback are:
+ *
+ *  - n       the graph node, ie. the virtual variable to select a
+ *            register for
+ *  - regs    bitset of available registers to choose; this bitset
+ *            contains *all* registers, but registers of different
+ *            classes will not have their corresponding bit set.
+ *  - data    callback data specified in ra_set_select_reg_callback()
+ */
+typedef unsigned int (*ra_select_reg_callback)(
+      unsigned int n,        /* virtual variable to choose a physical reg for */
+      BITSET_WORD *regs,     /* available physical regs to choose from */
+      void *data);
+
 void ra_set_select_reg_callback(struct ra_graph *g,
-                                unsigned int (*callback)(struct ra_graph *g,
-                                                         BITSET_WORD *regs,
-                                                         void *data),
+                                ra_select_reg_callback callback,
                                 void *data);
 void ra_add_node_interference(struct ra_graph *g,
                               unsigned int n1, unsigned int n2);