~mmach/netext73/mesa-ryzen

« back to all changes in this revision

Viewing changes to src/amd/llvm/ac_llvm_build.h

  • Committer: mmach
  • Date: 2023-11-02 21:31:35 UTC
  • Revision ID: netbit73@gmail.com-20231102213135-18d4tzh7tj0uz752
2023-11-02 22:11:57

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * Copyright 2016 Bas Nieuwenhuizen
3
3
 *
4
 
 * Permission is hereby granted, free of charge, to any person obtaining a
5
 
 * copy of this software and associated documentation files (the
6
 
 * "Software"), to deal in the Software without restriction, including
7
 
 * without limitation the rights to use, copy, modify, merge, publish,
8
 
 * distribute, sub license, and/or sell copies of the Software, and to
9
 
 * permit persons to whom the Software is furnished to do so, subject to
10
 
 * the following conditions:
11
 
 *
12
 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
 
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14
 
 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
15
 
 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
16
 
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
17
 
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
18
 
 * USE OR OTHER DEALINGS IN THE SOFTWARE.
19
 
 *
20
 
 * The above copyright notice and this permission notice (including the
21
 
 * next paragraph) shall be included in all copies or substantial portions
22
 
 * of the Software.
23
 
 *
 
4
 * SPDX-License-Identifier: MIT
24
5
 */
25
6
#ifndef AC_LLVM_BUILD_H
26
7
#define AC_LLVM_BUILD_H
56
37
 
57
38
struct ac_llvm_flow;
58
39
struct ac_llvm_compiler;
 
40
struct radeon_info;
59
41
 
60
42
struct ac_llvm_flow_state {
61
43
   struct ac_llvm_flow *stack;
130
112
   LLVMValueRef i1true;
131
113
   LLVMValueRef i1false;
132
114
 
133
 
   /* Temporary helper to implement demote_to_helper:
134
 
    * True = live lanes
135
 
    * False = demoted lanes
136
 
    */
137
 
   LLVMValueRef postponed_kill;
138
 
