From 944ee9e088c00b65427e9d94872e5968d501b2cf Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Tue, 17 Sep 2024 13:28:32 +0200 Subject: [PATCH] pan/cs: Don't use a list for our block stack MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don't need a double-linked list to manage our block stack. Use a single-link list instead, which simplifies things a bit and hopefully lets the compiler optimize things a bit more. Signed-off-by: Boris Brezillon Reviewed-by: Lars-Ivar Hesselberg Simonsen Reviewed-by: Louis-Francis Ratté-Boulianne Part-of: --- src/panfrost/lib/genxml/cs_builder.h | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/panfrost/lib/genxml/cs_builder.h b/src/panfrost/lib/genxml/cs_builder.h index 2ba130f67db..e84a56dcf48 100644 --- a/src/panfrost/lib/genxml/cs_builder.h +++ b/src/panfrost/lib/genxml/cs_builder.h @@ -30,7 +30,6 @@ #include "gen_macros.h" #include "util/bitset.h" -#include "util/list.h" #include "util/u_dynarray.h" /* @@ -122,7 +121,7 @@ struct cs_chunk { */ struct cs_block { /* Used to insert the block in the block stack. */ - struct list_head node; + struct cs_block *next; }; #define CS_LABEL_INVALID_POS ~0u @@ -161,7 +160,7 @@ struct cs_builder { * jump in the middle. */ struct { - struct list_head stack; + struct cs_block *stack; struct util_dynarray instrs; } blocks; @@ -192,7 +191,6 @@ cs_builder_init(struct cs_builder *b, const struct cs_builder_conf *conf, */ b->conf.nr_kernel_registers = MAX2(b->conf.nr_kernel_registers, 3); - list_inithead(&b->blocks.stack); util_dynarray_init(&b->blocks.instrs, NULL); } @@ -430,9 +428,7 @@ cs_extract32(struct cs_builder *b, struct cs_index idx, unsigned word) static inline struct cs_block * cs_cur_block(struct cs_builder *b) { - return list_is_empty(&b->blocks.stack) - ? NULL - : list_last_entry(&b->blocks.stack, struct cs_block, node); + return b->blocks.stack; } #define JUMP_SEQ_INSTR_COUNT 4 @@ -623,7 +619,8 @@ cs_move48_to(struct cs_builder *b, struct cs_index dest, uint64_t imm) static inline void cs_block_start(struct cs_builder *b, struct cs_block *block) { - list_addtail(&block->node, &b->blocks.stack); + block->next = b->blocks.stack; + b->blocks.stack = block; } static inline void @@ -631,9 +628,9 @@ cs_block_end(struct cs_builder *b, struct cs_block *block) { assert(cs_cur_block(b) == block); - list_del(&block->node); + b->blocks.stack = block->next; - if (!list_is_empty(&b->blocks.stack)) + if (cs_cur_block(b) != NULL) return; uint32_t num_instrs =