From 1580865a8c576f386c40c3f346636132d720654b Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Sun, 29 Jun 2014 18:11:29 -0700 Subject: i965: Move assembly annotation functions to intel_asm_annotation.c. It's C. Compile it as such. Reviewed-by: Topi Pohjolainen --- src/mesa/drivers/dri/i965/brw_shader.cpp | 55 ---------------------- src/mesa/drivers/dri/i965/brw_shader.h | 6 --- src/mesa/drivers/dri/i965/intel_asm_annotation.c | 58 ++++++++++++++++++++++++ src/mesa/drivers/dri/i965/intel_asm_annotation.h | 9 ++++ 4 files changed, 67 insertions(+), 61 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp index d7e127b9659..318802b79e8 100644 --- a/src/mesa/drivers/dri/i965/brw_shader.cpp +++ b/src/mesa/drivers/dri/i965/brw_shader.cpp @@ -822,58 +822,3 @@ backend_visitor::assign_common_binding_table_offsets(uint32_t next_binding_table /* prog_data->base.binding_table.size will be set by brw_mark_surface_used. */ } - -void annotate(struct brw_context *brw, - struct annotation_info *annotation, cfg_t *cfg, - backend_instruction *inst, unsigned offset) -{ - if (annotation->ann_size <= annotation->ann_count) { - 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; - } - - struct annotation *ann = &annotation->ann[annotation->ann_count++]; - ann->offset = offset; - if ((INTEL_DEBUG & DEBUG_NO_ANNOTATION) == 0) { - ann->ir = inst->ir; - ann->annotation = inst->annotation; - } - - if (cfg->blocks[annotation->cur_block]->start == inst) { - ann->block_start = cfg->blocks[annotation->cur_block]; - } - - /* There is no hardware DO instruction on Gen6+, so since DO always - * starts a basic block, we need to set the .block_start of the next - * instruction's annotation with a pointer to the bblock started by - * the DO. - * - * 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) { - annotation->ann_count--; - } - - if (cfg->blocks[annotation->cur_block]->end == inst) { - ann->block_end = cfg->blocks[annotation->cur_block]; - annotation->cur_block++; - } -} - -void -annotation_finalize(struct annotation_info *annotation, - unsigned next_inst_offset) -{ - if (!annotation->ann_count) - return; - - if (annotation->ann_count == annotation->ann_size) { - annotation->ann = reralloc(annotation->mem_ctx, annotation->ann, - struct annotation, annotation->ann_size + 1); - } - annotation->ann[annotation->ann_count].offset = next_inst_offset; -} diff --git a/src/mesa/drivers/dri/i965/brw_shader.h b/src/mesa/drivers/dri/i965/brw_shader.h index a9224878a4d..cfaea9e5b80 100644 --- a/src/mesa/drivers/dri/i965/brw_shader.h +++ b/src/mesa/drivers/dri/i965/brw_shader.h @@ -26,7 +26,6 @@ #include "brw_defines.h" #include "main/compiler.h" #include "glsl/ir.h" -#include "intel_asm_annotation.h" #pragma once @@ -173,11 +172,6 @@ public: uint32_t brw_texture_offset(struct gl_context *ctx, ir_constant *offset); -void annotate(struct brw_context *brw, - struct annotation_info *annotation, cfg_t *cfg, - backend_instruction *inst, unsigned offset); -void annotation_finalize(struct annotation_info *annotation, unsigned offset); - #endif /* __cplusplus */ enum brw_reg_type brw_type_for_base_type(const struct glsl_type *type); diff --git a/src/mesa/drivers/dri/i965/intel_asm_annotation.c b/src/mesa/drivers/dri/i965/intel_asm_annotation.c index a7bb2e170d0..4717bafd341 100644 --- a/src/mesa/drivers/dri/i965/intel_asm_annotation.c +++ b/src/mesa/drivers/dri/i965/intel_asm_annotation.c @@ -23,9 +23,12 @@ #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" void dump_assembly(void *assembly, int num_annotations, struct annotation *annotation, @@ -87,3 +90,58 @@ dump_assembly(void *assembly, int num_annotations, struct annotation *annotation } fprintf(stderr, "\n"); } + +void annotate(struct brw_context *brw, + struct annotation_info *annotation, struct cfg_t *cfg, + struct backend_instruction *inst, unsigned offset) +{ + if (annotation->ann_size <= annotation->ann_count) { + 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; + } + + struct annotation *ann = &annotation->ann[annotation->ann_count++]; + ann->offset = offset; + if ((INTEL_DEBUG & DEBUG_NO_ANNOTATION) == 0) { + ann->ir = inst->ir; + ann->annotation = inst->annotation; + } + + if (cfg->blocks[annotation->cur_block]->start == inst) { + ann->block_start = cfg->blocks[annotation->cur_block]; + } + + /* There is no hardware DO instruction on Gen6+, so since DO always + * starts a basic block, we need to set the .block_start of the next + * instruction's annotation with a pointer to the bblock started by + * the DO. + * + * 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) { + annotation->ann_count--; + } + + if (cfg->blocks[annotation->cur_block]->end == inst) { + ann->block_end = cfg->blocks[annotation->cur_block]; + annotation->cur_block++; + } +} + +void +annotation_finalize(struct annotation_info *annotation, + unsigned next_inst_offset) +{ + if (!annotation->ann_count) + return; + + if (annotation->ann_count == annotation->ann_size) { + annotation->ann = reralloc(annotation->mem_ctx, annotation->ann, + struct annotation, annotation->ann_size + 1); + } + annotation->ann[annotation->ann_count].offset = next_inst_offset; +} diff --git a/src/mesa/drivers/dri/i965/intel_asm_annotation.h b/src/mesa/drivers/dri/i965/intel_asm_annotation.h index 50ed21a3f7b..79f337211b1 100644 --- a/src/mesa/drivers/dri/i965/intel_asm_annotation.h +++ b/src/mesa/drivers/dri/i965/intel_asm_annotation.h @@ -31,6 +31,8 @@ extern "C" { struct bblock_t; struct brw_context; struct gl_program; +struct backend_instruction; +struct cfg_t; struct annotation { int offset; @@ -60,6 +62,13 @@ void dump_assembly(void *assembly, int num_annotations, struct annotation *annotation, struct brw_context *brw, const struct gl_program *prog); +void +annotate(struct brw_context *brw, + struct annotation_info *annotation, struct cfg_t *cfg, + struct backend_instruction *inst, unsigned offset); +void +annotation_finalize(struct annotation_info *annotation, unsigned offset); + #ifdef __cplusplus } /* extern "C" */ #endif -- cgit v1.2.3