diff options
author | Alyssa Rosenzweig <[email protected]> | 2019-08-31 11:08:39 -0700 |
---|---|---|
committer | Alyssa Rosenzweig <[email protected]> | 2019-09-30 08:40:13 -0400 |
commit | adda411263217e86345f039aef730665c73732ea (patch) | |
tree | fb1991e5bbbe866e300978b63a7094049210318b /src/panfrost | |
parent | 0ecfcbf46225bfb14f92a515ca2140ad2cbc4646 (diff) |
pan/midgard: Add flatten_mir helper
We would like to flatten a linked list of midgard_instructions into an
array of midgard_instruction pointers on the heap.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src/panfrost')
-rw-r--r-- | src/panfrost/midgard/midgard_schedule.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/panfrost/midgard/midgard_schedule.c b/src/panfrost/midgard/midgard_schedule.c index 2ed25da2e0d..75295b5d123 100644 --- a/src/panfrost/midgard/midgard_schedule.c +++ b/src/panfrost/midgard/midgard_schedule.c @@ -620,6 +620,28 @@ schedule_bundle(compiler_context *ctx, midgard_block *block, midgard_instruction return bundle; } +/* We would like to flatten the linked list of midgard_instructions in a bundle + * to an array of pointers on the heap for easy indexing */ + +static midgard_instruction ** +flatten_mir(midgard_block *block, unsigned *len) +{ + *len = list_length(&block->instructions); + + if (!(*len)) + return NULL; + + midgard_instruction **instructions = + calloc(sizeof(midgard_instruction *), *len); + + unsigned i = 0; + + mir_foreach_instr_in_block(block, ins) + instructions[i++] = ins; + + return instructions; +} + /* Schedule a single block by iterating its instruction to create bundles. * While we go, tally about the bundle sizes to compute the block size. */ |