From 06f52fe0b1a219682317035c831d60824fecce55 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 16 Dec 2020 12:56:45 -0500 Subject: [PATCH] pan/bi: Add node_to_index helper To invert index_to_node for RA. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/compiler.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h index 4f1408e73e9..aa980c49707 100644 --- a/src/panfrost/bifrost/compiler.h +++ b/src/panfrost/bifrost/compiler.h @@ -778,6 +778,15 @@ bi_get_node(bi_index index) return (index.value << 1) | index.reg; } +static inline bi_index +bi_node_to_index(unsigned node, unsigned node_count) +{ + assert(node < node_count); + assert(node_count < ~0); + + return bi_get_index(node >> 1, node & PAN_IS_REG, 0); +} + /* Iterators for Bifrost IR */ #define bi_foreach_block(ctx, v) \