[Mesa-dev] [PATCH 1/2] i965: Make bblock_t::next and friends return NULL at sentinels.
Jason Ekstrand
jason at jlekstrand.net
Mon Apr 4 07:18:35 UTC 2016
This is what NIR does and I think it's rather sensible.
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
On Sun, Apr 3, 2016 at 10:56 PM, Kenneth Graunke <kenneth at whitecape.org>
wrote:
> The bblock_t::prev/prev_const/next/next_const API returns bblock_t
> pointers, rather than exec_nodes. So it's a bit surprising.
>
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
> src/mesa/drivers/dri/i965/brw_cfg.h | 12 ++++++++++++
> src/mesa/drivers/dri/i965/brw_shader.cpp | 2 +-
> 2 files changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_cfg.h
> b/src/mesa/drivers/dri/i965/brw_cfg.h
> index 405020b..5b770aa 100644
> --- a/src/mesa/drivers/dri/i965/brw_cfg.h
> +++ b/src/mesa/drivers/dri/i965/brw_cfg.h
> @@ -121,24 +121,36 @@ bblock_end_const(const struct bblock_t *block)
> static inline struct bblock_t *
> bblock_next(struct bblock_t *block)
> {
> + if (exec_node_is_tail_sentinel(block->link.next))
> + return NULL;
> +
> return (struct bblock_t *)block->link.next;
> }
>
> static inline const struct bblock_t *
> bblock_next_const(const struct bblock_t *block)
> {
> + if (exec_node_is_tail_sentinel(block->link.next))
> + return NULL;
> +
> return (const struct bblock_t *)block->link.next;
> }
>
> static inline struct bblock_t *
> bblock_prev(struct bblock_t *block)
> {
> + if (exec_node_is_head_sentinel(block->link.prev))
> + return NULL;
> +
> return (struct bblock_t *)block->link.prev;
> }
>
> static inline const struct bblock_t *
> bblock_prev_const(const struct bblock_t *block)
> {
> + if (exec_node_is_head_sentinel(block->link.prev))
> + return NULL;
> +
> return (const struct bblock_t *)block->link.prev;
> }
>
> diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp
> b/src/mesa/drivers/dri/i965/brw_shader.cpp
> index 736deb4..376cb25 100644
> --- a/src/mesa/drivers/dri/i965/brw_shader.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
> @@ -938,7 +938,7 @@ static void
> adjust_later_block_ips(bblock_t *start_block, int ip_adjustment)
> {
> for (bblock_t *block_iter = start_block->next();
> - !block_iter->link.is_tail_sentinel();
> + block_iter;
> block_iter = block_iter->next()) {
> block_iter->start_ip += ip_adjustment;
> block_iter->end_ip += ip_adjustment;
> --
> 2.7.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160404/f795a9cb/attachment.html>
More information about the mesa-dev
mailing list