xref: /aosp_15_r20/external/mesa3d/src/intel/compiler/elk/elk_disasm_info.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright © 2014 Intel Corporation
3  *
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:
10  *
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
13  * Software.
14  *
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
21  * IN THE SOFTWARE.
22  */
23 
24 #ifndef ELK_DISASM_INFO_H
25 #define ELK_DISASM_INFO_H
26 
27 #include "compiler/glsl/list.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 struct elk_cfg_t;
34 struct elk_backend_instruction;
35 struct intel_device_info;
36 
37 struct inst_group {
38    struct exec_node link;
39 
40    int offset;
41 
42    size_t error_length;
43    char *error;
44 
45    /* Pointers to the basic block in the CFG if the instruction group starts
46     * or ends a basic block.
47     */
48    struct elk_bblock_t *block_start;
49    struct elk_bblock_t *block_end;
50 
51    /* Annotation for the generated IR.  One of the two can be set. */
52    const void *ir;
53    const char *annotation;
54 };
55 
56 struct elk_disasm_info {
57    struct exec_list group_list;
58 
59    const struct elk_isa_info *isa;
60    const struct elk_cfg_t *cfg;
61 
62    /** Block index in the cfg. */
63    int cur_block;
64    bool use_tail;
65 };
66 
67 void
68 elk_dump_assembly(void *assembly, int start_offset, int end_offset,
69               struct elk_disasm_info *disasm, const unsigned *block_latency);
70 
71 struct elk_disasm_info *
72 elk_disasm_initialize(const struct elk_isa_info *isa,
73                   const struct elk_cfg_t *cfg);
74 
75 struct inst_group *
76 elk_disasm_new_inst_group(struct elk_disasm_info *disasm, unsigned offset);
77 
78 void
79 elk_disasm_annotate(struct elk_disasm_info *disasm,
80                 struct elk_backend_instruction *inst, unsigned offset);
81 
82 void
83 elk_disasm_insert_error(struct elk_disasm_info *disasm, unsigned offset,
84                     unsigned inst_size, const char *error);
85 
86 #ifdef __cplusplus
87 } /* extern "C" */
88 #endif
89 
90 #endif /* ELK_DISASM_INFO_H */
91