2 * Copyright 2016 Bas Nieuwenhuizen
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:
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.
20 * The above copyright notice and this permission notice (including the
21 * next paragraph) shall be included in all copies or substantial portions
25 #ifndef AC_LLVM_BUILD_H
26 #define AC_LLVM_BUILD_H
29 #include <llvm-c/Core.h>
30 #include "compiler/nir/nir.h"
31 #include "amd_family.h"
32 #include "ac_shader_util.h"
33 #include "ac_shader_args.h"
34 #include "ac_shader_abi.h"
41 AC_ADDR_SPACE_FLAT
= 0, /* Slower than global. */
42 AC_ADDR_SPACE_GLOBAL
= 1,
43 AC_ADDR_SPACE_GDS
= 2,
44 AC_ADDR_SPACE_LDS
= 3,
45 AC_ADDR_SPACE_CONST
= 4, /* Global allowing SMEM. */
46 AC_ADDR_SPACE_CONST_32BIT
= 6, /* same as CONST, but the pointer type has 32 bits */
49 #define AC_WAIT_LGKM (1 << 0) /* LDS, GDS, constant, message */
50 #define AC_WAIT_VLOAD (1 << 1) /* VMEM load/sample instructions */
51 #define AC_WAIT_VSTORE (1 << 2) /* VMEM store instructions */
54 struct ac_llvm_compiler
;
57 struct ac_llvm_flow_state
{
58 struct ac_llvm_flow
*stack
;
63 struct ac_llvm_context
{
64 LLVMContextRef context
;
66 LLVMBuilderRef builder
;
68 LLVMValueRef main_function
;
89 LLVMTypeRef iN_wavemask
;
90 LLVMTypeRef iN_ballotmask
;
109 LLVMValueRef i1false
;
111 /* Temporary helper to implement demote_to_helper:
113 * False = demoted lanes
115 LLVMValueRef postponed_kill
;
117 /* Since ac_nir_translate makes a local copy of ac_llvm_context, there
118 * are two ac_llvm_contexts. Declare a pointer here, so that the control
119 * flow stack is shared by both ac_llvm_contexts.
121 struct ac_llvm_flow_state
*flow
;
123 unsigned range_md_kind
;
124 unsigned invariant_load_md_kind
;
125 unsigned uniform_md_kind
;
126 unsigned fpmath_md_kind
;
127 LLVMValueRef fpmath_md_2p5_ulp
;
128 LLVMValueRef empty_md
;
130 enum chip_class chip_class
;
131 enum radeon_family family
;
134 unsigned ballot_mask_bits
;
142 ac_llvm_context_init(struct ac_llvm_context
*ctx
,
143 struct ac_llvm_compiler
*compiler
,
144 enum chip_class chip_class
, enum radeon_family family
,
145 enum ac_float_mode float_mode
, unsigned wave_size
,
146 unsigned ballot_mask_bits
);
149 ac_llvm_context_dispose(struct ac_llvm_context
*ctx
);
152 ac_get_llvm_num_components(LLVMValueRef value
);
155 ac_get_elem_bits(struct ac_llvm_context
*ctx
, LLVMTypeRef type
);
158 ac_llvm_extract_elem(struct ac_llvm_context
*ac
,
162 unsigned ac_get_type_size(LLVMTypeRef type
);
164 LLVMTypeRef
ac_to_integer_type(struct ac_llvm_context
*ctx
, LLVMTypeRef t
);
165 LLVMValueRef
ac_to_integer(struct ac_llvm_context
*ctx
, LLVMValueRef v
);
166 LLVMValueRef
ac_to_integer_or_pointer(struct ac_llvm_context
*ctx
, LLVMValueRef v
);
167 LLVMTypeRef
ac_to_float_type(struct ac_llvm_context
*ctx
, LLVMTypeRef t
);
168 LLVMValueRef
ac_to_float(struct ac_llvm_context
*ctx
, LLVMValueRef v
);
171 ac_build_intrinsic(struct ac_llvm_context
*ctx
, const char *name
,
172 LLVMTypeRef return_type
, LLVMValueRef
*params
,
173 unsigned param_count
, unsigned attrib_mask
);
175 void ac_build_type_name_for_intr(LLVMTypeRef type
, char *buf
, unsigned bufsize
);
178 ac_build_phi(struct ac_llvm_context
*ctx
, LLVMTypeRef type
,
179 unsigned count_incoming
, LLVMValueRef
*values
,
180 LLVMBasicBlockRef
*blocks
);
182 void ac_build_s_barrier(struct ac_llvm_context
*ctx
);
183 void ac_build_optimization_barrier(struct ac_llvm_context
*ctx
,
184 LLVMValueRef
*pvgpr
);
186 LLVMValueRef
ac_build_shader_clock(struct ac_llvm_context
*ctx
);
188 LLVMValueRef
ac_build_ballot(struct ac_llvm_context
*ctx
, LLVMValueRef value
);
189 LLVMValueRef
ac_get_i1_sgpr_mask(struct ac_llvm_context
*ctx
,
192 LLVMValueRef
ac_build_vote_all(struct ac_llvm_context
*ctx
, LLVMValueRef value
);
194 LLVMValueRef
ac_build_vote_any(struct ac_llvm_context
*ctx
, LLVMValueRef value
);
196 LLVMValueRef
ac_build_vote_eq(struct ac_llvm_context
*ctx
, LLVMValueRef value
);
199 ac_build_varying_gather_values(struct ac_llvm_context
*ctx
, LLVMValueRef
*values
,
200 unsigned value_count
, unsigned component
);
203 ac_build_gather_values_extended(struct ac_llvm_context
*ctx
,
204 LLVMValueRef
*values
,
205 unsigned value_count
,
206 unsigned value_stride
,
210 ac_build_gather_values(struct ac_llvm_context
*ctx
,
211 LLVMValueRef
*values
,
212 unsigned value_count
);
215 ac_extract_components(struct ac_llvm_context
*ctx
,
220 LLVMValueRef
ac_build_expand_to_vec4(struct ac_llvm_context
*ctx
,
222 unsigned num_channels
);
223 LLVMValueRef
ac_build_round(struct ac_llvm_context
*ctx
, LLVMValueRef value
);
226 ac_build_fdiv(struct ac_llvm_context
*ctx
,
230 LLVMValueRef
ac_build_fast_udiv(struct ac_llvm_context
*ctx
,
232 LLVMValueRef multiplier
,
233 LLVMValueRef pre_shift
,
234 LLVMValueRef post_shift
,
235 LLVMValueRef increment
);
236 LLVMValueRef
ac_build_fast_udiv_nuw(struct ac_llvm_context
*ctx
,
238 LLVMValueRef multiplier
,
239 LLVMValueRef pre_shift
,
240 LLVMValueRef post_shift
,
241 LLVMValueRef increment
);
242 LLVMValueRef
ac_build_fast_udiv_u31_d_not_one(struct ac_llvm_context
*ctx
,
244 LLVMValueRef multiplier
,
245 LLVMValueRef post_shift
);
248 ac_prepare_cube_coords(struct ac_llvm_context
*ctx
,
249 bool is_deriv
, bool is_array
, bool is_lod
,
250 LLVMValueRef
*coords_arg
,
251 LLVMValueRef
*derivs_arg
);
255 ac_build_fs_interp(struct ac_llvm_context
*ctx
,
256 LLVMValueRef llvm_chan
,
257 LLVMValueRef attr_number
,
263 ac_build_fs_interp_f16(struct ac_llvm_context
*ctx
,
264 LLVMValueRef llvm_chan
,
265 LLVMValueRef attr_number
,
271 ac_build_fs_interp_mov(struct ac_llvm_context
*ctx
,
272 LLVMValueRef parameter
,
273 LLVMValueRef llvm_chan
,
274 LLVMValueRef attr_number
,
275 LLVMValueRef params
);
278 ac_build_gep_ptr(struct ac_llvm_context
*ctx
,
279 LLVMValueRef base_ptr
,
283 ac_build_gep0(struct ac_llvm_context
*ctx
,
284 LLVMValueRef base_ptr
,
286 LLVMValueRef
ac_build_pointer_add(struct ac_llvm_context
*ctx
, LLVMValueRef ptr
,
290 ac_build_indexed_store(struct ac_llvm_context
*ctx
,
291 LLVMValueRef base_ptr
, LLVMValueRef index
,
294 LLVMValueRef
ac_build_load(struct ac_llvm_context
*ctx
, LLVMValueRef base_ptr
,
296 LLVMValueRef
ac_build_load_invariant(struct ac_llvm_context
*ctx
,
297 LLVMValueRef base_ptr
, LLVMValueRef index
);
298 LLVMValueRef
ac_build_load_to_sgpr(struct ac_llvm_context
*ctx
,
299 LLVMValueRef base_ptr
, LLVMValueRef index
);
300 LLVMValueRef
ac_build_load_to_sgpr_uint_wraparound(struct ac_llvm_context
*ctx
,
301 LLVMValueRef base_ptr
, LLVMValueRef index
);
304 ac_build_buffer_store_dword(struct ac_llvm_context
*ctx
,
307 unsigned num_channels
,
308 LLVMValueRef voffset
,
309 LLVMValueRef soffset
,
310 unsigned inst_offset
,
311 unsigned cache_policy
);
314 ac_build_buffer_store_format(struct ac_llvm_context
*ctx
,
318 LLVMValueRef voffset
,
319 unsigned num_channels
,
320 unsigned cache_policy
);
323 ac_build_buffer_load(struct ac_llvm_context
*ctx
,
327 LLVMValueRef voffset
,
328 LLVMValueRef soffset
,
329 unsigned inst_offset
,
330 unsigned cache_policy
,
334 LLVMValueRef
ac_build_buffer_load_format(struct ac_llvm_context
*ctx
,
337 LLVMValueRef voffset
,
338 unsigned num_channels
,
339 unsigned cache_policy
,
343 ac_build_tbuffer_load_short(struct ac_llvm_context
*ctx
,
345 LLVMValueRef voffset
,
346 LLVMValueRef soffset
,
347 LLVMValueRef immoffset
,
348 unsigned cache_policy
);
351 ac_build_tbuffer_load_byte(struct ac_llvm_context
*ctx
,
353 LLVMValueRef voffset
,
354 LLVMValueRef soffset
,
355 LLVMValueRef immoffset
,
356 unsigned cache_policy
);
359 ac_build_struct_tbuffer_load(struct ac_llvm_context
*ctx
,
362 LLVMValueRef voffset
,
363 LLVMValueRef soffset
,
364 LLVMValueRef immoffset
,
365 unsigned num_channels
,
368 unsigned cache_policy
,
372 ac_build_raw_tbuffer_load(struct ac_llvm_context
*ctx
,
374 LLVMValueRef voffset
,
375 LLVMValueRef soffset
,
376 LLVMValueRef immoffset
,
377 unsigned num_channels
,
380 unsigned cache_policy
,
383 /* For ac_build_fetch_format.
385 * Note: FLOAT must be 0 (used for convenience of encoding in radeonsi).
388 AC_FETCH_FORMAT_FLOAT
= 0,
389 AC_FETCH_FORMAT_FIXED
,
390 AC_FETCH_FORMAT_UNORM
,
391 AC_FETCH_FORMAT_SNORM
,
392 AC_FETCH_FORMAT_USCALED
,
393 AC_FETCH_FORMAT_SSCALED
,
394 AC_FETCH_FORMAT_UINT
,
395 AC_FETCH_FORMAT_SINT
,
399 ac_build_opencoded_load_format(struct ac_llvm_context
*ctx
,
401 unsigned num_channels
,
407 LLVMValueRef voffset
,
408 LLVMValueRef soffset
,
409 unsigned cache_policy
,
413 ac_build_tbuffer_store_short(struct ac_llvm_context
*ctx
,
416 LLVMValueRef voffset
,
417 LLVMValueRef soffset
,
418 unsigned cache_policy
);
421 ac_build_tbuffer_store_byte(struct ac_llvm_context
*ctx
,
424 LLVMValueRef voffset
,
425 LLVMValueRef soffset
,
426 unsigned cache_policy
);
429 ac_build_struct_tbuffer_store(struct ac_llvm_context
*ctx
,
433 LLVMValueRef voffset
,
434 LLVMValueRef soffset
,
435 LLVMValueRef immoffset
,
436 unsigned num_channels
,
439 unsigned cache_policy
);
442 ac_build_raw_tbuffer_store(struct ac_llvm_context
*ctx
,
445 LLVMValueRef voffset
,
446 LLVMValueRef soffset
,
447 LLVMValueRef immoffset
,
448 unsigned num_channels
,
451 unsigned cache_policy
);
454 ac_get_thread_id(struct ac_llvm_context
*ctx
);
456 #define AC_TID_MASK_TOP_LEFT 0xfffffffc
457 #define AC_TID_MASK_TOP 0xfffffffd
458 #define AC_TID_MASK_LEFT 0xfffffffe
461 ac_build_ddxy(struct ac_llvm_context
*ctx
,
466 #define AC_SENDMSG_GS 2
467 #define AC_SENDMSG_GS_DONE 3
468 #define AC_SENDMSG_GS_ALLOC_REQ 9
470 #define AC_SENDMSG_GS_OP_NOP (0 << 4)
471 #define AC_SENDMSG_GS_OP_CUT (1 << 4)
472 #define AC_SENDMSG_GS_OP_EMIT (2 << 4)
473 #define AC_SENDMSG_GS_OP_EMIT_CUT (3 << 4)
475 void ac_build_sendmsg(struct ac_llvm_context
*ctx
,
477 LLVMValueRef wave_id
);
479 LLVMValueRef
ac_build_imsb(struct ac_llvm_context
*ctx
,
481 LLVMTypeRef dst_type
);
483 LLVMValueRef
ac_build_umsb(struct ac_llvm_context
*ctx
,
485 LLVMTypeRef dst_type
);
486 LLVMValueRef
ac_build_fmin(struct ac_llvm_context
*ctx
, LLVMValueRef a
,
488 LLVMValueRef
ac_build_fmax(struct ac_llvm_context
*ctx
, LLVMValueRef a
,
490 LLVMValueRef
ac_build_imin(struct ac_llvm_context
*ctx
, LLVMValueRef a
,
492 LLVMValueRef
ac_build_imax(struct ac_llvm_context
*ctx
, LLVMValueRef a
,
494 LLVMValueRef
ac_build_umin(struct ac_llvm_context
*ctx
, LLVMValueRef a
, LLVMValueRef b
);
495 LLVMValueRef
ac_build_umax(struct ac_llvm_context
*ctx
, LLVMValueRef a
, LLVMValueRef b
);
496 LLVMValueRef
ac_build_clamp(struct ac_llvm_context
*ctx
, LLVMValueRef value
);
498 struct ac_export_args
{
501 unsigned enabled_channels
;
507 void ac_build_export(struct ac_llvm_context
*ctx
, struct ac_export_args
*a
);
509 void ac_build_export_null(struct ac_llvm_context
*ctx
);
511 enum ac_image_opcode
{
519 ac_image_get_resinfo
,
521 ac_image_atomic_cmpswap
,
539 /* These cache policy bits match the definitions used by the LLVM intrinsics. */
540 enum ac_image_cache_policy
{
541 ac_glc
= 1 << 0, /* per-CU cache control */
542 ac_slc
= 1 << 1, /* global L2 cache control */
543 ac_dlc
= 1 << 2, /* per-shader-array cache control */
544 ac_swizzled
= 1 << 3, /* the access is swizzled, disabling load/store merging */
547 struct ac_image_args
{
548 enum ac_image_opcode opcode
: 4;
549 enum ac_atomic_op atomic
: 4; /* for the ac_image_atomic opcode */
550 enum ac_image_dim dim
: 3;
552 unsigned cache_policy
: 3;
555 unsigned attributes
; /* additional call-site specific AC_FUNC_ATTRs */
557 LLVMValueRef resource
;
558 LLVMValueRef sampler
;
559 LLVMValueRef data
[2]; /* data[0] is source data (vector); data[1] is cmp for cmpswap */
562 LLVMValueRef compare
;
563 LLVMValueRef derivs
[6];
564 LLVMValueRef coords
[4];
565 LLVMValueRef lod
; // also used by ac_image_get_resinfo
568 LLVMValueRef
ac_build_image_opcode(struct ac_llvm_context
*ctx
,
569 struct ac_image_args
*a
);
570 LLVMValueRef
ac_build_image_get_sample_count(struct ac_llvm_context
*ctx
,
572 LLVMValueRef
ac_build_cvt_pkrtz_f16(struct ac_llvm_context
*ctx
,
573 LLVMValueRef args
[2]);
574 LLVMValueRef
ac_build_cvt_pknorm_i16(struct ac_llvm_context
*ctx
,
575 LLVMValueRef args
[2]);
576 LLVMValueRef
ac_build_cvt_pknorm_u16(struct ac_llvm_context
*ctx
,
577 LLVMValueRef args
[2]);
578 LLVMValueRef
ac_build_cvt_pk_i16(struct ac_llvm_context
*ctx
,
579 LLVMValueRef args
[2], unsigned bits
, bool hi
);
580 LLVMValueRef
ac_build_cvt_pk_u16(struct ac_llvm_context
*ctx
,
581 LLVMValueRef args
[2], unsigned bits
, bool hi
);
582 LLVMValueRef
ac_build_wqm_vote(struct ac_llvm_context
*ctx
, LLVMValueRef i1
);
583 void ac_build_kill_if_false(struct ac_llvm_context
*ctx
, LLVMValueRef i1
);
584 LLVMValueRef
ac_build_bfe(struct ac_llvm_context
*ctx
, LLVMValueRef input
,
585 LLVMValueRef offset
, LLVMValueRef width
,
587 LLVMValueRef
ac_build_imad(struct ac_llvm_context
*ctx
, LLVMValueRef s0
,
588 LLVMValueRef s1
, LLVMValueRef s2
);
589 LLVMValueRef
ac_build_fmad(struct ac_llvm_context
*ctx
, LLVMValueRef s0
,
590 LLVMValueRef s1
, LLVMValueRef s2
);
592 void ac_build_waitcnt(struct ac_llvm_context
*ctx
, unsigned wait_flags
);
594 LLVMValueRef
ac_build_fract(struct ac_llvm_context
*ctx
, LLVMValueRef src0
,
597 LLVMValueRef
ac_build_fmed3(struct ac_llvm_context
*ctx
, LLVMValueRef src0
,
598 LLVMValueRef src1
, LLVMValueRef src2
,
601 LLVMValueRef
ac_build_isign(struct ac_llvm_context
*ctx
, LLVMValueRef src0
,
604 LLVMValueRef
ac_build_fsign(struct ac_llvm_context
*ctx
, LLVMValueRef src0
,
607 LLVMValueRef
ac_build_bit_count(struct ac_llvm_context
*ctx
, LLVMValueRef src0
);
609 LLVMValueRef
ac_build_bitfield_reverse(struct ac_llvm_context
*ctx
,
612 void ac_optimize_vs_outputs(struct ac_llvm_context
*ac
,
613 LLVMValueRef main_fn
,
614 uint8_t *vs_output_param_offset
,
615 uint32_t num_outputs
,
616 uint8_t *num_param_exports
);
617 void ac_init_exec_full_mask(struct ac_llvm_context
*ctx
);
619 void ac_declare_lds_as_pointer(struct ac_llvm_context
*ac
);
620 LLVMValueRef
ac_lds_load(struct ac_llvm_context
*ctx
,
621 LLVMValueRef dw_addr
);
622 void ac_lds_store(struct ac_llvm_context
*ctx
,
623 LLVMValueRef dw_addr
, LLVMValueRef value
);
625 LLVMValueRef
ac_find_lsb(struct ac_llvm_context
*ctx
,
626 LLVMTypeRef dst_type
,
629 LLVMTypeRef
ac_array_in_const_addr_space(LLVMTypeRef elem_type
);
630 LLVMTypeRef
ac_array_in_const32_addr_space(LLVMTypeRef elem_type
);
632 void ac_build_bgnloop(struct ac_llvm_context
*ctx
, int lable_id
);
633 void ac_build_break(struct ac_llvm_context
*ctx
);
634 void ac_build_continue(struct ac_llvm_context
*ctx
);
635 void ac_build_else(struct ac_llvm_context
*ctx
, int lable_id
);
636 void ac_build_endif(struct ac_llvm_context
*ctx
, int lable_id
);
637 void ac_build_endloop(struct ac_llvm_context
*ctx
, int lable_id
);
638 void ac_build_ifcc(struct ac_llvm_context
*ctx
, LLVMValueRef cond
, int label_id
);
639 void ac_build_if(struct ac_llvm_context
*ctx
, LLVMValueRef value
,
641 void ac_build_uif(struct ac_llvm_context
*ctx
, LLVMValueRef value
,
644 LLVMValueRef
ac_build_alloca(struct ac_llvm_context
*ac
, LLVMTypeRef type
,
646 LLVMValueRef
ac_build_alloca_undef(struct ac_llvm_context
*ac
, LLVMTypeRef type
,
649 LLVMValueRef
ac_cast_ptr(struct ac_llvm_context
*ctx
, LLVMValueRef ptr
,
652 LLVMValueRef
ac_trim_vector(struct ac_llvm_context
*ctx
, LLVMValueRef value
,
655 LLVMValueRef
ac_unpack_param(struct ac_llvm_context
*ctx
, LLVMValueRef param
,
656 unsigned rshift
, unsigned bitwidth
);
658 void ac_apply_fmask_to_sample(struct ac_llvm_context
*ac
, LLVMValueRef fmask
,
659 LLVMValueRef
*addr
, bool is_array_tex
);
662 ac_build_ds_swizzle(struct ac_llvm_context
*ctx
, LLVMValueRef src
, unsigned mask
);
664 LLVMValueRef
ac_build_readlane_no_opt_barrier(struct ac_llvm_context
*ctx
,
665 LLVMValueRef src
, LLVMValueRef lane
);
668 ac_build_readlane(struct ac_llvm_context
*ctx
, LLVMValueRef src
, LLVMValueRef lane
);
671 ac_build_writelane(struct ac_llvm_context
*ctx
, LLVMValueRef src
, LLVMValueRef value
, LLVMValueRef lane
);
674 ac_build_mbcnt(struct ac_llvm_context
*ctx
, LLVMValueRef mask
);
677 ac_build_inclusive_scan(struct ac_llvm_context
*ctx
, LLVMValueRef src
, nir_op op
);
680 ac_build_exclusive_scan(struct ac_llvm_context
*ctx
, LLVMValueRef src
, nir_op op
);
683 ac_build_reduce(struct ac_llvm_context
*ctx
, LLVMValueRef src
, nir_op op
, unsigned cluster_size
);
686 * Common arguments for a scan/reduce operation that accumulates per-wave
687 * values across an entire workgroup, while respecting the order of waves.
691 bool enable_exclusive
;
692 bool enable_inclusive
;
694 LLVMValueRef src
; /* clobbered! */
695 LLVMValueRef result_reduce
;
696 LLVMValueRef result_exclusive
;
697 LLVMValueRef result_inclusive
;
699 LLVMValueRef waveidx
;
700 LLVMValueRef numwaves
; /* only needed for "reduce" operations */
702 /* T addrspace(LDS) pointer to the same type as value, at least maxwaves entries */
703 LLVMValueRef scratch
;
708 ac_build_wg_wavescan_top(struct ac_llvm_context
*ctx
, struct ac_wg_scan
*ws
);
710 ac_build_wg_wavescan_bottom(struct ac_llvm_context
*ctx
, struct ac_wg_scan
*ws
);
712 ac_build_wg_wavescan(struct ac_llvm_context
*ctx
, struct ac_wg_scan
*ws
);
715 ac_build_wg_scan_top(struct ac_llvm_context
*ctx
, struct ac_wg_scan
*ws
);
717 ac_build_wg_scan_bottom(struct ac_llvm_context
*ctx
, struct ac_wg_scan
*ws
);
719 ac_build_wg_scan(struct ac_llvm_context
*ctx
, struct ac_wg_scan
*ws
);
722 ac_build_quad_swizzle(struct ac_llvm_context
*ctx
, LLVMValueRef src
,
723 unsigned lane0
, unsigned lane1
, unsigned lane2
, unsigned lane3
);
726 ac_build_shuffle(struct ac_llvm_context
*ctx
, LLVMValueRef src
, LLVMValueRef index
);
729 ac_build_frexp_exp(struct ac_llvm_context
*ctx
, LLVMValueRef src0
,
733 ac_build_frexp_mant(struct ac_llvm_context
*ctx
, LLVMValueRef src0
,
737 ac_build_canonicalize(struct ac_llvm_context
*ctx
, LLVMValueRef src0
,
741 ac_build_ddxy_interp(struct ac_llvm_context
*ctx
, LLVMValueRef interp_ij
);
744 ac_build_load_helper_invocation(struct ac_llvm_context
*ctx
);
747 ac_build_is_helper_invocation(struct ac_llvm_context
*ctx
);
749 LLVMValueRef
ac_build_call(struct ac_llvm_context
*ctx
, LLVMValueRef func
,
750 LLVMValueRef
*args
, unsigned num_args
);
752 LLVMValueRef
ac_build_atomic_rmw(struct ac_llvm_context
*ctx
, LLVMAtomicRMWBinOp op
,
753 LLVMValueRef ptr
, LLVMValueRef val
,
754 const char *sync_scope
);
756 LLVMValueRef
ac_build_atomic_cmp_xchg(struct ac_llvm_context
*ctx
, LLVMValueRef ptr
,
757 LLVMValueRef cmp
, LLVMValueRef val
,
758 const char *sync_scope
);
761 ac_export_mrt_z(struct ac_llvm_context
*ctx
, LLVMValueRef depth
,
762 LLVMValueRef stencil
, LLVMValueRef samplemask
,
763 struct ac_export_args
*args
);
765 void ac_build_sendmsg_gs_alloc_req(struct ac_llvm_context
*ctx
, LLVMValueRef wave_id
,
766 LLVMValueRef vtx_cnt
, LLVMValueRef prim_cnt
);
769 unsigned num_vertices
;
771 LLVMValueRef index
[3];
772 LLVMValueRef edgeflag
[3];
773 LLVMValueRef passthrough
;
776 LLVMValueRef
ac_pack_prim_export(struct ac_llvm_context
*ctx
,
777 const struct ac_ngg_prim
*prim
);
778 void ac_build_export_prim(struct ac_llvm_context
*ctx
,
779 const struct ac_ngg_prim
*prim
);
781 static inline LLVMValueRef
782 ac_get_arg(struct ac_llvm_context
*ctx
, struct ac_arg arg
)
785 return LLVMGetParam(ctx
->main_function
, arg
.arg_index
);
788 enum ac_llvm_calling_convention
{
789 AC_LLVM_AMDGPU_VS
= 87,
790 AC_LLVM_AMDGPU_GS
= 88,
791 AC_LLVM_AMDGPU_PS
= 89,
792 AC_LLVM_AMDGPU_CS
= 90,
793 AC_LLVM_AMDGPU_HS
= 93,
796 LLVMValueRef
ac_build_main(const struct ac_shader_args
*args
,
797 struct ac_llvm_context
*ctx
,
798 enum ac_llvm_calling_convention convention
,
799 const char *name
, LLVMTypeRef ret_type
,
800 LLVMModuleRef module
);
801 void ac_build_s_endpgm(struct ac_llvm_context
*ctx
);
803 LLVMValueRef
ac_prefix_bitcount(struct ac_llvm_context
*ctx
,
804 LLVMValueRef mask
, LLVMValueRef index
);
805 LLVMValueRef
ac_prefix_bitcount_2x64(struct ac_llvm_context
*ctx
,
806 LLVMValueRef mask
[2], LLVMValueRef index
);
807 void ac_build_triangle_strip_indices_to_triangle(struct ac_llvm_context
*ctx
,
809 LLVMValueRef flatshade_first
,
810 LLVMValueRef index
[3]);