summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2015-10-21 15:23:10 -0700
committerMatt Turner <[email protected]>2015-11-12 11:00:10 -0800
commit34ed45557e9b8a834af2816e774165a0ee7acdd2 (patch)
tree2633928d03ba0614f7c560810df9028e8c28f54a /src/mesa
parenta280e83d71bb046098ed5380cb053318f9e8cf8e (diff)
i965: Add annotation_insert_error() and support for printing errors.
Will allow annotations to contain error messages (indicating an instruction violates a rule for instance) that are printed after the disassembly of the block. Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/i965/intel_asm_annotation.c71
-rw-r--r--src/mesa/drivers/dri/i965/intel_asm_annotation.h7
2 files changed, 71 insertions, 7 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_asm_annotation.c b/src/mesa/drivers/dri/i965/intel_asm_annotation.c
index fe9d80a5e67..52878fde43e 100644
--- a/src/mesa/drivers/dri/i965/intel_asm_annotation.c
+++ b/src/mesa/drivers/dri/i965/intel_asm_annotation.c
@@ -69,6 +69,10 @@ dump_assembly(void *assembly, int num_annotations, struct annotation *annotation
brw_disassemble(devinfo, assembly, start_offset, end_offset, stderr);
+ if (annotation[i].error) {
+ fputs(annotation[i].error, stderr);
+ }
+
if (annotation[i].block_end) {
fprintf(stderr, " END B%d", annotation[i].block_end->num);
foreach_list_typed(struct bblock_link, successor_link, link,
@@ -82,25 +86,34 @@ dump_assembly(void *assembly, int num_annotations, struct annotation *annotation
fprintf(stderr, "\n");
}
-void annotate(const struct brw_device_info *devinfo,
- struct annotation_info *annotation, const struct cfg_t *cfg,
- struct backend_instruction *inst, unsigned offset)
+static bool
+annotation_array_ensure_space(struct annotation_info *annotation)
{
- if (annotation->mem_ctx == NULL)
- annotation->mem_ctx = ralloc_context(NULL);
-
if (annotation->ann_size <= annotation->ann_count) {
int old_size = annotation->ann_size;
annotation->ann_size = MAX2(1024, annotation->ann_size * 2);
annotation->ann = reralloc(annotation->mem_ctx, annotation->ann,
struct annotation, annotation->ann_size);
if (!annotation->ann)
- return;
+ return false;
memset(annotation->ann + old_size, 0,
(annotation->ann_size - old_size) * sizeof(struct annotation));
}
+ return true;
+}
+
+void annotate(const struct brw_device_info *devinfo,
+ struct annotation_info *annotation, const struct cfg_t *cfg,
+ struct backend_instruction *inst, unsigned offset)
+{
+ if (annotation->mem_ctx == NULL)
+ annotation->mem_ctx = ralloc_context(NULL);
+
+ if (!annotation_array_ensure_space(annotation))
+ return;
+
struct annotation *ann = &annotation->ann[annotation->ann_count++];
ann->offset = offset;
if ((INTEL_DEBUG & DEBUG_ANNOTATION) != 0) {
@@ -156,3 +169,47 @@ annotation_finalize(struct annotation_info *annotation,
}
annotation->ann[annotation->ann_count].offset = next_inst_offset;
}
+
+void
+annotation_insert_error(struct annotation_info *annotation, unsigned offset,
+ const char *error)
+{
+ struct annotation *ann;
+
+ if (!annotation->ann_count)
+ return;
+
+ /* We may have to split an annotation, so ensure we have enough space
+ * allocated for that case up front.
+ */
+ if (!annotation_array_ensure_space(annotation))
+ return;
+
+ for (int i = 0; i < annotation->ann_count; i++) {
+ struct annotation *cur = &annotation->ann[i];
+ struct annotation *next = &annotation->ann[i + 1];
+ ann = cur;
+
+ if (next->offset <= offset)
+ continue;
+
+ if (offset + sizeof(brw_inst) != next->offset) {
+ memmove(next, cur,
+ (annotation->ann_count - i + 2) * sizeof(struct annotation));
+ cur->error = NULL;
+ cur->error_length = 0;
+ cur->block_end = NULL;
+ next->offset = offset + sizeof(brw_inst);
+ next->block_start = NULL;
+ annotation->ann_count++;
+ }
+ break;
+ }
+
+ assume(ann != NULL);
+
+ if (ann->error)
+ ralloc_strcat(&ann->error, error);
+ else
+ ann->error = ralloc_strdup(annotation->mem_ctx, error);
+}
diff --git a/src/mesa/drivers/dri/i965/intel_asm_annotation.h b/src/mesa/drivers/dri/i965/intel_asm_annotation.h
index 6c72326f058..662a4b4e0f7 100644
--- a/src/mesa/drivers/dri/i965/intel_asm_annotation.h
+++ b/src/mesa/drivers/dri/i965/intel_asm_annotation.h
@@ -37,6 +37,9 @@ struct cfg_t;
struct annotation {
int offset;
+ size_t error_length;
+ char *error;
+
/* Pointers to the basic block in the CFG if the instruction group starts
* or ends a basic block.
*/
@@ -69,6 +72,10 @@ annotate(const struct brw_device_info *devinfo,
void
annotation_finalize(struct annotation_info *annotation, unsigned offset);
+void
+annotation_insert_error(struct annotation_info *annotation, unsigned offset,
+ const char *error);
+
#ifdef __cplusplus
} /* extern "C" */
#endif