diff options
author | Matt Turner <[email protected]> | 2017-11-15 17:08:42 -0800 |
---|---|---|
committer | Matt Turner <[email protected]> | 2017-11-17 12:14:38 -0800 |
commit | 4f82b17287194ca7d10816f6cfe4712a3e0a03fc (patch) | |
tree | 7e2bb056e5c389643e9338e4359e5aae9ab49f92 /src/intel/compiler/brw_eu_compact.c | |
parent | f80e97346b0da9fab3d60b46bdcf0a0d702f97c9 (diff) |
i965: Rewrite disassembly annotation code
The old code used an array to store each "instruction group" (the new,
better name than the old overloaded "annotation"), and required a
memmove() to shift elements over in the array when we needed to split a
group so that we could add an error message. This was confusing and
difficult to get right, not the least of which was because the array
has a tail sentinel not included in .ann_count.
Instead use a linked list, a data structure made for efficient
insertion.
Acked-by: Samuel Iglesias Gonsálvez <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/intel/compiler/brw_eu_compact.c')
-rw-r--r-- | src/intel/compiler/brw_eu_compact.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/intel/compiler/brw_eu_compact.c b/src/intel/compiler/brw_eu_compact.c index a9da46957a5..d2edb5586c2 100644 --- a/src/intel/compiler/brw_eu_compact.c +++ b/src/intel/compiler/brw_eu_compact.c @@ -1486,7 +1486,7 @@ brw_init_compaction_tables(const struct gen_device_info *devinfo) void brw_compact_instructions(struct brw_codegen *p, int start_offset, - int num_annotations, struct annotation *annotation) + struct disasm_info *disasm) { if (unlikely(INTEL_DEBUG & DEBUG_NO_COMPACTION)) return; @@ -1501,7 +1501,7 @@ brw_compact_instructions(struct brw_codegen *p, int start_offset, /* For an instruction at byte offset 8*i after compaction, this was its IP * (in 16-byte units) before compaction. */ - int old_ip[(p->next_insn_offset - start_offset) / sizeof(brw_compact_inst)]; + int old_ip[(p->next_insn_offset - start_offset) / sizeof(brw_compact_inst) + 1]; if (devinfo->gen == 4 && !devinfo->is_g4x) return; @@ -1556,6 +1556,12 @@ brw_compact_instructions(struct brw_codegen *p, int start_offset, } } + /* Add an entry for the ending offset of the program. This greatly + * simplifies the linked list walk at the end of the function. + */ + old_ip[offset / sizeof(brw_compact_inst)] = + (p->next_insn_offset - start_offset) / sizeof(brw_inst); + /* Fix up control flow offsets. */ p->next_insn_offset = start_offset + offset; for (offset = 0; offset < p->next_insn_offset - start_offset; @@ -1651,21 +1657,21 @@ brw_compact_instructions(struct brw_codegen *p, int start_offset, } p->nr_insn = p->next_insn_offset / sizeof(brw_inst); - /* Update the instruction offsets for each annotation. */ - if (annotation) { - for (int offset = 0, i = 0; i < num_annotations; i++) { + /* Update the instruction offsets for each group. */ + if (disasm) { + int offset = 0; + + foreach_list_typed(struct inst_group, group, link, &disasm->group_list) { while (start_offset + old_ip[offset / sizeof(brw_compact_inst)] * - sizeof(brw_inst) != annotation[i].offset) { + sizeof(brw_inst) != group->offset) { assert(start_offset + old_ip[offset / sizeof(brw_compact_inst)] * - sizeof(brw_inst) < annotation[i].offset); + sizeof(brw_inst) < group->offset); offset = next_offset(devinfo, store, offset); } - annotation[i].offset = start_offset + offset; + group->offset = start_offset + offset; offset = next_offset(devinfo, store, offset); } - - annotation[num_annotations].offset = p->next_insn_offset; } } |