X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Futil%2Fregister_allocate.h;h=c9170e7762a82f0fc4b7bb72c6cb517d225f6a59;hb=19b2ac2bb9e1ddc22956920d661f0e47aa49d718;hp=61f182eff49a928331792bbc591631c818a7f27c;hpb=237dcb4aa7c39c59bfd225ae3d73caf709be216d;p=mesa.git diff --git a/src/util/register_allocate.h b/src/util/register_allocate.h index 61f182eff49..c9170e7762a 100644 --- a/src/util/register_allocate.h +++ b/src/util/register_allocate.h @@ -25,8 +25,11 @@ * */ -#include +#ifndef REGISTER_ALLOCATE_H +#define REGISTER_ALLOCATE_H +#include +#include "util/bitset.h" #ifdef __cplusplus extern "C" { @@ -36,6 +39,9 @@ extern "C" { struct ra_class; struct ra_regs; +struct blob; +struct blob_reader; + /* @{ * Register set setup. * @@ -44,17 +50,27 @@ struct ra_regs; * registers, such as aligned register pairs that conflict with the * two real registers from which they are composed. */ -struct ra_regs *ra_alloc_reg_set(void *mem_ctx, unsigned int count); +struct ra_regs *ra_alloc_reg_set(void *mem_ctx, unsigned int count, + bool need_conflict_lists); void ra_set_allocate_round_robin(struct ra_regs *regs); 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); + 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 base_reg, unsigned int reg); + +void +ra_add_transitive_reg_pair_conflict(struct ra_regs *regs, + unsigned int base_reg, unsigned int reg0, unsigned int reg1); + +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_set_finalize(struct ra_regs *regs, unsigned int **conflicts); + +void ra_set_serialize(const struct ra_regs *regs, struct blob *blob); +struct ra_regs *ra_set_deserialize(void *mem_ctx, struct blob_reader *blob); /** @} */ /** @{ Interference graph setup. @@ -68,15 +84,46 @@ void ra_set_finalize(struct ra_regs *regs, unsigned int **conflicts); * graph. */ struct ra_graph *ra_alloc_interference_graph(struct ra_regs *regs, - unsigned int count); + unsigned int count); +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, + ra_select_reg_callback callback, + void *data); void ra_add_node_interference(struct ra_graph *g, - unsigned int n1, unsigned int n2); + unsigned int n1, unsigned int n2); +void ra_reset_node_interference(struct ra_graph *g, unsigned int n); /** @} */ /** @{ Graph-coloring register allocation */ bool ra_allocate(struct ra_graph *g); +#define NO_REG ~0U +/** + * Returns NO_REG for a node that has not (yet) been assigned. + */ unsigned int ra_get_node_reg(struct ra_graph *g, unsigned int n); void ra_set_node_reg(struct ra_graph * g, unsigned int n, unsigned int reg); void ra_set_node_spill_cost(struct ra_graph *g, unsigned int n, float cost); @@ -87,3 +134,5 @@ int ra_get_best_spill_node(struct ra_graph *g); #ifdef __cplusplus } // extern "C" #endif + +#endif /* REGISTER_ALLOCATE_H */