2 * Copyright © 2014 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
26 #include "brw_context.h"
30 #include "gen_disasm.h"
35 struct brw_device_info devinfo
;
39 gen_disasm_disassemble(struct gen_disasm
*disasm
, void *assembly
, int start
, int end
, FILE *out
)
41 struct brw_device_info
*devinfo
= &disasm
->devinfo
;
42 bool dump_hex
= false;
44 for (int offset
= start
; offset
< end
;) {
45 brw_inst
*insn
= assembly
+ offset
;
47 bool compacted
= brw_inst_cmpt_control(devinfo
, insn
);
49 fprintf(out
, "0x%08x: ", offset
);
52 brw_compact_inst
*compacted
= (void *)insn
;
54 fprintf(out
, "0x%08x 0x%08x ",
55 ((uint32_t *)insn
)[1],
56 ((uint32_t *)insn
)[0]);
59 brw_uncompact_instruction(devinfo
, &uncompacted
, compacted
);
64 fprintf(out
, "0x%08x 0x%08x 0x%08x 0x%08x ",
65 ((uint32_t *)insn
)[3],
66 ((uint32_t *)insn
)[2],
67 ((uint32_t *)insn
)[1],
68 ((uint32_t *)insn
)[0]);
73 brw_disassemble_inst(out
, devinfo
, insn
, compacted
);
75 /* Simplistic, but efficient way to terminate disasm */
76 if (brw_inst_opcode(devinfo
, insn
) == BRW_OPCODE_SEND
||
77 brw_inst_opcode(devinfo
, insn
) == BRW_OPCODE_SENDC
)
78 if (brw_inst_eot(devinfo
, insn
))
80 if (brw_inst_opcode(devinfo
, insn
) == 0)
87 gen_disasm_create(int pciid
)
89 struct gen_disasm
*gd
;
90 const struct brw_device_info
*dev_info
= NULL
;
92 gd
= malloc(sizeof *gd
);
96 dev_info
= brw_get_device_info(pciid
);
98 gd
->devinfo
.gen
= dev_info
->gen
;
99 gd
->devinfo
.is_cherryview
= dev_info
->is_cherryview
;
100 gd
->devinfo
.is_g4x
= dev_info
->is_g4x
;
102 brw_init_compaction_tables(&gd
->devinfo
);
108 gen_disasm_destroy(struct gen_disasm
*disasm
)