agx: Track block offsets

For fixing branch offsets.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11023>
This commit is contained in:
Alyssa Rosenzweig
2021-05-24 19:47:58 -04:00
parent f7918ebc82
commit 6f54385b0a
2 changed files with 12 additions and 2 deletions
+3
View File
@@ -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 {
+9 -2
View File
@@ -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);
}
}
}