summaryrefslogtreecommitdiff
path: root/src/microsoft/compiler/dxil_dump_decls.h
blob: b651734b63f1e27382403119ed777b7b1c1b87fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/*
 * Copyright © Microsoft Corporation
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */

#ifndef DIXL_DUMP_DECL
#error This header can only be included from dxil_dump.c
#endif

#include "dxil_module.h"

static void
dump_metadata(struct dxil_dumper *buf, struct dxil_module *m);
static void
dump_shader_info(struct dxil_dumper *buf, struct dxil_shader_info *info);
static const char *
dump_shader_string(enum dxil_shader_kind kind);
static void
dump_features(struct _mesa_string_buffer *buf, struct dxil_features *feat);
static void
dump_types(struct dxil_dumper *buf, struct list_head *list);
static void
dump_gvars(struct dxil_dumper *buf, struct list_head *list);
static void
dump_constants(struct dxil_dumper *buf, struct list_head *list);
static void
dump_funcs(struct dxil_dumper *buf, struct list_head *list);
static void
dump_attr_set_list(struct dxil_dumper *buf, struct list_head *list);
static void
dump_instrs(struct dxil_dumper *buf, struct list_head *list);
static void
dump_mdnodes(struct dxil_dumper *buf, struct list_head *list);
static void
dump_mdnode(struct dxil_dumper *d, const struct dxil_mdnode *node);
static void
dump_named_nodes(struct dxil_dumper *d, struct list_head *list);
static void
dump_type(struct dxil_dumper *buf, const struct dxil_type *type);
static void
dump_instr_binop(struct dxil_dumper *d, struct dxil_instr_binop *binop);
static void
dump_instr_cmp(struct dxil_dumper *d, struct dxil_instr_cmp *cmp);
static void
dump_instr_select(struct dxil_dumper *d, struct dxil_instr_select *select);
static void
dump_instr_cast(struct dxil_dumper *d, struct dxil_instr_cast *cast);
static void
dump_instr_call(struct dxil_dumper *d, struct dxil_instr_call *call);
static void
dump_instr_ret(struct dxil_dumper *d, struct dxil_instr_ret *ret);
static void
dump_instr_extractval(struct dxil_dumper *d, struct dxil_instr_extractval *ret);
static void
dump_instr_branch(struct dxil_dumper *d, struct dxil_instr_br *br);
static void
dump_instr_phi(struct dxil_dumper *d, struct dxil_instr_phi *phi);
static void
dump_instr_alloca(struct dxil_dumper *d, struct dxil_instr_alloca *alloca);
static void
dump_instr_gep(struct dxil_dumper *d, struct dxil_instr_gep *gep);
static void
dump_instr_load(struct dxil_dumper *d, struct dxil_instr_load *store);
static void
dump_instr_store(struct dxil_dumper *d, struct dxil_instr_store *store);
static void
dump_instr_atomicrmw(struct dxil_dumper *d, struct dxil_instr_atomicrmw *rmw);

static void
dump_instr_print_operands(struct dxil_dumper *d, int num,
                          const struct dxil_value *val[]);

static void dump_io_signatures(struct _mesa_string_buffer *buf,
                               struct dxil_module *m);
static void
dump_io_signature(struct _mesa_string_buffer *buf, unsigned num,
                  struct dxil_signature_record *io);

static const char *component_type_as_string(uint32_t type);

static void dump_psv(struct _mesa_string_buffer *buf,
                     struct dxil_module *m);
static void dump_psv_io(struct _mesa_string_buffer *buf, struct dxil_module *m,
                        unsigned num, struct dxil_psv_signature_element *io);

static void
dump_value(struct dxil_dumper *d, const struct dxil_value *val);

