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 "compiler/brw_inst.h"
27 #include "compiler/brw_eu.h"
29 #include "gen_disasm.h"
34 struct gen_device_info devinfo
;
38 is_send(uint32_t opcode
)
40 return (opcode
== BRW_OPCODE_SEND
||
41 opcode
== BRW_OPCODE_SENDC
||
42 opcode
== BRW_OPCODE_SENDS
||
43 opcode
== BRW_OPCODE_SENDSC
);
47 gen_disasm_disassemble(struct gen_disasm
*disasm
, void *assembly
,
50 struct gen_device_info
*devinfo
= &disasm
->devinfo
;
51 bool dump_hex
= false;
54 /* This loop exits when send-with-EOT or when opcode is 0 */
56 brw_inst
*insn
= assembly
+ offset
;
58 bool compacted
= brw_inst_cmpt_control(devinfo
, insn
);
60 fprintf(out
, "0x%08x: ", offset
);
63 brw_compact_inst
*compacted
= (void *)insn
;
65 fprintf(out
, "0x%08x 0x%08x ",
66 ((uint32_t *)insn
)[1],
67 ((uint32_t *)insn
)[0]);
70 brw_uncompact_instruction(devinfo
, &uncompacted
, compacted
);
75 fprintf(out
, "0x%08x 0x%08x 0x%08x 0x%08x ",
76 ((uint32_t *)insn
)[3],
77 ((uint32_t *)insn
)[2],
78 ((uint32_t *)insn
)[1],
79 ((uint32_t *)insn
)[0]);
84 brw_disassemble_inst(out
, devinfo
, insn
, compacted
);
86 /* Simplistic, but efficient way to terminate disasm */
87 uint32_t opcode
= brw_inst_opcode(devinfo
, insn
);
88 if (opcode
== 0 || (is_send(opcode
) && brw_inst_eot(devinfo
, insn
))) {
95 gen_disasm_create(int pciid
)
97 struct gen_disasm
*gd
;
99 gd
= malloc(sizeof *gd
);
103 if (!gen_get_device_info(pciid
, &gd
->devinfo
)) {
108 brw_init_compaction_tables(&gd
->devinfo
);
114 gen_disasm_destroy(struct gen_disasm
*disasm
)