   bool conditional_demote_seen;
139
 
 
140
115
   /* Since ac_nir_translate makes a local copy of ac_llvm_context, there
141
116
    * are two ac_llvm_contexts. Declare a pointer here, so that the control
142
117
    * flow stack is shared by both ac_llvm_contexts.
148
123
   unsigned uniform_md_kind;
149
124
   LLVMValueRef empty_md;
150
125
 
 
126
   const struct radeon_info *info;
151
127
   enum amd_gfx_level gfx_level;
152
 
   enum radeon_family family;
153
 
   bool has_3d_cube_border_color_mipmap;
154
128
 
155
129
   unsigned wave_size;
156
130
   unsigned ballot_mask_bits;
167
141
};
168
142
 
169
143
void ac_llvm_context_init(struct ac_llvm_context *ctx, struct ac_llvm_compiler *compiler,
170
 
                          enum amd_gfx_level gfx_level, enum radeon_family family,
171
 
                          bool has_3d_cube_border_color_mipmap,
172
 
                          enum ac_float_mode float_mode, unsigned wave_size,
173
 
                          unsigned ballot_mask_bits, bool exports_color_null, bool exports_mrtz);
 
144
                          const struct radeon_info *info, enum ac_float_mode float_mode,
 
145
                          unsigned wave_size, unsigned ballot_mask_bits, bool exports_color_null,
 
146
                          bool exports_mrtz);
174
147
 
175
148
void ac_llvm_context_dispose(struct ac_llvm_context *ctx);
176
149
 
200
173
void ac_build_s_barrier(struct ac_llvm_context *ctx, gl_shader_stage stage);
201
174
void ac_build_optimization_barrier(struct ac_llvm_context *ctx, LLVMValueRef *pgpr, bool sgpr);
202
175
 
203
 
LLVMValueRef ac_build_shader_clock(struct ac_llvm_context *ctx, nir_scope scope);
 
176
LLVMValueRef ac_build_shader_clock(struct ac_llvm_context *ctx, mesa_scope scope);
204
177
 
205
178
LLVMValueRef ac_build_ballot(struct ac_llvm_context *ctx, LLVMValueRef value);
206
179
LLVMValueRef ac_get_i1_sgpr_mask(struct ac_llvm_context *ctx, LLVMValueRef value);
243
216
LLVMValueRef ac_build_fast_udiv_u31_d_not_one(struct ac_llvm_context *ctx, LLVMValueRef num,
244
217
                                              LLVMValueRef multiplier, LLVMValueRef post_shift);
245
218
 
246
 
void ac_prepare_cube_coords(struct ac_llvm_context *ctx, bool is_deriv, bool is_array, bool is_lod,
247
 
                            LLVMValueRef *coords_arg, LLVMValueRef *derivs_arg);
248
 
 
249
219
LLVMValueRef ac_build_fs_interp(struct ac_llvm_context *ctx, LLVMValueRef llvm_chan,
250
220
                                LLVMValueRef attr_number, LLVMValueRef params, LLVMValueRef i,
251
221
                                LLVMValueRef j);
281
251
 
282
252
void ac_build_buffer_store_dword(struct ac_llvm_context *ctx, LLVMValueRef rsrc, LLVMValueRef vdata,
283
253
                                 LLVMValueRef vindex, LLVMValueRef voffset, LLVMValueRef soffset,
284
 
                                 unsigned cache_policy);
 
254
                                 enum gl_access_qualifier access);
285
255
 
286
256
void ac_build_buffer_store_format(struct ac_llvm_context *ctx, LLVMValueRef rsrc, LLVMValueRef data,
287
 
                                  LLVMValueRef vindex, LLVMValueRef voffset, unsigned cache_policy);
 
257
                                  LLVMValueRef vindex, LLVMValueRef voffset, enum gl_access_qualifier access);
288
258
 
289
259
LLVMValueRef ac_build_buffer_load(struct ac_llvm_context *ctx, LLVMValueRef rsrc, int num_channels,
290
260
                                  LLVMValueRef vindex, LLVMValueRef voffset, LLVMValueRef soffset,
291
 
                                  LLVMTypeRef channel_type, unsigned cache_policy,
 
261
                                  LLVMTypeRef channel_type, enum gl_access_qualifier access,
292
262
                                  bool can_speculate, bool allow_smem);
293
263
 
294
264
LLVMValueRef ac_build_buffer_load_format(struct ac_llvm_context *ctx, LLVMValueRef rsrc,
295
265
                                         LLVMValueRef vindex, LLVMValueRef voffset,
296
 
                                         unsigned num_channels, unsigned cache_policy,
 
266
                                         unsigned num_channels, enum gl_access_qualifier access,
297
267
                                         bool can_speculate, bool d16, bool tfe);
298
268
 
299
269
LLVMValueRef ac_build_buffer_load_short(struct ac_llvm_context *ctx, LLVMValueRef rsrc,
300
270
                                        LLVMValueRef voffset, LLVMValueRef soffset,
301
 
                                        unsigned cache_policy);
 
271
                                        enum gl_access_qualifier access);
302
272
 
303
273
LLVMValueRef ac_build_buffer_load_byte(struct ac_llvm_context *ctx, LLVMValueRef rsrc,
304
274
                                       LLVMValueRef voffset, LLVMValueRef soffset,
305
 
                                       unsigned cache_policy);
 
275
                                       enum gl_access_qualifier access);
306
276
 
307
277
LLVMValueRef ac_build_safe_tbuffer_load(struct ac_llvm_context *ctx, LLVMValueRef rsrc,
308
278
                                        LLVMValueRef vindex, LLVMValueRef voffset,
312
282
                                        unsigned align_offset,
313
283
                                        unsigned align_mul,
314
284
                                        unsigned num_channels,
315
 
                                        unsigned cache_policy,
 
285
                                        enum gl_access_qualifier access,
316
286
                                        bool can_speculate);
317
287
 
318
288
void ac_build_buffer_store_short(struct ac_llvm_context *ctx, LLVMValueRef rsrc,
319
289
                                 LLVMValueRef vdata, LLVMValueRef voffset, LLVMValueRef soffset,
320
 
                                 unsigned cache_policy);
 
290
                                 enum gl_access_qualifier access);
321
291
 
322
292
void ac_build_buffer_store_byte(struct ac_llvm_context *ctx, LLVMValueRef rsrc, LLVMValueRef vdata,
323
 
                                LLVMValueRef voffset, LLVMValueRef soffset, unsigned cache_policy);
 
293
                                LLVMValueRef voffset, LLVMValueRef soffset, enum gl_access_qualifier access);
324
294
 
325
295
void ac_set_range_metadata(struct ac_llvm_context *ctx, LLVMValueRef value, unsigned lo,
326
296
                           unsigned hi);
332
302
 
333
303
LLVMValueRef ac_build_ddxy(struct ac_llvm_context *ctx, uint32_t mask, int idx, LLVMValueRef val);
334
304
 
335
 
#define AC_SENDMSG_GS           2
336
 
#define AC_SENDMSG_GS_DONE      3
337
 
#define AC_SENDMSG_GS_ALLOC_REQ 9
338
 
 
339
 
#define AC_SENDMSG_GS_OP_NOP      (0 << 4)
340
 
#define AC_SENDMSG_GS_OP_CUT      (1 << 4)
341
 
#define AC_SENDMSG_GS_OP_EMIT     (2 << 4)
342
 
#define AC_SENDMSG_GS_OP_EMIT_CUT (3 << 4)
343
 
 
344
 
void ac_build_sendmsg(struct ac_llvm_context *ctx, uint32_t msg, LLVMValueRef wave_id);
 
305
void ac_build_sendmsg(struct ac_llvm_context *ctx, uint32_t imm, LLVMValueRef m0_content);
345
306
 
346
307
LLVMValueRef ac_build_imsb(struct ac_llvm_context *ctx, LLVMValueRef arg, LLVMTypeRef dst_type);
347
308
 
400
361
   ac_atomic_fmax,
401
362
};
402
363
 
403
 
/* These cache policy bits match the definitions used by the LLVM intrinsics. */
404
 
enum ac_image_cache_policy
405
 
{
406
 
   ac_glc = 1 << 0,      /* per-CU cache control */
407
 
   ac_slc = 1 << 1,      /* global L2 cache control */
408
 
   ac_dlc = 1 << 2,      /* per-shader-array cache control */
409
 
   ac_swizzled = 1 << 3, /* the access is swizzled, disabling load/store merging */
410
 
};
411
 
 
412
364
struct ac_image_args {
413
365
   enum ac_image_opcode opcode;
414
366
   enum ac_atomic_op atomic; /* for the ac_image_atomic opcode */
415
367
   enum ac_image_dim dim;
 
368
   enum gl_access_qualifier access;
416
369
   unsigned dmask : 4;
417
 
   unsigned cache_policy : 3;
418
370
   bool unorm : 1;
419
371
   bool level_zero : 1;
420
372
   bool d16 : 1;        /* GFX8+: data and return values are 16-bit */
537
489
 
538
490
LLVMValueRef ac_build_load_helper_invocation(struct ac_llvm_context *ctx);
539
491
 
540
 
LLVMValueRef ac_build_is_helper_invocation(struct ac_llvm_context *ctx);
541
 
 
542
492
LLVMValueRef ac_build_call(struct ac_llvm_context *ctx, LLVMTypeRef fn_type, LLVMValueRef func,
543
493
                           LLVMValueRef *args, unsigned num_args);
544
494
 
560
510
   LLVMValueRef passthrough;
561
511
};
562
512
 
563
 
LLVMValueRef ac_pack_edgeflags_for_export(struct ac_llvm_context *ctx,
564
 
                                          const struct ac_shader_args *args);
565
 
 
566
513
LLVMTypeRef ac_arg_type_to_pointee_type(struct ac_llvm_context *ctx, enum ac_arg_type type);
567
514
 
568
515
static inline LLVMValueRef ac_get_arg(struct ac_llvm_context *ctx, struct ac_arg arg)