[Mesa-dev] [PATCH 2/3] ra: Create a reg_belongs_to_class() helper function.

Christoph Brill egore911 at egore911.de
Tue Mar 18 00:43:33 PDT 2014


It's a bit picky as compilers are likely to detect this themselves, but an
'inline' might be nice.

Nonetheless I'm in favor for everything that improves code readability, so:

Reviewed-By: Christoph Brill <egore911 at gmail.com>

Am 17.03.2014 21:32 schrieb "Kenneth Graunke" <kenneth at whitecape.org>:
>
> This is a little easier to read.
>
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  src/mesa/program/register_allocate.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/program/register_allocate.c
b/src/mesa/program/register_allocate.c
> index edde730..c763b96 100644
> --- a/src/mesa/program/register_allocate.c
> +++ b/src/mesa/program/register_allocate.c
> @@ -284,6 +284,15 @@ ra_class_add_reg(struct ra_regs *regs, unsigned int
c, unsigned int r)
>  }
>
>  /**
> + * Returns true if the register belongs to the given class.
> + */
> +static bool
> +reg_belongs_to_class(unsigned int r, struct ra_class *c)
> +{
> +   return c->regs[r];
> +}
> +
> +/**
>   * Must be called after all conflicts and register classes have been
>   * set up and before the register set is used for allocation.
>   * To avoid costly q value computation, use the q_values paramater
> @@ -319,7 +328,7 @@ ra_set_finalize(struct ra_regs *regs, unsigned int
**q_values)
>             int conflicts = 0;
>             int i;
>
> -           if (!regs->classes[c]->regs[rc])
> +            if (!reg_belongs_to_class(rc, regs->classes[c]))
>                continue;
>
>             for (i = 0; i < regs->regs[rc].num_conflicts; i++) {
> @@ -479,7 +488,7 @@ ra_select(struct ra_graph *g)
>         */
>        for (ri = 0; ri < g->regs->count; ri++) {
>           r = (start_search_reg + ri) % g->regs->count;
> -        if (!c->regs[r])
> +         if (!reg_belongs_to_class(r, c))
>             continue;
>
>          /* Check if any of our neighbors conflict with this register
choice. */
> --
> 1.9.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140318/3ddd8185/attachment.html>


More information about the mesa-dev mailing list