diff --git a/src/asahi/compiler/agx_compiler.h b/src/asahi/compiler/agx_compiler.h index a9d818d83c6..02030f09ac6 100644 --- a/src/asahi/compiler/agx_compiler.h +++ b/src/asahi/compiler/agx_compiler.h @@ -303,6 +303,9 @@ typedef struct agx_block { /* Liveness analysis results */ BITSET_WORD *live_in; BITSET_WORD *live_out; + + /* Offset of the block in the emitted binary */ + off_t offset; } agx_block; typedef struct { diff --git a/src/asahi/compiler/agx_pack.c b/src/asahi/compiler/agx_pack.c index c61ff43536a..f75d90dc478 100644 --- a/src/asahi/compiler/agx_pack.c +++ b/src/asahi/compiler/agx_pack.c @@ -552,6 +552,13 @@ agx_pack_instr(struct util_dynarray *emission, agx_instr *I) void agx_pack(agx_context *ctx, struct util_dynarray *emission) { - agx_foreach_instr_global(ctx, ins) - agx_pack_instr(emission, ins); + agx_foreach_block(ctx, block) { + /* Relative to the start of the binary, the block begins at the current + * number of bytes emitted */ + block->offset = emission->size; + + agx_foreach_instr_in_block(block, ins) { + agx_pack_instr(emission, ins); + } + } }