summaryrefslogtreecommitdiffstats
path: root/src/intel/tools
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2017-11-15 17:08:42 -0800
committerMatt Turner <[email protected]>2017-11-17 12:14:38 -0800
commit4f82b17287194ca7d10816f6cfe4712a3e0a03fc (patch)
tree7e2bb056e5c389643e9338e4359e5aae9ab49f92 /src/intel/tools
parentf80e97346b0da9fab3d60b46bdcf0a0d702f97c9 (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/tools')
-rw-r--r--src/intel/tools/disasm.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/intel/tools/disasm.c b/src/intel/tools/disasm.c
index 251acd313dc..50915795224 100644
--- a/src/intel/tools/disasm.c
+++ b/src/intel/tools/disasm.c
@@ -76,34 +76,35 @@ gen_disasm_disassemble(struct gen_disasm *disasm, void *assembly,
struct gen_device_info *devinfo = &disasm->devinfo;
int end = gen_disasm_find_end(disasm, assembly, start);
- /* Make a dummy annotation structure that brw_validate_instructions
+ /* Make a dummy disasm structure that brw_validate_instructions
* can work from.
*/
- struct annotation_info annotation_info = {
- .ann_count = 1,
- .ann_size = 2,
- };
- annotation_info.mem_ctx = ralloc_context(NULL);
- annotation_info.ann = rzalloc_array(annotation_info.mem_ctx,
- struct annotation,
- annotation_info.ann_size);
- annotation_info.ann[0].offset = start;
- annotation_info.ann[1].offset = end;
- brw_validate_instructions(devinfo, assembly, start, end, &annotation_info);
- struct annotation *annotation = annotation_info.ann;
-
- for (int i = 0; i < annotation_info.ann_count; i++) {
- int start_offset = annotation[i].offset;
- int end_offset = annotation[i + 1].offset;
+ struct disasm_info *disasm_info = disasm_initialize(devinfo, NULL);
+ disasm_new_inst_group(disasm_info, start);
+ disasm_new_inst_group(disasm_info, end);
+
+ brw_validate_instructions(devinfo, assembly, start, end, disasm_info);
+
+ foreach_list_typed(struct inst_group, group, link,
+ &disasm_info->group_list) {
+ struct exec_node *next_node = exec_node_get_next(&group->link);
+ if (exec_node_is_tail_sentinel(next_node))
+ break;
+
+ struct inst_group *next =
+ exec_node_data(struct inst_group, next_node, link);
+
+ int start_offset = group->offset;
+ int end_offset = next->offset;
brw_disassemble(devinfo, assembly, start_offset, end_offset, out);
- if (annotation[i].error) {
- fputs(annotation[i].error, out);
+ if (group->error) {
+ fputs(group->error, out);
}
}
- ralloc_free(annotation_info.mem_ctx);
+ ralloc_free(disasm_info);
}
struct gen_disasm *