From 3ddff0fa8b1b597110247d377c84869b74f8f0ea Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 6 Jan 2021 14:23:23 -0500 Subject: [PATCH] pan/bi: Flatten block lists From Midgard scheduler. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Boris Brezillon Part-of: --- src/panfrost/bifrost/bi_schedule.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/panfrost/bifrost/bi_schedule.c b/src/panfrost/bifrost/bi_schedule.c index cb7b5ea7620..e9707203d98 100644 --- a/src/panfrost/bifrost/bi_schedule.c +++ b/src/panfrost/bifrost/bi_schedule.c @@ -136,6 +136,25 @@ bi_lower_cubeface(bi_context *ctx, return cubeface1; } +/* Flatten linked list to array for O(1) indexing */ + +static bi_instr ** +bi_flatten_block(bi_block *block, unsigned *len) +{ + if (list_is_empty(&block->base.instructions)) + return NULL; + + *len = list_length(&block->base.instructions); + bi_instr **instructions = malloc(sizeof(bi_instr *) * (*len)); + + unsigned i = 0; + + bi_foreach_instr_in_block(block, ins) + instructions[i++] = ins; + + return instructions; +} + /* Determines messsage type by checking the table and a few special cases. Only * case missing is tilebuffer instructions that access depth/stencil, which * require a Z_STENCIL message (to implement -- 2.34.1