X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fdrivers%2Fdri%2Fi965%2Fintel_asm_annotation.c;h=b01490a1822e341f02d3eae0377b7b452ca47566;hb=ed65e6ef49e17e9cae93a8f98e2968346de2bc6e;hp=953a60ad1ecc6c6b6a307c87ae56f66d184d0346;hpb=a3d0ccb037082f3aa66bd558dfbe89f63a6eedd3;p=mesa.git diff --git a/src/mesa/drivers/dri/i965/intel_asm_annotation.c b/src/mesa/drivers/dri/i965/intel_asm_annotation.c index 953a60ad1ec..b01490a1822 100644 --- a/src/mesa/drivers/dri/i965/intel_asm_annotation.c +++ b/src/mesa/drivers/dri/i965/intel_asm_annotation.c @@ -23,16 +23,13 @@ #include "brw_cfg.h" #include "brw_eu.h" -#include "brw_context.h" #include "intel_debug.h" #include "intel_asm_annotation.h" -#include "program/prog_print.h" -#include "program/prog_instruction.h" -#include "main/macros.h" +#include "compiler/nir/nir.h" void dump_assembly(void *assembly, int num_annotations, struct annotation *annotation, - struct brw_context *brw, const struct gl_program *prog) + const struct gen_device_info *devinfo) { const char *last_annotation_string = NULL; const void *last_annotation_ir = NULL; @@ -55,17 +52,7 @@ dump_assembly(void *assembly, int num_annotations, struct annotation *annotation last_annotation_ir = annotation[i].ir; if (last_annotation_ir) { fprintf(stderr, " "); - if (!prog->Instructions) - fprint_ir(stderr, annotation[i].ir); - else { - const struct prog_instruction *pi = - (const struct prog_instruction *)annotation[i].ir; - fprintf(stderr, "%d: ", - (int)(pi - prog->Instructions)); - _mesa_fprint_instruction_opt(stderr, - pi, - 0, PROG_PRINT_DEBUG, NULL); - } + nir_print_instr(annotation[i].ir, stderr); fprintf(stderr, "\n"); } } @@ -76,7 +63,11 @@ dump_assembly(void *assembly, int num_annotations, struct annotation *annotation fprintf(stderr, " %s\n", last_annotation_string); } - brw_disassemble(brw, assembly, start_offset, end_offset, stderr); + 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); @@ -91,9 +82,8 @@ dump_assembly(void *assembly, int num_annotations, struct annotation *annotation fprintf(stderr, "\n"); } -void annotate(struct brw_context *brw, - 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->ann_size <= annotation->ann_count) { int old_size = annotation->ann_size; @@ -101,20 +91,33 @@ void annotate(struct brw_context *brw, 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 gen_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_NO_ANNOTATION) == 0) { + if ((INTEL_DEBUG & DEBUG_ANNOTATION) != 0) { ann->ir = inst->ir; ann->annotation = inst->annotation; } - if (cfg->blocks[annotation->cur_block]->start == inst) { + if (bblock_start(cfg->blocks[annotation->cur_block]) == inst) { ann->block_start = cfg->blocks[annotation->cur_block]; } @@ -126,11 +129,11 @@ void annotate(struct brw_context *brw, * There's also only complication from emitting an annotation without * a corresponding hardware instruction to disassemble. */ - if (brw->gen >= 6 && inst->opcode == BRW_OPCODE_DO) { + if (devinfo->gen >= 6 && inst->opcode == BRW_OPCODE_DO) { annotation->ann_count--; } - if (cfg->blocks[annotation->cur_block]->end == inst) { + if (bblock_end(cfg->blocks[annotation->cur_block]) == inst) { ann->block_end = cfg->blocks[annotation->cur_block]; annotation->cur_block++; } @@ -149,3 +152,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; + + assume(annotation->ann_count > 0); + + 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; + } + + if (ann->error) + ralloc_strcat(&ann->error, error); + else + ann->error = ralloc_strdup(annotation->mem_ctx, error); +}