Using the common NIR stuff.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
for (unsigned i = 0; i < 8; ++i)
agx_trap(&_b);
- unsigned block_source_count = 0;
-
- /* Name blocks now that we're done emitting so the order is consistent */
+ /* Index blocks now that we're done emitting so the order is consistent */
agx_foreach_block(ctx, block)
- block->name = block_source_count++;
+ block->index = ctx->num_blocks++;
if (agx_debug & AGX_DBG_SHADERS && !skip_internal)
agx_print_shader(ctx, stdout);
#include "util/u_math.h"
#include "util/half_float.h"
#include "util/u_dynarray.h"
+#include "util/u_worklist.h"
#include "agx_compile.h"
#include "agx_opcodes.h"
#include "agx_minifloat.h"
struct list_head instructions;
/* Index of the block in source order */
- unsigned name;
+ unsigned index;
/* Control flow graph */
struct agx_block *successors[2];
/* Place to start pushing new values */
unsigned push_base;
+ /* Maximum block index */
+ unsigned num_blocks;
+
/* For creating temporaries */
unsigned alloc;
return last;
}
+#define agx_worklist_init(ctx, w) u_worklist_init(w, ctx->num_blocks, ctx)
+#define agx_worklist_push_head(w, block) u_worklist_push_head(w, block, index)
+#define agx_worklist_push_tail(w, block) u_worklist_push_tail(w, block, index)
+#define agx_worklist_peek_head(w) u_worklist_peek_head(w, agx_block, index)
+#define agx_worklist_pop_head(w) u_worklist_pop_head( w, agx_block, index)
+#define agx_worklist_peek_tail(w) u_worklist_peek_tail(w, agx_block, index)
+#define agx_worklist_pop_tail(w) u_worklist_pop_tail( w, agx_block, index)
+
/* Like in NIR, for use with the builder */
enum agx_cursor_option {
void
agx_print_block(agx_block *block, FILE *fp)
{
- fprintf(fp, "block%u {\n", block->name);
+ fprintf(fp, "block%u {\n", block->index);
agx_foreach_instr_in_block(block, ins)
agx_print_instr(ins, fp);
fprintf(fp, " -> ");
agx_foreach_successor(block, succ)
- fprintf(fp, "block%u ", succ->name);
+ fprintf(fp, "block%u ", succ->index);
}
if (block->predecessors.size) {
fprintf(fp, " from");
agx_foreach_predecessor(block, pred)
- fprintf(fp, " block%u", (*pred)->name);
+ fprintf(fp, " block%u", (*pred)->index);
}
fprintf(fp, "\n\n");