1de20f576d4d36d3a6cd8354b9c5a489d20b7b47
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_find_end(struct gen_disasm
*disasm
, void *assembly
, int start
)
49 struct gen_device_info
*devinfo
= &disasm
->devinfo
;
52 /* This loop exits when send-with-EOT or when opcode is 0 */
54 brw_inst
*insn
= assembly
+ offset
;
56 if (brw_inst_cmpt_control(devinfo
, insn
)) {
62 /* Simplistic, but efficient way to terminate disasm */
63 uint32_t opcode
= brw_inst_opcode(devinfo
, insn
);
64 if (opcode
== 0 || (is_send(opcode
) && brw_inst_eot(devinfo
, insn
))) {
73 gen_disasm_disassemble(struct gen_disasm
*disasm
, void *assembly
,
76 struct gen_device_info
*devinfo
= &disasm
->devinfo
;
77 int end
= gen_disasm_find_end(disasm
, assembly
, start
);
79 /* Make a dummy disasm structure that brw_validate_instructions
82 struct disasm_info
*disasm_info
= disasm_initialize(devinfo
, NULL
);
83 disasm_new_inst_group(disasm_info
, start
);
84 disasm_new_inst_group(disasm_info
, end
);
86 brw_validate_instructions(devinfo
, assembly
, start
, end
, disasm_info
);
88 foreach_list_typed(struct inst_group
, group
, link
,
89 &disasm_info
->group_list
) {
90 struct exec_node
*next_node
= exec_node_get_next(&group
->link
);
91 if (exec_node_is_tail_sentinel(next_node
))
94 struct inst_group
*next
=
95 exec_node_data(struct inst_group
, next_node
, link
);
97 int start_offset
= group
->offset
;
98 int end_offset
= next
->offset
;
100 brw_disassemble(devinfo
, assembly
, start_offset
, end_offset
, out
);
103 fputs(group
->error
, out
);
107 ralloc_free(disasm_info
);
111 gen_disasm_create(const struct gen_device_info
*devinfo
)
113 struct gen_disasm
*gd
;
115 gd
= malloc(sizeof *gd
);
119 gd
->devinfo
= *devinfo
;
121 brw_init_compaction_tables(&gd
->devinfo
);
127 gen_disasm_destroy(struct gen_disasm
*disasm
)