{
memset(ctx, 0, sizeof(*ctx));
+ ctx->devinfo = *devinfo;
ctx->get_bo = get_bo;
ctx->get_state_size = get_state_size;
ctx->user_data = user_data;
ctx->spec = gen_spec_load(devinfo);
else
ctx->spec = gen_spec_load_from_path(devinfo, xml_path);
- ctx->disasm = gen_disasm_create(devinfo);
}
void
gen_batch_decode_ctx_finish(struct gen_batch_decode_ctx *ctx)
{
gen_spec_destroy(ctx->spec);
- gen_disasm_destroy(ctx->disasm);
}
#define CSI "\e["
return;
fprintf(ctx->fp, "\nReferenced %s:\n", type);
- gen_disasm_disassemble(ctx->disasm, bo.map, 0, ctx->fp);
+ gen_disassemble(&ctx->devinfo, bo.map, 0, ctx->fp);
}
/* Heuristic to determine whether a uint32_t is probably actually a float
void *user_data;
FILE *fp;
+ struct gen_device_info devinfo;
struct gen_spec *spec;
enum gen_batch_decode_flags flags;
- struct gen_disasm *disasm;
-
uint64_t surface_base;
uint64_t dynamic_base;
uint64_t instruction_base;
#include "gen_disasm.h"
-struct gen_disasm {
- struct gen_device_info devinfo;
-};
-
static bool
is_send(uint32_t opcode)
{
}
static int
-gen_disasm_find_end(struct gen_disasm *disasm,
+gen_disasm_find_end(const struct gen_device_info *devinfo,
const void *assembly, int start)
{
- struct gen_device_info *devinfo = &disasm->devinfo;
int offset = start;
/* This loop exits when send-with-EOT or when opcode is 0 */
}
void
-gen_disasm_disassemble(struct gen_disasm *disasm, const void *assembly,
- int start, FILE *out)
+gen_disassemble(const struct gen_device_info *devinfo,
+ const void *assembly, int start, FILE *out)
{
- struct gen_device_info *devinfo = &disasm->devinfo;
- int end = gen_disasm_find_end(disasm, assembly, start);
+ int end = gen_disasm_find_end(devinfo, assembly, start);
/* Make a dummy disasm structure that brw_validate_instructions
* can work from.
ralloc_free(mem_ctx);
ralloc_free(disasm_info);
}
-
-struct gen_disasm *
-gen_disasm_create(const struct gen_device_info *devinfo)
-{
- struct gen_disasm *gd;
-
- gd = malloc(sizeof *gd);
- if (gd == NULL)
- return NULL;
-
- gd->devinfo = *devinfo;
-
- return gd;
-}
-
-void
-gen_disasm_destroy(struct gen_disasm *disasm)
-{
- free(disasm);
-}
extern "C" {
#endif
-struct gen_disasm;
-
-struct gen_disasm *gen_disasm_create(const struct gen_device_info *devinfo);
-void gen_disasm_disassemble(struct gen_disasm *disasm,
- const void *assembly, int start, FILE *out);
-
-void gen_disasm_destroy(struct gen_disasm *disasm);
+void gen_disassemble(const struct gen_device_info *devinfo,
+ const void *assembly, int start, FILE *out);
#ifdef __cplusplus
}
/* Device state */
struct gen_device_info devinfo;
struct gen_spec *spec;
- struct gen_disasm *disasm;
};
static void
exit(EXIT_FAILURE);
}
file->spec = gen_spec_load(&file->devinfo);
- file->disasm = gen_disasm_create(&file->devinfo);
}
static void
if (shader_bo.map) {
FILE *f = open_memstream(&window->shader, &window->shader_size);
if (f) {
- gen_disasm_disassemble(context.file->disasm,
- (const uint8_t *) shader_bo.map +
- (address - shader_bo.addr), 0, f);
+ gen_disassemble(&context.file->devinfo,
+ (const uint8_t *) shader_bo.map +
+ (address - shader_bo.addr), 0, f);
fclose(f);
}
}
aub_viewer_decode_ctx_init(&window->decode_ctx,
&context.cfg,
&window->decode_cfg,
+ &context.file->devinfo,
context.file->spec,
- context.file->disasm,
batch_get_bo,
NULL,
window);
void *user_data;
+ const struct gen_device_info *devinfo;
struct gen_spec *spec;
- struct gen_disasm *disasm;
enum drm_i915_gem_engine_class engine;
struct aub_viewer_cfg *cfg;
void aub_viewer_decode_ctx_init(struct aub_viewer_decode_ctx *ctx,
struct aub_viewer_cfg *cfg,
struct aub_viewer_decode_cfg *decode_cfg,
+ const struct gen_device_info *devinfo,
struct gen_spec *spec,
- struct gen_disasm *disasm,
struct gen_batch_decode_bo (*get_bo)(void *, bool, uint64_t),
unsigned (*get_state_size)(void *, uint32_t),
void *user_data);
aub_viewer_decode_ctx_init(struct aub_viewer_decode_ctx *ctx,
struct aub_viewer_cfg *cfg,
struct aub_viewer_decode_cfg *decode_cfg,
+ const struct gen_device_info *devinfo,
struct gen_spec *spec,
- struct gen_disasm *disasm,
struct gen_batch_decode_bo (*get_bo)(void *, bool, uint64_t),
unsigned (*get_state_size)(void *, uint32_t),
void *user_data)
ctx->get_bo = get_bo;
ctx->get_state_size = get_state_size;
ctx->user_data = user_data;
+ ctx->devinfo = devinfo;
ctx->engine = I915_ENGINE_CLASS_RENDER;
ctx->cfg = cfg;
ctx->decode_cfg = decode_cfg;
ctx->spec = spec;
- ctx->disasm = disasm;
}
static void
/* Creating this is far cheaper than it looks. It's perfectly fine to
* do it for every binary.
*/
- struct gen_disasm *d = gen_disasm_create(&pipeline->device->info);
- gen_disasm_disassemble(d, stage->code, code_offset, stream);
- gen_disasm_destroy(d);
+ gen_disassemble(&pipeline->device->info,
+ stage->code, code_offset, stream);
fclose(stream);