static const char *binop_strings[DXIL_BINOP_INSTR_COUNT] = {
   [DXIL_BINOP_ADD] = "add",
   [DXIL_BINOP_SUB] = "sub",
   [DXIL_BINOP_MUL] = "mul",
   [DXIL_BINOP_UDIV] = "udiv",
   [DXIL_BINOP_SDIV] = "sdiv",
   [DXIL_BINOP_UREM] = "urem",
   [DXIL_BINOP_SREM] = "srem",
   [DXIL_BINOP_SHL] = "shl",
   [DXIL_BINOP_LSHR] = "lshr",
   [DXIL_BINOP_ASHR] = "ashr",
   [DXIL_BINOP_AND] = "and",
   [DXIL_BINOP_OR] = "or",
   [DXIL_BINOP_XOR]= "xor"
};

static const char *pred_strings[DXIL_CMP_INSTR_COUNT] = {
   [DXIL_FCMP_FALSE] = "FALSE",
   [DXIL_FCMP_OEQ] = "ord-fEQ",
   [DXIL_FCMP_OGT] = "ord-fGT",
   [DXIL_FCMP_OGE] = "ord-fGE",
   [DXIL_FCMP_OLT] = "ord-fLT",
   [DXIL_FCMP_OLE] = "ord-fLE",
   [DXIL_FCMP_ONE] = "ord-fNE",
   [DXIL_FCMP_ORD] = "ord-fRD",
   [DXIL_FCMP_UNO] = "unord-fNO",
   [DXIL_FCMP_UEQ] = "unord-fEQ",
   [DXIL_FCMP_UGT] = "unord-fGT",
   [DXIL_FCMP_UGE] = "unord-fGE",
   [DXIL_FCMP_ULT] = "unord-fLT",
   [DXIL_FCMP_ULE] = "unord-fLE",
   [DXIL_FCMP_UNE] = "unord-fNE",
   [DXIL_FCMP_TRUE] = "TRUE",
   [DXIL_ICMP_EQ] = "iEQ",
   [DXIL_ICMP_NE] = "iNE",
   [DXIL_ICMP_UGT] = "uiGT",
   [DXIL_ICMP_UGE] = "uiGE",
   [DXIL_ICMP_ULT] = "uiLT",
   [DXIL_ICMP_ULE] = "uiLE",
   [DXIL_ICMP_SGT] = "iGT",
   [DXIL_ICMP_SGE] = "iGE",
   [DXIL_ICMP_SLT] = "iLT",
   [DXIL_ICMP_SLE] = "iLE"
};

static const char *cast_opcode_strings[DXIL_CAST_INSTR_COUNT] = {
   [DXIL_CAST_TRUNC] = "trunc",
   [DXIL_CAST_ZEXT] = "zext",
   [DXIL_CAST_SEXT] = "sext",
   [DXIL_CAST_FPTOUI] = "ftoui",
   [DXIL_CAST_FPTOSI] = "ftoi",
   [DXIL_CAST_UITOFP] = "uitof",
   [DXIL_CAST_SITOFP] = "itof",
   [DXIL_CAST_FPTRUNC] = "ftrunc",
   [DXIL_CAST_FPEXT] = "fext",
   [DXIL_CAST_PTRTOINT] = "ptrtoint",
   [DXIL_CAST_INTTOPTR] = "inttoptr",
   [DXIL_CAST_BITCAST] = "bitcast",
   [DXIL_CAST_ADDRSPACECAST] = "addrspacecast",
};

static const char *dxil_type_strings[DXIL_PROG_SIG_COMP_TYPE_COUNT] = {
   [DXIL_PROG_SIG_COMP_TYPE_UNKNOWN] = "unknown",
   [DXIL_PROG_SIG_COMP_TYPE_UINT32] = "uint32",
   [DXIL_PROG_SIG_COMP_TYPE_SINT32] = "int32",
   [DXIL_PROG_SIG_COMP_TYPE_FLOAT32] = "float32",
   [DXIL_PROG_SIG_COMP_TYPE_UINT16] = "uint16",
   [DXIL_PROG_SIG_COMP_TYPE_SINT16] = "int16",
   [DXIL_PROG_SIG_COMP_TYPE_FLOAT16] = "float16",
   [DXIL_PROG_SIG_COMP_TYPE_UINT64] = "uint64",
   [DXIL_PROG_SIG_COMP_TYPE_SINT64] = "int64",
   [DXIL_PROG_SIG_COMP_TYPE_FLOAT64] = "float64"
};