diff --git a/src/util/register_allocate.c b/src/util/register_allocate.c index e44c509643a..8c3296c342e 100644 --- a/src/util/register_allocate.c +++ b/src/util/register_allocate.c @@ -282,6 +282,21 @@ ra_class_add_reg(struct ra_class *class, unsigned int r) class->p++; } +/** + * Overrides the P value of a register class to be below the + * automatically calculated one in order to force optimistic + * allocation above this threshold even for nodes that are trivially + * colorable, which can be used to reduce the register requirement of + * programs on platforms where increasing register use imposes limits + * on thread parallelism. + */ +void +ra_class_override_p(struct ra_class *class, unsigned int p) +{ + assert(p <= class->p); + class->p = p; +} + /** * Returns true if the register belongs to the given class. */ diff --git a/src/util/register_allocate.h b/src/util/register_allocate.h index 14f2be4023a..d580fb249fe 100644 --- a/src/util/register_allocate.h +++ b/src/util/register_allocate.h @@ -67,6 +67,7 @@ ra_add_transitive_reg_pair_conflict(struct ra_regs *regs, void ra_make_reg_conflicts_transitive(struct ra_regs *regs, unsigned int reg); void ra_class_add_reg(struct ra_class *c, unsigned int reg); +void ra_class_override_p(struct ra_class *c, unsigned int p); struct ra_class *ra_get_class_from_index(struct ra_regs *regs, unsigned int c); void ra_set_finalize(struct ra_regs *regs, unsigned int **conflicts);