-
- /* List of midgard_block */
- struct set *work_list = _mesa_set_create(ctx,
- _mesa_hash_pointer,
- _mesa_key_pointer_equal);
-
- /* Allocate */
-
- mir_foreach_block(ctx, block) {
- block->live_in = calloc(ctx->temp_count, sizeof(uint16_t));
- block->live_out = calloc(ctx->temp_count, sizeof(uint16_t));
- }
-
- /* Initialize the work list with the exit block */
- struct set_entry *cur;
-
- midgard_block *exit = mir_exit_block(ctx);
- cur = _mesa_set_add(work_list, exit);
-
- /* Iterate the work list */
-
- do {
- /* Pop off a block */
- midgard_block *blk = (struct midgard_block *) cur->key;
- _mesa_set_remove(work_list, cur);
-
- /* Update its liveness information */
- bool progress = liveness_block_update(ctx, blk);
-
- /* If we made progress, we need to process the predecessors */
-
- if (progress || !blk->visited) {
- mir_foreach_predecessor(blk, pred)
- _mesa_set_add(work_list, pred);
- }
-
- blk->visited = true;
- } while((cur = _mesa_set_next_entry(work_list, NULL)) != NULL);