mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 07:18:17 +02:00
intel/compiler: Merge intel_disasm.[ch] into corresponding brw files
Rename the functions to match the existing ones. Acked-by: Dylan Baker <dylan@pnwbakers.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27579>
This commit is contained in:
parent
468a0ffe9c
commit
5992185c8d
13 changed files with 110 additions and 187 deletions
|
|
@ -22,7 +22,7 @@
|
|||
*/
|
||||
|
||||
#include "common/intel_decoder.h"
|
||||
#include "intel_disasm.h"
|
||||
#include "compiler/brw_disasm.h"
|
||||
#include "util/macros.h"
|
||||
#include "util/u_debug.h"
|
||||
#include "util/u_dynarray.h"
|
||||
|
|
@ -161,10 +161,10 @@ ctx_disassemble_program(struct intel_batch_decode_ctx *ctx,
|
|||
return;
|
||||
|
||||
fprintf(ctx->fp, "\nReferenced %s:\n", name);
|
||||
intel_disassemble(ctx->isa, bo.map, 0, ctx->fp);
|
||||
brw_disassemble_with_errors(ctx->isa, bo.map, 0, ctx->fp);
|
||||
|
||||
if (ctx->shader_binary) {
|
||||
int size = intel_disassemble_find_end(ctx->isa, bo.map, 0);
|
||||
int size = brw_disassemble_find_end(ctx->isa, bo.map, 0);
|
||||
|
||||
ctx->shader_binary(ctx->user_data, short_name, addr,
|
||||
bo.map, size);
|
||||
|
|
|
|||
|
|
@ -1,111 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2014 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "compiler/brw_inst.h"
|
||||
#include "compiler/brw_disasm.h"
|
||||
#include "compiler/brw_disasm_info.h"
|
||||
#include "compiler/brw_eu.h"
|
||||
#include "compiler/brw_isa_info.h"
|
||||
|
||||
#include "intel_disasm.h"
|
||||
|
||||
static bool
|
||||
is_send(uint32_t opcode)
|
||||
{
|
||||
return (opcode == BRW_OPCODE_SEND ||
|
||||
opcode == BRW_OPCODE_SENDC ||
|
||||
opcode == BRW_OPCODE_SENDS ||
|
||||
opcode == BRW_OPCODE_SENDSC );
|
||||
}
|
||||
|
||||
int
|
||||
intel_disassemble_find_end(const struct brw_isa_info *isa,
|
||||
const void *assembly, int start)
|
||||
{
|
||||
const struct intel_device_info *devinfo = isa->devinfo;
|
||||
int offset = start;
|
||||
|
||||
/* This loop exits when send-with-EOT or when opcode is 0 */
|
||||
while (true) {
|
||||
const brw_inst *insn = assembly + offset;
|
||||
|
||||
if (brw_inst_cmpt_control(devinfo, insn)) {
|
||||
offset += 8;
|
||||
} else {
|
||||
offset += 16;
|
||||
}
|
||||
|
||||
/* Simplistic, but efficient way to terminate disasm */
|
||||
uint32_t opcode = brw_inst_opcode(isa, insn);
|
||||
if (opcode == 0 || (is_send(opcode) && brw_inst_eot(devinfo, insn))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
void
|
||||
intel_disassemble(const struct brw_isa_info *isa,
|
||||
const void *assembly, int start, FILE *out)
|
||||
{
|
||||
int end = intel_disassemble_find_end(isa, assembly, start);
|
||||
|
||||
/* Make a dummy disasm structure that brw_validate_instructions
|
||||
* can work from.
|
||||
*/
|
||||
struct disasm_info *disasm_info = disasm_initialize(isa, NULL);
|
||||
disasm_new_inst_group(disasm_info, start);
|
||||
disasm_new_inst_group(disasm_info, end);
|
||||
|
||||
brw_validate_instructions(isa, assembly, start, end, disasm_info);
|
||||
|
||||
void *mem_ctx = ralloc_context(NULL);
|
||||
const struct brw_label *root_label =
|
||||
brw_label_assembly(isa, assembly, start, end, mem_ctx);
|
||||
|
||||
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(isa, assembly, start_offset, end_offset,
|
||||
root_label, out);
|
||||
|
||||
if (group->error) {
|
||||
fputs(group->error, out);
|
||||
}
|
||||
}
|
||||
|
||||
ralloc_free(mem_ctx);
|
||||
ralloc_free(disasm_info);
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2014 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef INTEL_DISASM_H
|
||||
#define INTEL_DISASM_H
|
||||
|
||||
#include "intel/dev/intel_device_info.h"
|
||||
#include "compiler/brw_isa_info.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int intel_disassemble_find_end(const struct brw_isa_info *isa,
|
||||
const void *assembly, int start);
|
||||
|
||||
void intel_disassemble(const struct brw_isa_info *isa,
|
||||
const void *assembly, int start, FILE *out);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* INTEL_DISASM_H */
|
||||
|
|
@ -37,8 +37,6 @@ files_libintel_common = files(
|
|||
'intel_bind_timeline.h',
|
||||
'intel_buffer_alloc.h',
|
||||
'intel_decoder.h',
|
||||
'intel_disasm.c',
|
||||
'intel_disasm.h',
|
||||
'intel_engine.c',
|
||||
'intel_engine.h',
|
||||
'intel_gem.c',
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright © 2008 Keith Packard
|
||||
* Copyright © 2014 Intel Corporation
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
|
|
@ -20,17 +21,19 @@
|
|||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "brw_disasm.h"
|
||||
#include "brw_disasm_info.h"
|
||||
#include "brw_eu_defines.h"
|
||||
#include "brw_inst.h"
|
||||
#include "brw_shader.h"
|
||||
#include "brw_reg.h"
|
||||
#include "brw_inst.h"
|
||||
#include "brw_eu.h"
|
||||
#include "brw_inst.h"
|
||||
#include "brw_isa_info.h"
|
||||
#include "brw_reg.h"
|
||||
#include "brw_shader.h"
|
||||
#include "util/half_float.h"
|
||||
|
||||
bool
|
||||
|
|
@ -2811,3 +2814,73 @@ brw_disassemble_inst(FILE *file, const struct brw_isa_info *isa,
|
|||
newline(file);
|
||||
return err;
|
||||
}
|
||||
|
||||
int
|
||||
brw_disassemble_find_end(const struct brw_isa_info *isa,
|
||||
const void *assembly, int start)
|
||||
{
|
||||
const struct intel_device_info *devinfo = isa->devinfo;
|
||||
int offset = start;
|
||||
|
||||
/* This loop exits when send-with-EOT or when opcode is 0 */
|
||||
while (true) {
|
||||
const brw_inst *insn = assembly + offset;
|
||||
|
||||
if (brw_inst_cmpt_control(devinfo, insn)) {
|
||||
offset += 8;
|
||||
} else {
|
||||
offset += 16;
|
||||
}
|
||||
|
||||
/* Simplistic, but efficient way to terminate disasm */
|
||||
uint32_t opcode = brw_inst_opcode(isa, insn);
|
||||
if (opcode == 0 || (is_send(opcode) && brw_inst_eot(devinfo, insn))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
void
|
||||
brw_disassemble_with_errors(const struct brw_isa_info *isa,
|
||||
const void *assembly, int start, FILE *out)
|
||||
{
|
||||
int end = brw_disassemble_find_end(isa, assembly, start);
|
||||
|
||||
/* Make a dummy disasm structure that brw_validate_instructions
|
||||
* can work from.
|
||||
*/
|
||||
struct disasm_info *disasm_info = disasm_initialize(isa, NULL);
|
||||
disasm_new_inst_group(disasm_info, start);
|
||||
disasm_new_inst_group(disasm_info, end);
|
||||
|
||||
brw_validate_instructions(isa, assembly, start, end, disasm_info);
|
||||
|
||||
void *mem_ctx = ralloc_context(NULL);
|
||||
const struct brw_label *root_label =
|
||||
brw_label_assembly(isa, assembly, start, end, mem_ctx);
|
||||
|
||||
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(isa, assembly, start_offset, end_offset,
|
||||
root_label, out);
|
||||
|
||||
if (group->error) {
|
||||
fputs(group->error, out);
|
||||
}
|
||||
}
|
||||
|
||||
ralloc_free(mem_ctx);
|
||||
ralloc_free(disasm_info);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,10 @@ void brw_disassemble_with_labels(const struct brw_isa_info *isa,
|
|||
void brw_disassemble(const struct brw_isa_info *isa,
|
||||
const void *assembly, int start, int end,
|
||||
const struct brw_label *root_label, FILE *out);
|
||||
int brw_disassemble_find_end(const struct brw_isa_info *isa,
|
||||
const void *assembly, int start);
|
||||
void brw_disassemble_with_errors(const struct brw_isa_info *isa,
|
||||
const void *assembly, int start, FILE *out);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include "brw_compiler.h"
|
||||
#include "brw_kernel.h"
|
||||
#include "common/intel_disasm.h"
|
||||
#include "compiler/brw_disasm.h"
|
||||
#include "compiler/clc/clc.h"
|
||||
#include "compiler/glsl_types.h"
|
||||
#include "compiler/nir/nir_serialize.h"
|
||||
|
|
@ -247,7 +247,7 @@ print_kernel(FILE *fp, const char *prefix,
|
|||
|
||||
fprintf(fp, "#if 0 /* BEGIN KERNEL ASSEMBLY */\n");
|
||||
fprintf(fp, "\n");
|
||||
intel_disassemble(isa, kernel->code, 0, fp);
|
||||
brw_disassemble_with_errors(isa, kernel->code, 0, fp);
|
||||
fprintf(fp, "\n");
|
||||
fprintf(fp, "#endif /* END KERNEL ASSEMBLY */\n");
|
||||
print_u32_data(fp, prefix, "code", kernel->code,
|
||||
|
|
|
|||
|
|
@ -39,7 +39,8 @@
|
|||
#include "aub_read.h"
|
||||
#include "aub_mem.h"
|
||||
|
||||
#include "common/intel_disasm.h"
|
||||
#include "compiler/brw_disasm.h"
|
||||
#include "compiler/brw_isa_info.h"
|
||||
|
||||
#define xtzalloc(name) ((decltype(&name)) calloc(1, sizeof(name)))
|
||||
#define xtalloc(name) ((decltype(&name)) malloc(sizeof(name)))
|
||||
|
|
@ -394,9 +395,9 @@ new_shader_window(struct aub_mem *mem, uint64_t address, const char *desc)
|
|||
if (shader_bo.map) {
|
||||
FILE *f = open_memstream(&window->shader, &window->shader_size);
|
||||
if (f) {
|
||||
intel_disassemble(&context.file->isa,
|
||||
(const uint8_t *) shader_bo.map +
|
||||
(address - shader_bo.addr), 0, f);
|
||||
brw_disassemble_with_errors(&context.file->isa,
|
||||
(const uint8_t *) shader_bo.map +
|
||||
(address - shader_bo.addr), 0, f);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include "imgui/imgui.h"
|
||||
|
||||
#include "common/intel_decoder.h"
|
||||
#include "common/intel_disasm.h"
|
||||
#include "compiler/brw_disasm.h"
|
||||
|
||||
struct aub_viewer_cfg {
|
||||
ImColor clear_color;
|
||||
|
|
|
|||
|
|
@ -42,9 +42,10 @@
|
|||
|
||||
#include <xf86drm.h>
|
||||
|
||||
#include "common/intel_disasm.h"
|
||||
#include "common/intel_gem.h"
|
||||
#include "common/intel_hang_dump.h"
|
||||
#include "compiler/brw_disasm.h"
|
||||
#include "compiler/brw_isa_info.h"
|
||||
#include "dev/intel_device_info.h"
|
||||
|
||||
#include "drm-uapi/i915_drm.h"
|
||||
|
|
@ -417,9 +418,9 @@ main(int argc, char *argv[])
|
|||
(bo->file_offset - aligned_offset), (*addr - bo->offset));
|
||||
struct brw_isa_info _isa, *isa = &_isa;
|
||||
brw_init_isa_info(isa, &devinfo);
|
||||
intel_disassemble(isa,
|
||||
map + (bo->file_offset - aligned_offset) + (*addr - bo->offset),
|
||||
0, stderr);
|
||||
brw_disassemble_with_errors(isa,
|
||||
map + (bo->file_offset - aligned_offset) + (*addr - bo->offset),
|
||||
0, stderr);
|
||||
|
||||
munmap(map, remaining_length);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,8 +41,9 @@
|
|||
#include "util/list.h"
|
||||
#include "util/macros.h"
|
||||
|
||||
#include "common/intel_disasm.h"
|
||||
#include "common/intel_hang_dump.h"
|
||||
#include "compiler/brw_disasm.h"
|
||||
#include "compiler/brw_isa_info.h"
|
||||
|
||||
/* Data */
|
||||
|
||||
|
|
@ -222,9 +223,9 @@ public:
|
|||
size_t shader_txt_size = 0;
|
||||
FILE *f = open_memstream(&shader_txt, &shader_txt_size);
|
||||
if (f) {
|
||||
intel_disassemble(&context.isa,
|
||||
(const uint8_t *) bo->map +
|
||||
(address - bo->offset), 0, f);
|
||||
brw_disassemble_with_errors(&context.isa,
|
||||
(const uint8_t *) bo->map +
|
||||
(address - bo->offset), 0, f);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@
|
|||
#include "util/mesa-sha1.h"
|
||||
#include "util/os_time.h"
|
||||
#include "common/intel_l3_config.h"
|
||||
#include "common/intel_disasm.h"
|
||||
#include "common/intel_sample_positions.h"
|
||||
#include "compiler/brw_disasm.h"
|
||||
#include "anv_private.h"
|
||||
#include "compiler/brw_nir.h"
|
||||
#include "compiler/brw_nir_rt.h"
|
||||
|
|
@ -1666,8 +1666,8 @@ anv_pipeline_add_executable(struct anv_pipeline *pipeline,
|
|||
/* Creating this is far cheaper than it looks. It's perfectly fine to
|
||||
* do it for every binary.
|
||||
*/
|
||||
intel_disassemble(&pipeline->device->physical->compiler->isa,
|
||||
stage->code, code_offset, stream);
|
||||
brw_disassemble_with_errors(&pipeline->device->physical->compiler->isa,
|
||||
stage->code, code_offset, stream);
|
||||
|
||||
fclose(stream);
|
||||
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@
|
|||
#include "util/mesa-sha1.h"
|
||||
#include "util/os_time.h"
|
||||
#include "common/intel_l3_config.h"
|
||||
#include "common/intel_disasm.h"
|
||||
#include "common/intel_sample_positions.h"
|
||||
#include "compiler/brw_disasm.h"
|
||||
#include "anv_private.h"
|
||||
#include "compiler/brw_nir.h"
|
||||
#include "compiler/brw_nir_rt.h"
|
||||
|
|
@ -1035,8 +1035,8 @@ anv_pipeline_add_executable(struct anv_pipeline *pipeline,
|
|||
/* Creating this is far cheaper than it looks. It's perfectly fine to
|
||||
* do it for every binary.
|
||||
*/
|
||||
intel_disassemble(&pipeline->device->physical->compiler->isa,
|
||||
stage->code, code_offset, stream);
|
||||
brw_disassemble_with_errors(&pipeline->device->physical->compiler->isa,
|
||||
stage->code, code_offset, stream);
|
||||
|
||||
fclose(stream);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue