forked from notaz/mesa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdxil_internal.h
301 lines (255 loc) · 6.47 KB
/
dxil_internal.h
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
/*
* 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 DXIL_INTERNAL_H
#define DXIL_INTERNAL_H
#include "dxil_module.h"
#include "util/list.h"
#include <stdint.h>
// Malloc.h defines a macro for alloca. Let's at least make sure that all includers
// of this header have the same definition of alloca.
#include <malloc.h>
struct dxil_type_list {
struct dxil_type **types;
size_t num_types;
};
struct dxil_type {
enum type_type {
TYPE_VOID,
TYPE_INTEGER,
TYPE_FLOAT,
TYPE_POINTER,
TYPE_STRUCT,
TYPE_ARRAY,
TYPE_VECTOR,
TYPE_FUNCTION
} type;
union {
unsigned int_bits;
unsigned float_bits;
const struct dxil_type *ptr_target_type;
struct {
const char *name;
struct dxil_type_list elem;
} struct_def;
struct {
const struct dxil_type *ret_type;
struct dxil_type_list args;
} function_def;
struct {
const struct dxil_type *elem_type;
size_t num_elems;
} array_or_vector_def;
};
struct list_head head;
unsigned id;
};
struct dxil_value {
int id;
const struct dxil_type *type;
};
struct dxil_gvar {
const char *name;
const struct dxil_type *type;
bool constant;
enum dxil_address_space as;
int align;
const struct dxil_value *initializer;
struct dxil_value value;
struct list_head head;
};
struct dxil_func {
char *name;
const struct dxil_type *type;
bool decl;
unsigned attr_set;
struct dxil_value value;
struct list_head head;
};
struct dxil_attrib {
enum {
DXIL_ATTR_ENUM
} type;
union {
enum dxil_attr_kind kind;
};
};
struct attrib_set {
struct dxil_attrib attrs[2];
unsigned num_attrs;
struct list_head head;
};
struct dxil_instr_binop {
enum dxil_bin_opcode opcode;
const struct dxil_value *operands[2];
enum dxil_opt_flags flags;
};
struct dxil_instr_cmp {
enum dxil_cmp_pred pred;
const struct dxil_value *operands[2];
};
struct dxil_instr_select {
const struct dxil_value *operands[3];
};
struct dxil_instr_cast {
enum dxil_cast_opcode opcode;
const struct dxil_type *type;
const struct dxil_value *value;
};
struct dxil_instr_call {
const struct dxil_func *func;
struct dxil_value **args;
size_t num_args;
};
struct dxil_instr_ret {
struct dxil_value *value;
};
struct dxil_instr_extractval {
const struct dxil_value *src;
const struct dxil_type *type;
unsigned int idx;
};
struct dxil_instr_br {
const struct dxil_value *cond;
unsigned succ[2];
};
struct dxil_instr_phi {
const struct dxil_type *type;
struct dxil_phi_src {
const struct dxil_value *value;
unsigned block;
} *incoming;
size_t num_incoming;
};
struct dxil_instr_alloca {
const struct dxil_type *alloc_type;
const struct dxil_type *size_type;
const struct dxil_value *size;
unsigned align;
};
struct dxil_instr_gep {
bool inbounds;
const struct dxil_type *source_elem_type;
struct dxil_value **operands;
size_t num_operands;
};
struct dxil_instr_load {
const struct dxil_value *ptr;
const struct dxil_type *type;
unsigned align;
bool is_volatile;
};
struct dxil_instr_store {
const struct dxil_value *value, *ptr;
unsigned align;
bool is_volatile;
};
struct dxil_instr_atomicrmw {
const struct dxil_value *value, *ptr;
enum dxil_rmw_op op;
bool is_volatile;
enum dxil_atomic_ordering ordering;
enum dxil_sync_scope syncscope;
};
struct dxil_instr_cmpxchg {
const struct dxil_value *cmpval, *newval, *ptr;
bool is_volatile;
enum dxil_atomic_ordering ordering;
enum dxil_sync_scope syncscope;
};
struct dxil_instr {
enum instr_type {
INSTR_BINOP,
INSTR_CMP,
INSTR_SELECT,
INSTR_CAST,
INSTR_BR,
INSTR_PHI,
INSTR_CALL,
INSTR_RET,
INSTR_EXTRACTVAL,
INSTR_ALLOCA,
INSTR_GEP,
INSTR_LOAD,
INSTR_STORE,
INSTR_ATOMICRMW,
INSTR_CMPXCHG,
} type;
union {
struct dxil_instr_binop binop;
struct dxil_instr_cmp cmp;
struct dxil_instr_select select;
struct dxil_instr_cast cast;
struct dxil_instr_call call;
struct dxil_instr_ret ret;
struct dxil_instr_extractval extractval;
struct dxil_instr_phi phi;
struct dxil_instr_br br;
struct dxil_instr_alloca alloca;
struct dxil_instr_gep gep;
struct dxil_instr_load load;
struct dxil_instr_store store;
struct dxil_instr_atomicrmw atomicrmw;
struct dxil_instr_cmpxchg cmpxchg;
};
bool has_value;
struct dxil_value value;
struct list_head head;
};
struct dxil_const {
struct dxil_value value;
bool undef;
union {
intmax_t int_value;
double float_value;
const struct dxil_value **array_values;
const struct dxil_value **struct_values;
};
struct list_head head;
};
struct dxil_mdnode {
enum mdnode_type {
MD_STRING,
MD_VALUE,
MD_NODE
} type;
union {
char *string;
struct {
const struct dxil_type *type;
const struct dxil_value *value;
} value;
struct {
const struct dxil_mdnode **subnodes;
size_t num_subnodes;
} node;
};
struct list_head head;
unsigned id;
};
struct dxil_named_node {
char *name;
const struct dxil_mdnode **subnodes;
size_t num_subnodes;
struct list_head head;
};
#endif // DXIL_INTERNAL_H