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
;
88 LLVMTypeRef iN_wavemask
;
89 LLVMTypeRef iN_ballotmask
;
106 LLVMValueRef i1false
;
108 /* Since ac_nir_translate makes a local copy of ac_llvm_context, there
109 * are two ac_llvm_contexts. Declare a pointer here, so that the control
110 * flow stack is shared by both ac_llvm_contexts.
112 struct ac_llvm_flow_state
*flow
;
114 unsigned range_md_kind
;
115 unsigned invariant_load_md_kind
;
116 unsigned uniform_md_kind
;
117 unsigned fpmath_md_kind
;
118 LLVMValueRef fpmath_md_2p5_ulp
;
119 LLVMValueRef empty_md
;
121 enum chip_class chip_class
;
122 enum radeon_family family
;
125 unsigned ballot_mask_bits
;
133 ac_llvm_context_init(struct ac_llvm_context
*ctx
,
134 struct ac_llvm_compiler
*compiler
,
135 enum chip_class chip_class
, enum radeon_family family
,
136 enum ac_float_mode float_mode
, unsigned wave_size
,
137 unsigned ballot_mask_bits
);
140 ac_llvm_context_dispose(struct ac_llvm_context
*ctx
);
143 ac_get_llvm_num_components(LLVMValueRef value
);
146 ac_get_elem_bits(struct ac_llvm_context
*ctx
, LLVMTypeRef type
);
149 ac_llvm_extract_elem(struct ac_llvm_context
*ac
,
153 unsigned ac_get_type_size(LLVMTypeRef type
);
155 LLVMTypeRef
ac_to_integer_type(struct ac_llvm_context
*ctx
, LLVMTypeRef t
);
156 LLVMValueRef
ac_to_integer(struct ac_llvm_context
*ctx
, LLVMValueRef v
);
157 LLVMValueRef
ac_to_integer_or_pointer(struct ac_llvm_context
*ctx
, LLVMValueRef v
);
158 LLVMTypeRef
ac_to_float_type(struct ac_llvm_context
*ctx
, LLVMTypeRef t
);
159 LLVMValueRef
ac_to_float(struct ac_llvm_context
*ctx
, LLVMValueRef v
);
162 ac_build_intrinsic(struct ac_llvm_context
*ctx
, const char *name
,
163 LLVMTypeRef return_type
, LLVMValueRef
*params
,
164 unsigned param_count
, unsigned attrib_mask
);
166 void ac_build_type_name_for_intr(LLVMTypeRef type
, char *buf
, unsigned bufsize
);
169 ac_build_phi(struct ac_llvm_context
*ctx
, LLVMTypeRef type
,
170 unsigned count_incoming
, LLVMValueRef
*values
,
171 LLVMBasicBlockRef
*blocks
);
173 void ac_build_s_barrier(struct ac_llvm_context
*ctx
);
174 void ac_build_optimization_barrier(struct ac_llvm_context
*ctx
,
175 LLVMValueRef
*pvgpr
);
177 LLVMValueRef
ac_build_shader_clock(struct ac_llvm_context
*ctx
);
179 LLVMValueRef
ac_build_ballot(struct ac_llvm_context
*ctx
, LLVMValueRef value
);
180 LLVMValueRef
ac_get_i1_sgpr_mask(struct ac_llvm_context
*ctx
,
183 LLVMValueRef
ac_build_vote_all(struct ac_llvm_context
*ctx
, LLVMValueRef value
);
185 LLVMValueRef
ac_build_vote_any(struct ac_llvm_context
*ctx
, LLVMValueRef value
);
187 LLVMValueRef
ac_build_vote_eq(struct ac_llvm_context
*ctx
, LLVMValueRef value
);
190 ac_build_varying_gather_values(struct ac_llvm_context
*ctx
, LLVMValueRef
*values
,
191 unsigned value_count
, unsigned component
);
194 ac_build_gather_values_extended(struct ac_llvm_context
*ctx
,
195 LLVMValueRef
*values
,
196 unsigned value_count
,
197 unsigned value_stride
,
201 ac_build_gather_values(struct ac_llvm_context
*ctx
,
202 LLVMValueRef
*values
,
203 unsigned value_count
);
206 ac_extract_components(struct ac_llvm_context
*ctx
,
211 LLVMValueRef
ac_build_expand_to_vec4(struct ac_llvm_context
*ctx
,
213 unsigned num_channels
);
214 LLVMValueRef
ac_build_round(struct ac_llvm_context
*ctx
, LLVMValueRef value
);
217 ac_build_fdiv(struct ac_llvm_context
*ctx
,
221 LLVMValueRef
ac_build_fast_udiv(struct ac_llvm_context
*ctx
,
223 LLVMValueRef multiplier
,
224 LLVMValueRef pre_shift
,
225 LLVMValueRef post_shift
,
226 LLVMValueRef increment
);
227 LLVMValueRef
ac_build_fast_udiv_nuw(struct ac_llvm_context
*ctx
,
229 LLVMValueRef multiplier
,
230 LLVMValueRef pre_shift
,
231 LLVMValueRef post_shift
,
232 LLVMValueRef increment
);
233 LLVMValueRef
ac_build_fast_udiv_u31_d_not_one(struct ac_llvm_context
*ctx
,
235 LLVMValueRef multiplier
,
236 LLVMValueRef post_shift
);
239 ac_prepare_cube_coords(struct ac_llvm_context
*ctx
,
240 bool is_deriv
, bool is_array
, bool is_lod
,
241 LLVMValueRef
*coords_arg
,
242 LLVMValueRef
*derivs_arg
);
246 ac_build_fs_interp(struct ac_llvm_context
*ctx
,
247 LLVMValueRef llvm_chan
,
248 LLVMValueRef attr_number
,
254 ac_build_fs_interp_f16(struct ac_llvm_context
*ctx
,
255 LLVMValueRef llvm_chan
,
256 LLVMValueRef attr_number
,
262 ac_build_fs_interp_mov(struct ac_llvm_context
*ctx
,
263 LLVMValueRef parameter
,
264 LLVMValueRef llvm_chan
,
265 LLVMValueRef attr_number
,
266 LLVMValueRef params
);
269 ac_build_gep_ptr(struct ac_llvm_context
*ctx
,
270 LLVMValueRef base_ptr
,
274 ac_build_gep0(struct ac_llvm_context
*ctx
,
275 LLVMValueRef base_ptr
,
277 LLVMValueRef
ac_build_pointer_add(struct ac_llvm_context
*ctx
, LLVMValueRef ptr
,
281 ac_build_indexed_store(struct ac_llvm_context
*ctx
,
282 LLVMValueRef base_ptr
, LLVMValueRef index
,
285 LLVMValueRef
ac_build_load(struct ac_llvm_context
*ctx
, LLVMValueRef base_ptr
,
287 LLVMValueRef
ac_build_load_invariant(struct ac_llvm_context
*ctx
,
288 LLVMValueRef base_ptr
, LLVMValueRef index
);
289 LLVMValueRef
ac_build_load_to_sgpr(struct ac_llvm_context
*ctx
,
290 LLVMValueRef base_ptr
, LLVMValueRef index
);
291 LLVMValueRef
ac_build_load_to_sgpr_uint_wraparound(struct ac_llvm_context
*ctx
,
292 LLVMValueRef base_ptr
, LLVMValueRef index
);
295 ac_build_buffer_store_dword(struct ac_llvm_context
*ctx
,
298 unsigned num_channels
,
299 LLVMValueRef voffset
,
300 LLVMValueRef soffset
,
301 unsigned inst_offset
,
302 unsigned cache_policy
,
303 bool swizzle_enable_hint
);
306 ac_build_buffer_store_format(struct ac_llvm_context
*ctx
,
310 LLVMValueRef voffset
,
311 unsigned num_channels
,
312 unsigned cache_policy
);
315 ac_build_buffer_load(struct ac_llvm_context
*ctx
,
319 LLVMValueRef voffset
,
320 LLVMValueRef soffset
,
321 unsigned inst_offset
,
322 unsigned cache_policy
,
326 LLVMValueRef
ac_build_buffer_load_format(struct ac_llvm_context
*ctx
,
329 LLVMValueRef voffset
,
330 unsigned num_channels
,
331 unsigned cache_policy
,
335 ac_build_tbuffer_load_short(struct ac_llvm_context
*ctx
,
337 LLVMValueRef voffset
,
338 LLVMValueRef soffset
,
339 LLVMValueRef immoffset
,
340 unsigned cache_policy
);
343 ac_build_tbuffer_load_byte(struct ac_llvm_context
*ctx
,
345 LLVMValueRef voffset
,
346 LLVMValueRef soffset
,
347 LLVMValueRef immoffset
,
348 unsigned cache_policy
);
351 ac_build_struct_tbuffer_load(struct ac_llvm_context
*ctx
,
354 LLVMValueRef voffset
,
355 LLVMValueRef soffset
,
356 LLVMValueRef immoffset
,
357 unsigned num_channels
,
360 unsigned cache_policy
,
364 ac_build_raw_tbuffer_load(struct ac_llvm_context
*ctx
,
366 LLVMValueRef voffset
,
367 LLVMValueRef soffset
,
368 LLVMValueRef immoffset
,
369 unsigned num_channels
,
372 unsigned cache_policy
,
375 /* For ac_build_fetch_format.
377 * Note: FLOAT must be 0 (used for convenience of encoding in radeonsi).
380 AC_FETCH_FORMAT_FLOAT
= 0,
381 AC_FETCH_FORMAT_FIXED
,
382 AC_FETCH_FORMAT_UNORM
,
383 AC_FETCH_FORMAT_SNORM
,
384 AC_FETCH_FORMAT_USCALED
,
385 AC_FETCH_FORMAT_SSCALED
,
386 AC_FETCH_FORMAT_UINT
,
387 AC_FETCH_FORMAT_SINT
,
391 ac_build_opencoded_load_format(struct ac_llvm_context
*ctx
,
393 unsigned num_channels
,
399 LLVMValueRef voffset
,
400 LLVMValueRef soffset
,
401 unsigned cache_policy
,
405 ac_build_tbuffer_store_short(struct ac_llvm_context
*ctx
,
408 LLVMValueRef voffset
,
409 LLVMValueRef soffset
,
410 unsigned cache_policy
);
413 ac_build_tbuffer_store_byte(struct ac_llvm_context
*ctx
,
416 LLVMValueRef voffset
,
417 LLVMValueRef soffset
,
418 unsigned cache_policy
);
421 ac_build_struct_tbuffer_store(struct ac_llvm_context
*ctx
,
425 LLVMValueRef voffset
,
426 LLVMValueRef soffset
,
427 LLVMValueRef immoffset
,
428 unsigned num_channels
,
431 unsigned cache_policy
);
434 ac_build_raw_tbuffer_store(struct ac_llvm_context
*ctx
,
437 LLVMValueRef voffset
,
438 LLVMValueRef soffset
,
439 LLVMValueRef immoffset
,
440 unsigned num_channels
,
443 unsigned cache_policy
);
446 ac_get_thread_id(struct ac_llvm_context
*ctx
);
448 #define AC_TID_MASK_TOP_LEFT 0xfffffffc
449 #define AC_TID_MASK_TOP 0xfffffffd
450 #define AC_TID_MASK_LEFT 0xfffffffe
453 ac_build_ddxy(struct ac_llvm_context
*ctx
,
458 #define AC_SENDMSG_GS 2
459 #define AC_SENDMSG_GS_DONE 3
460 #define AC_SENDMSG_GS_ALLOC_REQ 9
462 #define AC_SENDMSG_GS_OP_NOP (0 << 4)
463 #define AC_SENDMSG_GS_OP_CUT (1 << 4)
464 #define AC_SENDMSG_GS_OP_EMIT (2 << 4)
465 #define AC_SENDMSG_GS_OP_EMIT_CUT (3 << 4)
467 void ac_build_sendmsg(struct ac_llvm_context
*ctx
,
469 LLVMValueRef wave_id
);
471 LLVMValueRef
ac_build_imsb(struct ac_llvm_context
*ctx
,
473 LLVMTypeRef dst_type
);
475 LLVMValueRef
ac_build_umsb(struct ac_llvm_context
*ctx
,
477 LLVMTypeRef dst_type
);
478 LLVMValueRef
ac_build_fmin(struct ac_llvm_context
*ctx
, LLVMValueRef a
,
480 LLVMValueRef
ac_build_fmax(struct ac_llvm_context
*ctx
, LLVMValueRef a
,
482 LLVMValueRef
ac_build_imin(struct ac_llvm_context
*ctx
, LLVMValueRef a
,
484 LLVMValueRef
ac_build_imax(struct ac_llvm_context
*ctx
, LLVMValueRef a
,
486 LLVMValueRef
ac_build_umin(struct ac_llvm_context
*ctx
, LLVMValueRef a
, LLVMValueRef b
);
487 LLVMValueRef
ac_build_umax(struct ac_llvm_context
*ctx
, LLVMValueRef a
, LLVMValueRef b
);
488 LLVMValueRef
ac_build_clamp(struct ac_llvm_context
*ctx
, LLVMValueRef value
);
490 struct ac_export_args
{
493 unsigned enabled_channels
;
499 void ac_build_export(struct ac_llvm_context
*ctx
, struct ac_export_args
*a
);
501 void ac_build_export_null(struct ac_llvm_context
*ctx
);
503 enum ac_image_opcode
{
511 ac_image_get_resinfo
,
513 ac_image_atomic_cmpswap
,
531 /* These cache policy bits match the definitions used by the LLVM intrinsics. */
532 enum ac_image_cache_policy
{
533 ac_glc
= 1 << 0, /* per-CU cache control */
534 ac_slc
= 1 << 1, /* global L2 cache control */
535 ac_dlc
= 1 << 2, /* per-shader-array cache control */
538 struct ac_image_args
{
539 enum ac_image_opcode opcode
: 4;
540 enum ac_atomic_op atomic
: 4; /* for the ac_image_atomic opcode */
541 enum ac_image_dim dim
: 3;
543 unsigned cache_policy
: 3;
546 unsigned attributes
; /* additional call-site specific AC_FUNC_ATTRs */
548 LLVMValueRef resource
;
549 LLVMValueRef sampler
;
550 LLVMValueRef data
[2]; /* data[0] is source data (vector); data[1] is cmp for cmpswap */
553 LLVMValueRef compare
;
554 LLVMValueRef derivs
[6];
555 LLVMValueRef coords
[4];
556 LLVMValueRef lod
; // also used by ac_image_get_resinfo
559 LLVMValueRef
ac_build_image_opcode(struct ac_llvm_context
*ctx
,
560 struct ac_image_args
*a
);
561 LLVMValueRef
ac_build_image_get_sample_count(struct ac_llvm_context
*ctx
,
563 LLVMValueRef
ac_build_cvt_pkrtz_f16(struct ac_llvm_context
*ctx
,
564 LLVMValueRef args
[2]);
565 LLVMValueRef
ac_build_cvt_pknorm_i16(struct ac_llvm_context
*ctx
,
566 LLVMValueRef args
[2]);
567 LLVMValueRef
ac_build_cvt_pknorm_u16(struct ac_llvm_context
*ctx
,
568 LLVMValueRef args
[2]);
569 LLVMValueRef
ac_build_cvt_pk_i16(struct ac_llvm_context
*ctx
,
570 LLVMValueRef args
[2], unsigned bits
, bool hi
);
571 LLVMValueRef
ac_build_cvt_pk_u16(struct ac_llvm_context
*ctx
,
572 LLVMValueRef args
[2], unsigned bits
, bool hi
);
573 LLVMValueRef
ac_build_wqm_vote(struct ac_llvm_context
*ctx
, LLVMValueRef i1
);
574 void ac_build_kill_if_false(struct ac_llvm_context
*ctx
, LLVMValueRef i1
);
575 LLVMValueRef
ac_build_bfe(struct ac_llvm_context
*ctx
, LLVMValueRef input
,
576 LLVMValueRef offset
, LLVMValueRef width
,
578 LLVMValueRef
ac_build_imad(struct ac_llvm_context
*ctx
, LLVMValueRef s0
,
579 LLVMValueRef s1
, LLVMValueRef s2
);
580 LLVMValueRef
ac_build_fmad(struct ac_llvm_context
*ctx
, LLVMValueRef s0
,
581 LLVMValueRef s1
, LLVMValueRef s2
);
583 void ac_build_waitcnt(struct ac_llvm_context
*ctx
, unsigned wait_flags
);
585 LLVMValueRef
ac_build_fract(struct ac_llvm_context
*ctx
, LLVMValueRef src0
,
588 LLVMValueRef
ac_build_fmed3(struct ac_llvm_context
*ctx
, LLVMValueRef src0
,
589 LLVMValueRef src1
, LLVMValueRef src2
,
592 LLVMValueRef
ac_build_isign(struct ac_llvm_context
*ctx
, LLVMValueRef src0
,
595 LLVMValueRef
ac_build_fsign(struct ac_llvm_context
*ctx
, LLVMValueRef src0
,
598 LLVMValueRef
ac_build_bit_count(struct ac_llvm_context
*ctx
, LLVMValueRef src0
);
600 LLVMValueRef
ac_build_bitfield_reverse(struct ac_llvm_context
*ctx
,
603 void ac_optimize_vs_outputs(struct ac_llvm_context
*ac
,
604 LLVMValueRef main_fn
,
605 uint8_t *vs_output_param_offset
,
606 uint32_t num_outputs
,
607 uint8_t *num_param_exports
);
608 void ac_init_exec_full_mask(struct ac_llvm_context
*ctx
);
610 void ac_declare_lds_as_pointer(struct ac_llvm_context
*ac
);
611 LLVMValueRef
ac_lds_load(struct ac_llvm_context
*ctx
,
612 LLVMValueRef dw_addr
);
613 void ac_lds_store(struct ac_llvm_context
*ctx
,
614 LLVMValueRef dw_addr
, LLVMValueRef value
);
616 LLVMValueRef
ac_find_lsb(struct ac_llvm_context
*ctx
,
617 LLVMTypeRef dst_type
,
620 LLVMTypeRef
ac_array_in_const_addr_space(LLVMTypeRef elem_type
);
621 LLVMTypeRef
ac_array_in_const32_addr_space(LLVMTypeRef elem_type
);
623 void ac_build_bgnloop(struct ac_llvm_context
*ctx
, int lable_id
);
624 void ac_build_break(struct ac_llvm_context
*ctx
);
625 void ac_build_continue(struct ac_llvm_context
*ctx
);
626 void ac_build_else(struct ac_llvm_context
*ctx
, int lable_id
);
627 void ac_build_endif(struct ac_llvm_context
*ctx
, int lable_id
);
628 void ac_build_endloop(struct ac_llvm_context
*ctx
, int lable_id
);
629 void ac_build_ifcc(struct ac_llvm_context
*ctx
, LLVMValueRef cond
, int label_id
);
630 void ac_build_if(struct ac_llvm_context
*ctx
, LLVMValueRef value
,
632 void ac_build_uif(struct ac_llvm_context
*ctx
, LLVMValueRef value
,
635 LLVMValueRef
ac_build_alloca(struct ac_llvm_context
*ac
, LLVMTypeRef type
,
637 LLVMValueRef
ac_build_alloca_undef(struct ac_llvm_context
*ac
, LLVMTypeRef type
,
640 LLVMValueRef
ac_cast_ptr(struct ac_llvm_context
*ctx
, LLVMValueRef ptr
,
643 LLVMValueRef
ac_trim_vector(struct ac_llvm_context
*ctx
, LLVMValueRef value
,
646 LLVMValueRef
ac_unpack_param(struct ac_llvm_context
*ctx
, LLVMValueRef param
,
647 unsigned rshift
, unsigned bitwidth
);
649 void ac_apply_fmask_to_sample(struct ac_llvm_context
*ac
, LLVMValueRef fmask
,
650 LLVMValueRef
*addr
, bool is_array_tex
);
653 ac_build_ds_swizzle(struct ac_llvm_context
*ctx
, LLVMValueRef src
, unsigned mask
);
656 ac_build_readlane(struct ac_llvm_context
*ctx
, LLVMValueRef src
, LLVMValueRef lane
);
659 ac_build_writelane(struct ac_llvm_context
*ctx
, LLVMValueRef src
, LLVMValueRef value
, LLVMValueRef lane
);
662 ac_build_mbcnt(struct ac_llvm_context
*ctx
, LLVMValueRef mask
);
665 ac_build_inclusive_scan(struct ac_llvm_context
*ctx
, LLVMValueRef src
, nir_op op
);
668 ac_build_exclusive_scan(struct ac_llvm_context
*ctx
, LLVMValueRef src
, nir_op op
);
671 ac_build_reduce(struct ac_llvm_context
*ctx
, LLVMValueRef src
, nir_op op
, unsigned cluster_size
);
674 * Common arguments for a scan/reduce operation that accumulates per-wave
675 * values across an entire workgroup, while respecting the order of waves.
679 bool enable_exclusive
;
680 bool enable_inclusive
;
682 LLVMValueRef src
; /* clobbered! */
683 LLVMValueRef result_reduce
;
684 LLVMValueRef result_exclusive
;
685 LLVMValueRef result_inclusive
;
687 LLVMValueRef waveidx
;
688 LLVMValueRef numwaves
; /* only needed for "reduce" operations */
690 /* T addrspace(LDS) pointer to the same type as value, at least maxwaves entries */
691 LLVMValueRef scratch
;
696 ac_build_wg_wavescan_top(struct ac_llvm_context
*ctx
, struct ac_wg_scan
*ws
);
698 ac_build_wg_wavescan_bottom(struct ac_llvm_context
*ctx
, struct ac_wg_scan
*ws
);
700 ac_build_wg_wavescan(struct ac_llvm_context
*ctx
, struct ac_wg_scan
*ws
);
703 ac_build_wg_scan_top(struct ac_llvm_context
*ctx
, struct ac_wg_scan
*ws
);
705 ac_build_wg_scan_bottom(struct ac_llvm_context
*ctx
, struct ac_wg_scan
*ws
);
707 ac_build_wg_scan(struct ac_llvm_context
*ctx
, struct ac_wg_scan
*ws
);
710 ac_build_quad_swizzle(struct ac_llvm_context
*ctx
, LLVMValueRef src
,
711 unsigned lane0
, unsigned lane1
, unsigned lane2
, unsigned lane3
);
714 ac_build_shuffle(struct ac_llvm_context
*ctx
, LLVMValueRef src
, LLVMValueRef index
);
717 ac_build_frexp_exp(struct ac_llvm_context
*ctx
, LLVMValueRef src0
,
721 ac_build_frexp_mant(struct ac_llvm_context
*ctx
, LLVMValueRef src0
,
725 ac_build_canonicalize(struct ac_llvm_context
*ctx
, LLVMValueRef src0
,
729 ac_build_ddxy_interp(struct ac_llvm_context
*ctx
, LLVMValueRef interp_ij
);
732 ac_build_load_helper_invocation(struct ac_llvm_context
*ctx
);
734 LLVMValueRef
ac_build_call(struct ac_llvm_context
*ctx
, LLVMValueRef func
,
735 LLVMValueRef
*args
, unsigned num_args
);
737 LLVMValueRef
ac_build_atomic_rmw(struct ac_llvm_context
*ctx
, LLVMAtomicRMWBinOp op
,
738 LLVMValueRef ptr
, LLVMValueRef val
,
739 const char *sync_scope
);
741 LLVMValueRef
ac_build_atomic_cmp_xchg(struct ac_llvm_context
*ctx
, LLVMValueRef ptr
,
742 LLVMValueRef cmp
, LLVMValueRef val
,
743 const char *sync_scope
);
746 ac_export_mrt_z(struct ac_llvm_context
*ctx
, LLVMValueRef depth
,
747 LLVMValueRef stencil
, LLVMValueRef samplemask
,
748 struct ac_export_args
*args
);
750 static inline LLVMValueRef
751 ac_get_arg(struct ac_llvm_context
*ctx
, struct ac_arg arg
)
754 return LLVMGetParam(ctx
->main_function
, arg
.arg_index
);
757 enum ac_llvm_calling_convention
{
758 AC_LLVM_AMDGPU_VS
= 87,
759 AC_LLVM_AMDGPU_GS
= 88,
760 AC_LLVM_AMDGPU_PS
= 89,
761 AC_LLVM_AMDGPU_CS
= 90,
762 AC_LLVM_AMDGPU_HS
= 93,
765 LLVMValueRef
ac_build_main(const struct ac_shader_args
*args
,
766 struct ac_llvm_context
*ctx
,
767 enum ac_llvm_calling_convention convention
,
768 const char *name
, LLVMTypeRef ret_type
,
769 LLVMModuleRef module
);