amd/llvm: switch to 3-spaces style
Follow-up of !4319 using the same clang-format config. Acked-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Acked-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5310>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -25,19 +25,21 @@
|
||||
#ifndef AC_LLVM_BUILD_H
|
||||
#define AC_LLVM_BUILD_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <llvm-c/Core.h>
|
||||
#include "compiler/nir/nir.h"
|
||||
#include "amd_family.h"
|
||||
#include "ac_shader_util.h"
|
||||
#include "ac_shader_args.h"
|
||||
#include "ac_shader_abi.h"
|
||||
#include "ac_shader_args.h"
|
||||
#include "ac_shader_util.h"
|
||||
#include "amd_family.h"
|
||||
#include "compiler/nir/nir.h"
|
||||
#include <llvm-c/Core.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
AC_ADDR_SPACE_FLAT = 0, /* Slower than global. */
|
||||
AC_ADDR_SPACE_GLOBAL = 1,
|
||||
AC_ADDR_SPACE_GDS = 2,
|
||||
@@ -139,26 +141,18 @@ struct ac_llvm_context {
|
||||
LLVMValueRef lds;
|
||||
};
|
||||
|
||||
void
|
||||
ac_llvm_context_init(struct ac_llvm_context *ctx,
|
||||
struct ac_llvm_compiler *compiler,
|
||||
void ac_llvm_context_init(struct ac_llvm_context *ctx, struct ac_llvm_compiler *compiler,
|
||||
enum chip_class chip_class, enum radeon_family family,
|
||||
enum ac_float_mode float_mode, unsigned wave_size,
|
||||
unsigned ballot_mask_bits);
|
||||
|
||||
void
|
||||
ac_llvm_context_dispose(struct ac_llvm_context *ctx);
|
||||
void ac_llvm_context_dispose(struct ac_llvm_context *ctx);
|
||||
|
||||
int
|
||||
ac_get_llvm_num_components(LLVMValueRef value);
|
||||
int ac_get_llvm_num_components(LLVMValueRef value);
|
||||
|
||||
int
|
||||
ac_get_elem_bits(struct ac_llvm_context *ctx, LLVMTypeRef type);
|
||||
int ac_get_elem_bits(struct ac_llvm_context *ctx, LLVMTypeRef type);
|
||||
|
||||
LLVMValueRef
|
||||
ac_llvm_extract_elem(struct ac_llvm_context *ac,
|
||||
LLVMValueRef value,
|
||||
int index);
|
||||
LLVMValueRef ac_llvm_extract_elem(struct ac_llvm_context *ac, LLVMValueRef value, int index);
|
||||
|
||||
unsigned ac_get_type_size(LLVMTypeRef type);
|
||||
|
||||
@@ -168,28 +162,22 @@ LLVMValueRef ac_to_integer_or_pointer(struct ac_llvm_context *ctx, LLVMValueRef
|
||||
LLVMTypeRef ac_to_float_type(struct ac_llvm_context *ctx, LLVMTypeRef t);
|
||||
LLVMValueRef ac_to_float(struct ac_llvm_context *ctx, LLVMValueRef v);
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_intrinsic(struct ac_llvm_context *ctx, const char *name,
|
||||
LLVMTypeRef return_type, LLVMValueRef *params,
|
||||
unsigned param_count, unsigned attrib_mask);
|
||||
LLVMValueRef ac_build_intrinsic(struct ac_llvm_context *ctx, const char *name,
|
||||
LLVMTypeRef return_type, LLVMValueRef *params, unsigned param_count,
|
||||
unsigned attrib_mask);
|
||||
|
||||
void ac_build_type_name_for_intr(LLVMTypeRef type, char *buf, unsigned bufsize);
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_phi(struct ac_llvm_context *ctx, LLVMTypeRef type,
|
||||
unsigned count_incoming, LLVMValueRef *values,
|
||||
LLVMBasicBlockRef *blocks);
|
||||
LLVMValueRef ac_build_phi(struct ac_llvm_context *ctx, LLVMTypeRef type, unsigned count_incoming,
|
||||
LLVMValueRef *values, LLVMBasicBlockRef *blocks);
|
||||
|
||||
void ac_build_s_barrier(struct ac_llvm_context *ctx);
|
||||
void ac_build_optimization_barrier(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef *pvgpr);
|
||||
void ac_build_optimization_barrier(struct ac_llvm_context *ctx, LLVMValueRef *pvgpr);
|
||||
|
||||
LLVMValueRef ac_build_shader_clock(struct ac_llvm_context *ctx,
|
||||
nir_scope scope);
|
||||
LLVMValueRef ac_build_shader_clock(struct ac_llvm_context *ctx, nir_scope scope);
|
||||
|
||||
LLVMValueRef ac_build_ballot(struct ac_llvm_context *ctx, LLVMValueRef value);
|
||||
LLVMValueRef ac_get_i1_sgpr_mask(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef value);
|
||||
LLVMValueRef ac_get_i1_sgpr_mask(struct ac_llvm_context *ctx, LLVMValueRef value);
|
||||
|
||||
LLVMValueRef ac_build_vote_all(struct ac_llvm_context *ctx, LLVMValueRef value);
|
||||
|
||||
@@ -197,196 +185,108 @@ LLVMValueRef ac_build_vote_any(struct ac_llvm_context *ctx, LLVMValueRef value);
|
||||
|
||||
LLVMValueRef ac_build_vote_eq(struct ac_llvm_context *ctx, LLVMValueRef value);
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_varying_gather_values(struct ac_llvm_context *ctx, LLVMValueRef *values,
|
||||
LLVMValueRef ac_build_varying_gather_values(struct ac_llvm_context *ctx, LLVMValueRef *values,
|
||||
unsigned value_count, unsigned component);
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_gather_values_extended(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef *values,
|
||||
unsigned value_count,
|
||||
unsigned value_stride,
|
||||
bool load,
|
||||
LLVMValueRef ac_build_gather_values_extended(struct ac_llvm_context *ctx, LLVMValueRef *values,
|
||||
unsigned value_count, unsigned value_stride, bool load,
|
||||
bool always_vector);
|
||||
LLVMValueRef
|
||||
ac_build_gather_values(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef *values,
|
||||
LLVMValueRef ac_build_gather_values(struct ac_llvm_context *ctx, LLVMValueRef *values,
|
||||
unsigned value_count);
|
||||
|
||||
LLVMValueRef
|
||||
ac_extract_components(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef value,
|
||||
unsigned start,
|
||||
LLVMValueRef ac_extract_components(struct ac_llvm_context *ctx, LLVMValueRef value, unsigned start,
|
||||
unsigned channels);
|
||||
|
||||
LLVMValueRef ac_build_expand_to_vec4(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef value,
|
||||
LLVMValueRef ac_build_expand_to_vec4(struct ac_llvm_context *ctx, LLVMValueRef value,
|
||||
unsigned num_channels);
|
||||
LLVMValueRef ac_build_round(struct ac_llvm_context *ctx, LLVMValueRef value);
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_fdiv(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef num,
|
||||
LLVMValueRef den);
|
||||
LLVMValueRef ac_build_fdiv(struct ac_llvm_context *ctx, LLVMValueRef num, LLVMValueRef den);
|
||||
|
||||
LLVMValueRef ac_build_fast_udiv(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef num,
|
||||
LLVMValueRef multiplier,
|
||||
LLVMValueRef pre_shift,
|
||||
LLVMValueRef post_shift,
|
||||
LLVMValueRef increment);
|
||||
LLVMValueRef ac_build_fast_udiv_nuw(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef num,
|
||||
LLVMValueRef multiplier,
|
||||
LLVMValueRef pre_shift,
|
||||
LLVMValueRef post_shift,
|
||||
LLVMValueRef increment);
|
||||
LLVMValueRef ac_build_fast_udiv_u31_d_not_one(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef num,
|
||||
LLVMValueRef multiplier,
|
||||
LLVMValueRef post_shift);
|
||||
LLVMValueRef ac_build_fast_udiv(struct ac_llvm_context *ctx, LLVMValueRef num,
|
||||
LLVMValueRef multiplier, LLVMValueRef pre_shift,
|
||||
LLVMValueRef post_shift, LLVMValueRef increment);
|
||||
LLVMValueRef ac_build_fast_udiv_nuw(struct ac_llvm_context *ctx, LLVMValueRef num,
|
||||
LLVMValueRef multiplier, LLVMValueRef pre_shift,
|
||||
LLVMValueRef post_shift, LLVMValueRef increment);
|
||||
LLVMValueRef ac_build_fast_udiv_u31_d_not_one(struct ac_llvm_context *ctx, LLVMValueRef num,
|
||||
LLVMValueRef multiplier, LLVMValueRef post_shift);
|
||||
|
||||
void
|
||||
ac_prepare_cube_coords(struct ac_llvm_context *ctx,
|
||||
bool is_deriv, bool is_array, bool is_lod,
|
||||
LLVMValueRef *coords_arg,
|
||||
LLVMValueRef *derivs_arg);
|
||||
void ac_prepare_cube_coords(struct ac_llvm_context *ctx, bool is_deriv, bool is_array, bool is_lod,
|
||||
LLVMValueRef *coords_arg, LLVMValueRef *derivs_arg);
|
||||
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_fs_interp(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef llvm_chan,
|
||||
LLVMValueRef attr_number,
|
||||
LLVMValueRef params,
|
||||
LLVMValueRef i,
|
||||
LLVMValueRef ac_build_fs_interp(struct ac_llvm_context *ctx, LLVMValueRef llvm_chan,
|
||||
LLVMValueRef attr_number, LLVMValueRef params, LLVMValueRef i,
|
||||
LLVMValueRef j);
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_fs_interp_f16(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef llvm_chan,
|
||||
LLVMValueRef attr_number,
|
||||
LLVMValueRef params,
|
||||
LLVMValueRef i,
|
||||
LLVMValueRef ac_build_fs_interp_f16(struct ac_llvm_context *ctx, LLVMValueRef llvm_chan,
|
||||
LLVMValueRef attr_number, LLVMValueRef params, LLVMValueRef i,
|
||||
LLVMValueRef j);
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_fs_interp_mov(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef parameter,
|
||||
LLVMValueRef llvm_chan,
|
||||
LLVMValueRef attr_number,
|
||||
LLVMValueRef ac_build_fs_interp_mov(struct ac_llvm_context *ctx, LLVMValueRef parameter,
|
||||
LLVMValueRef llvm_chan, LLVMValueRef attr_number,
|
||||
LLVMValueRef params);
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_gep_ptr(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef base_ptr,
|
||||
LLVMValueRef ac_build_gep_ptr(struct ac_llvm_context *ctx, LLVMValueRef base_ptr,
|
||||
LLVMValueRef index);
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_gep0(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef base_ptr,
|
||||
LLVMValueRef index);
|
||||
LLVMValueRef ac_build_gep0(struct ac_llvm_context *ctx, LLVMValueRef base_ptr, LLVMValueRef index);
|
||||
LLVMValueRef ac_build_pointer_add(struct ac_llvm_context *ctx, LLVMValueRef ptr,
|
||||
LLVMValueRef index);
|
||||
|
||||
void
|
||||
ac_build_indexed_store(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef base_ptr, LLVMValueRef index,
|
||||
void ac_build_indexed_store(struct ac_llvm_context *ctx, LLVMValueRef base_ptr, LLVMValueRef index,
|
||||
LLVMValueRef value);
|
||||
|
||||
LLVMValueRef ac_build_load(struct ac_llvm_context *ctx, LLVMValueRef base_ptr,
|
||||
LLVMValueRef ac_build_load(struct ac_llvm_context *ctx, LLVMValueRef base_ptr, LLVMValueRef index);
|
||||
LLVMValueRef ac_build_load_invariant(struct ac_llvm_context *ctx, LLVMValueRef base_ptr,
|
||||
LLVMValueRef index);
|
||||
LLVMValueRef ac_build_load_to_sgpr(struct ac_llvm_context *ctx, LLVMValueRef base_ptr,
|
||||
LLVMValueRef index);
|
||||
LLVMValueRef ac_build_load_invariant(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef base_ptr, LLVMValueRef index);
|
||||
LLVMValueRef ac_build_load_to_sgpr(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef base_ptr, LLVMValueRef index);
|
||||
LLVMValueRef ac_build_load_to_sgpr_uint_wraparound(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef base_ptr, LLVMValueRef index);
|
||||
|
||||
void
|
||||
ac_build_buffer_store_dword(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef rsrc,
|
||||
LLVMValueRef vdata,
|
||||
unsigned num_channels,
|
||||
LLVMValueRef voffset,
|
||||
LLVMValueRef soffset,
|
||||
unsigned inst_offset,
|
||||
unsigned cache_policy);
|
||||
void ac_build_buffer_store_dword(struct ac_llvm_context *ctx, LLVMValueRef rsrc, LLVMValueRef vdata,
|
||||
unsigned num_channels, LLVMValueRef voffset, LLVMValueRef soffset,
|
||||
unsigned inst_offset, unsigned cache_policy);
|
||||
|
||||
void
|
||||
ac_build_buffer_store_format(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef rsrc,
|
||||
LLVMValueRef data,
|
||||
LLVMValueRef vindex,
|
||||
LLVMValueRef voffset,
|
||||
unsigned cache_policy);
|
||||
void ac_build_buffer_store_format(struct ac_llvm_context *ctx, LLVMValueRef rsrc, LLVMValueRef data,
|
||||
LLVMValueRef vindex, LLVMValueRef voffset, unsigned cache_policy);
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_buffer_load(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef rsrc,
|
||||
int num_channels,
|
||||
LLVMValueRef vindex,
|
||||
LLVMValueRef voffset,
|
||||
LLVMValueRef soffset,
|
||||
unsigned inst_offset,
|
||||
unsigned cache_policy,
|
||||
bool can_speculate,
|
||||
LLVMValueRef ac_build_buffer_load(struct ac_llvm_context *ctx, LLVMValueRef rsrc, int num_channels,
|
||||
LLVMValueRef vindex, LLVMValueRef voffset, LLVMValueRef soffset,
|
||||
unsigned inst_offset, unsigned cache_policy, bool can_speculate,
|
||||
bool allow_smem);
|
||||
|
||||
LLVMValueRef ac_build_buffer_load_format(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef rsrc,
|
||||
LLVMValueRef vindex,
|
||||
LLVMValueRef voffset,
|
||||
unsigned num_channels,
|
||||
unsigned cache_policy,
|
||||
bool can_speculate,
|
||||
bool d16);
|
||||
LLVMValueRef ac_build_buffer_load_format(struct ac_llvm_context *ctx, LLVMValueRef rsrc,
|
||||
LLVMValueRef vindex, LLVMValueRef voffset,
|
||||
unsigned num_channels, unsigned cache_policy,
|
||||
bool can_speculate, bool d16);
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_tbuffer_load_short(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef rsrc,
|
||||
LLVMValueRef voffset,
|
||||
LLVMValueRef soffset,
|
||||
LLVMValueRef immoffset,
|
||||
unsigned cache_policy);
|
||||
LLVMValueRef ac_build_tbuffer_load_short(struct ac_llvm_context *ctx, LLVMValueRef rsrc,
|
||||
LLVMValueRef voffset, LLVMValueRef soffset,
|
||||
LLVMValueRef immoffset, unsigned cache_policy);
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_tbuffer_load_byte(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef rsrc,
|
||||
LLVMValueRef voffset,
|
||||
LLVMValueRef soffset,
|
||||
LLVMValueRef immoffset,
|
||||
unsigned cache_policy);
|
||||
LLVMValueRef ac_build_tbuffer_load_byte(struct ac_llvm_context *ctx, LLVMValueRef rsrc,
|
||||
LLVMValueRef voffset, LLVMValueRef soffset,
|
||||
LLVMValueRef immoffset, unsigned cache_policy);
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_struct_tbuffer_load(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef rsrc,
|
||||
LLVMValueRef vindex,
|
||||
LLVMValueRef voffset,
|
||||
LLVMValueRef soffset,
|
||||
LLVMValueRef immoffset,
|
||||
unsigned num_channels,
|
||||
unsigned dfmt,
|
||||
unsigned nfmt,
|
||||
unsigned cache_policy,
|
||||
bool can_speculate);
|
||||
LLVMValueRef ac_build_struct_tbuffer_load(struct ac_llvm_context *ctx, LLVMValueRef rsrc,
|
||||
LLVMValueRef vindex, LLVMValueRef voffset,
|
||||
LLVMValueRef soffset, LLVMValueRef immoffset,
|
||||
unsigned num_channels, unsigned dfmt, unsigned nfmt,
|
||||
unsigned cache_policy, bool can_speculate);
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_raw_tbuffer_load(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef rsrc,
|
||||
LLVMValueRef voffset,
|
||||
LLVMValueRef soffset,
|
||||
LLVMValueRef immoffset,
|
||||
unsigned num_channels,
|
||||
unsigned dfmt,
|
||||
unsigned nfmt,
|
||||
unsigned cache_policy,
|
||||
bool can_speculate);
|
||||
LLVMValueRef ac_build_raw_tbuffer_load(struct ac_llvm_context *ctx, LLVMValueRef rsrc,
|
||||
LLVMValueRef voffset, LLVMValueRef soffset,
|
||||
LLVMValueRef immoffset, unsigned num_channels, unsigned dfmt,
|
||||
unsigned nfmt, unsigned cache_policy, bool can_speculate);
|
||||
|
||||
/* For ac_build_fetch_format.
|
||||
*
|
||||
* Note: FLOAT must be 0 (used for convenience of encoding in radeonsi).
|
||||
*/
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
AC_FETCH_FORMAT_FLOAT = 0,
|
||||
AC_FETCH_FORMAT_FIXED,
|
||||
AC_FETCH_FORMAT_UNORM,
|
||||
@@ -397,73 +297,38 @@ enum {
|
||||
AC_FETCH_FORMAT_SINT,
|
||||
};
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_opencoded_load_format(struct ac_llvm_context *ctx,
|
||||
unsigned log_size,
|
||||
unsigned num_channels,
|
||||
unsigned format,
|
||||
bool reverse,
|
||||
bool known_aligned,
|
||||
LLVMValueRef rsrc,
|
||||
LLVMValueRef vindex,
|
||||
LLVMValueRef voffset,
|
||||
LLVMValueRef soffset,
|
||||
unsigned cache_policy,
|
||||
LLVMValueRef ac_build_opencoded_load_format(struct ac_llvm_context *ctx, unsigned log_size,
|
||||
unsigned num_channels, unsigned format, bool reverse,
|
||||
bool known_aligned, LLVMValueRef rsrc,
|
||||
LLVMValueRef vindex, LLVMValueRef voffset,
|
||||
LLVMValueRef soffset, unsigned cache_policy,
|
||||
bool can_speculate);
|
||||
|
||||
void
|
||||
ac_build_tbuffer_store_short(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef rsrc,
|
||||
LLVMValueRef vdata,
|
||||
LLVMValueRef voffset,
|
||||
LLVMValueRef soffset,
|
||||
void ac_build_tbuffer_store_short(struct ac_llvm_context *ctx, LLVMValueRef rsrc,
|
||||
LLVMValueRef vdata, LLVMValueRef voffset, LLVMValueRef soffset,
|
||||
unsigned cache_policy);
|
||||
|
||||
void
|
||||
ac_build_tbuffer_store_byte(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef rsrc,
|
||||
LLVMValueRef vdata,
|
||||
LLVMValueRef voffset,
|
||||
LLVMValueRef soffset,
|
||||
void ac_build_tbuffer_store_byte(struct ac_llvm_context *ctx, LLVMValueRef rsrc, LLVMValueRef vdata,
|
||||
LLVMValueRef voffset, LLVMValueRef soffset, unsigned cache_policy);
|
||||
|
||||
void ac_build_struct_tbuffer_store(struct ac_llvm_context *ctx, LLVMValueRef rsrc,
|
||||
LLVMValueRef vdata, LLVMValueRef vindex, LLVMValueRef voffset,
|
||||
LLVMValueRef soffset, LLVMValueRef immoffset,
|
||||
unsigned num_channels, unsigned dfmt, unsigned nfmt,
|
||||
unsigned cache_policy);
|
||||
|
||||
void
|
||||
ac_build_struct_tbuffer_store(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef rsrc,
|
||||
LLVMValueRef vdata,
|
||||
LLVMValueRef vindex,
|
||||
LLVMValueRef voffset,
|
||||
LLVMValueRef soffset,
|
||||
LLVMValueRef immoffset,
|
||||
unsigned num_channels,
|
||||
unsigned dfmt,
|
||||
unsigned nfmt,
|
||||
void ac_build_raw_tbuffer_store(struct ac_llvm_context *ctx, LLVMValueRef rsrc, LLVMValueRef vdata,
|
||||
LLVMValueRef voffset, LLVMValueRef soffset, LLVMValueRef immoffset,
|
||||
unsigned num_channels, unsigned dfmt, unsigned nfmt,
|
||||
unsigned cache_policy);
|
||||
|
||||
void
|
||||
ac_build_raw_tbuffer_store(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef rsrc,
|
||||
LLVMValueRef vdata,
|
||||
LLVMValueRef voffset,
|
||||
LLVMValueRef soffset,
|
||||
LLVMValueRef immoffset,
|
||||
unsigned num_channels,
|
||||
unsigned dfmt,
|
||||
unsigned nfmt,
|
||||
unsigned cache_policy);
|
||||
|
||||
LLVMValueRef
|
||||
ac_get_thread_id(struct ac_llvm_context *ctx);
|
||||
LLVMValueRef ac_get_thread_id(struct ac_llvm_context *ctx);
|
||||
|
||||
#define AC_TID_MASK_TOP_LEFT 0xfffffffc
|
||||
#define AC_TID_MASK_TOP 0xfffffffd
|
||||
#define AC_TID_MASK_LEFT 0xfffffffe
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_ddxy(struct ac_llvm_context *ctx,
|
||||
uint32_t mask,
|
||||
int idx,
|
||||
LLVMValueRef val);
|
||||
LLVMValueRef ac_build_ddxy(struct ac_llvm_context *ctx, uint32_t mask, int idx, LLVMValueRef val);
|
||||
|
||||
#define AC_SENDMSG_GS 2
|
||||
#define AC_SENDMSG_GS_DONE 3
|
||||
@@ -474,25 +339,15 @@ ac_build_ddxy(struct ac_llvm_context *ctx,
|
||||
#define AC_SENDMSG_GS_OP_EMIT (2 << 4)
|
||||
#define AC_SENDMSG_GS_OP_EMIT_CUT (3 << 4)
|
||||
|
||||
void ac_build_sendmsg(struct ac_llvm_context *ctx,
|
||||
uint32_t msg,
|
||||
LLVMValueRef wave_id);
|
||||
void ac_build_sendmsg(struct ac_llvm_context *ctx, uint32_t msg, LLVMValueRef wave_id);
|
||||
|
||||
LLVMValueRef ac_build_imsb(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef arg,
|
||||
LLVMTypeRef dst_type);
|
||||
LLVMValueRef ac_build_imsb(struct ac_llvm_context *ctx, LLVMValueRef arg, LLVMTypeRef dst_type);
|
||||
|
||||
LLVMValueRef ac_build_umsb(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef arg,
|
||||
LLVMTypeRef dst_type);
|
||||
LLVMValueRef ac_build_fmin(struct ac_llvm_context *ctx, LLVMValueRef a,
|
||||
LLVMValueRef b);
|
||||
LLVMValueRef ac_build_fmax(struct ac_llvm_context *ctx, LLVMValueRef a,
|
||||
LLVMValueRef b);
|
||||
LLVMValueRef ac_build_imin(struct ac_llvm_context *ctx, LLVMValueRef a,
|
||||
LLVMValueRef b);
|
||||
LLVMValueRef ac_build_imax(struct ac_llvm_context *ctx, LLVMValueRef a,
|
||||
LLVMValueRef b);
|
||||
LLVMValueRef ac_build_umsb(struct ac_llvm_context *ctx, LLVMValueRef arg, LLVMTypeRef dst_type);
|
||||
LLVMValueRef ac_build_fmin(struct ac_llvm_context *ctx, LLVMValueRef a, LLVMValueRef b);
|
||||
LLVMValueRef ac_build_fmax(struct ac_llvm_context *ctx, LLVMValueRef a, LLVMValueRef b);
|
||||
LLVMValueRef ac_build_imin(struct ac_llvm_context *ctx, LLVMValueRef a, LLVMValueRef b);
|
||||
LLVMValueRef ac_build_imax(struct ac_llvm_context *ctx, LLVMValueRef a, LLVMValueRef b);
|
||||
LLVMValueRef ac_build_umin(struct ac_llvm_context *ctx, LLVMValueRef a, LLVMValueRef b);
|
||||
LLVMValueRef ac_build_umax(struct ac_llvm_context *ctx, LLVMValueRef a, LLVMValueRef b);
|
||||
LLVMValueRef ac_build_clamp(struct ac_llvm_context *ctx, LLVMValueRef value);
|
||||
@@ -510,7 +365,8 @@ void ac_build_export(struct ac_llvm_context *ctx, struct ac_export_args *a);
|
||||
|
||||
void ac_build_export_null(struct ac_llvm_context *ctx);
|
||||
|
||||
enum ac_image_opcode {
|
||||
enum ac_image_opcode
|
||||
{
|
||||
ac_image_sample,
|
||||
ac_image_gather4,
|
||||
ac_image_load,
|
||||
@@ -523,7 +379,8 @@ enum ac_image_opcode {
|
||||
ac_image_atomic_cmpswap,
|
||||
};
|
||||
|
||||
enum ac_atomic_op {
|
||||
enum ac_atomic_op
|
||||
{
|
||||
ac_atomic_swap,
|
||||
ac_atomic_add,
|
||||
ac_atomic_sub,
|
||||
@@ -539,7 +396,8 @@ enum ac_atomic_op {
|
||||
};
|
||||
|
||||
/* These cache policy bits match the definitions used by the LLVM intrinsics. */
|
||||
enum ac_image_cache_policy {
|
||||
enum ac_image_cache_policy
|
||||
{
|
||||
ac_glc = 1 << 0, /* per-CU cache control */
|
||||
ac_slc = 1 << 1, /* global L2 cache control */
|
||||
ac_dlc = 1 << 2, /* per-shader-array cache control */
|
||||
@@ -569,59 +427,44 @@ struct ac_image_args {
|
||||
LLVMValueRef min_lod;
|
||||
};
|
||||
|
||||
LLVMValueRef ac_build_image_opcode(struct ac_llvm_context *ctx,
|
||||
struct ac_image_args *a);
|
||||
LLVMValueRef ac_build_image_get_sample_count(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef rsrc);
|
||||
LLVMValueRef ac_build_cvt_pkrtz_f16(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef args[2]);
|
||||
LLVMValueRef ac_build_cvt_pknorm_i16(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef args[2]);
|
||||
LLVMValueRef ac_build_cvt_pknorm_u16(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef args[2]);
|
||||
LLVMValueRef ac_build_cvt_pk_i16(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef args[2], unsigned bits, bool hi);
|
||||
LLVMValueRef ac_build_cvt_pk_u16(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef args[2], unsigned bits, bool hi);
|
||||
LLVMValueRef ac_build_image_opcode(struct ac_llvm_context *ctx, struct ac_image_args *a);
|
||||
LLVMValueRef ac_build_image_get_sample_count(struct ac_llvm_context *ctx, LLVMValueRef rsrc);
|
||||
LLVMValueRef ac_build_cvt_pkrtz_f16(struct ac_llvm_context *ctx, LLVMValueRef args[2]);
|
||||
LLVMValueRef ac_build_cvt_pknorm_i16(struct ac_llvm_context *ctx, LLVMValueRef args[2]);
|
||||
LLVMValueRef ac_build_cvt_pknorm_u16(struct ac_llvm_context *ctx, LLVMValueRef args[2]);
|
||||
LLVMValueRef ac_build_cvt_pk_i16(struct ac_llvm_context *ctx, LLVMValueRef args[2], unsigned bits,
|
||||
bool hi);
|
||||
LLVMValueRef ac_build_cvt_pk_u16(struct ac_llvm_context *ctx, LLVMValueRef args[2], unsigned bits,
|
||||
bool hi);
|
||||
LLVMValueRef ac_build_wqm_vote(struct ac_llvm_context *ctx, LLVMValueRef i1);
|
||||
void ac_build_kill_if_false(struct ac_llvm_context *ctx, LLVMValueRef i1);
|
||||
LLVMValueRef ac_build_bfe(struct ac_llvm_context *ctx, LLVMValueRef input,
|
||||
LLVMValueRef offset, LLVMValueRef width,
|
||||
bool is_signed);
|
||||
LLVMValueRef ac_build_imad(struct ac_llvm_context *ctx, LLVMValueRef s0,
|
||||
LLVMValueRef s1, LLVMValueRef s2);
|
||||
LLVMValueRef ac_build_fmad(struct ac_llvm_context *ctx, LLVMValueRef s0,
|
||||
LLVMValueRef s1, LLVMValueRef s2);
|
||||
LLVMValueRef ac_build_bfe(struct ac_llvm_context *ctx, LLVMValueRef input, LLVMValueRef offset,
|
||||
LLVMValueRef width, bool is_signed);
|
||||
LLVMValueRef ac_build_imad(struct ac_llvm_context *ctx, LLVMValueRef s0, LLVMValueRef s1,
|
||||
LLVMValueRef s2);
|
||||
LLVMValueRef ac_build_fmad(struct ac_llvm_context *ctx, LLVMValueRef s0, LLVMValueRef s1,
|
||||
LLVMValueRef s2);
|
||||
|
||||
void ac_build_waitcnt(struct ac_llvm_context *ctx, unsigned wait_flags);
|
||||
|
||||
LLVMValueRef ac_build_fract(struct ac_llvm_context *ctx, LLVMValueRef src0,
|
||||
unsigned bitsize);
|
||||
LLVMValueRef ac_build_fract(struct ac_llvm_context *ctx, LLVMValueRef src0, unsigned bitsize);
|
||||
LLVMValueRef ac_const_uint_vec(struct ac_llvm_context *ctx, LLVMTypeRef type, uint64_t value);
|
||||
LLVMValueRef ac_build_isign(struct ac_llvm_context *ctx, LLVMValueRef src0);
|
||||
LLVMValueRef ac_build_fsign(struct ac_llvm_context *ctx, LLVMValueRef src);
|
||||
LLVMValueRef ac_build_bit_count(struct ac_llvm_context *ctx, LLVMValueRef src0);
|
||||
|
||||
LLVMValueRef ac_build_bitfield_reverse(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef src0);
|
||||
LLVMValueRef ac_build_bitfield_reverse(struct ac_llvm_context *ctx, LLVMValueRef src0);
|
||||
|
||||
void ac_optimize_vs_outputs(struct ac_llvm_context *ac,
|
||||
LLVMValueRef main_fn,
|
||||
uint8_t *vs_output_param_offset,
|
||||
uint32_t num_outputs,
|
||||
uint32_t skip_output_mask,
|
||||
uint8_t *num_param_exports);
|
||||
void ac_optimize_vs_outputs(struct ac_llvm_context *ac, LLVMValueRef main_fn,
|
||||
uint8_t *vs_output_param_offset, uint32_t num_outputs,
|
||||
uint32_t skip_output_mask, uint8_t *num_param_exports);
|
||||
void ac_init_exec_full_mask(struct ac_llvm_context *ctx);
|
||||
|
||||
void ac_declare_lds_as_pointer(struct ac_llvm_context *ac);
|
||||
LLVMValueRef ac_lds_load(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef dw_addr);
|
||||
void ac_lds_store(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef dw_addr, LLVMValueRef value);
|
||||
LLVMValueRef ac_lds_load(struct ac_llvm_context *ctx, LLVMValueRef dw_addr);
|
||||
void ac_lds_store(struct ac_llvm_context *ctx, LLVMValueRef dw_addr, LLVMValueRef value);
|
||||
|
||||
LLVMValueRef ac_find_lsb(struct ac_llvm_context *ctx,
|
||||
LLVMTypeRef dst_type,
|
||||
LLVMValueRef src0);
|
||||
LLVMValueRef ac_find_lsb(struct ac_llvm_context *ctx, LLVMTypeRef dst_type, LLVMValueRef src0);
|
||||
|
||||
LLVMTypeRef ac_array_in_const_addr_space(LLVMTypeRef elem_type);
|
||||
LLVMTypeRef ac_array_in_const32_addr_space(LLVMTypeRef elem_type);
|
||||
@@ -633,51 +476,40 @@ void ac_build_else(struct ac_llvm_context *ctx, int lable_id);
|
||||
void ac_build_endif(struct ac_llvm_context *ctx, int lable_id);
|
||||
void ac_build_endloop(struct ac_llvm_context *ctx, int lable_id);
|
||||
void ac_build_ifcc(struct ac_llvm_context *ctx, LLVMValueRef cond, int label_id);
|
||||
void ac_build_if(struct ac_llvm_context *ctx, LLVMValueRef value,
|
||||
int lable_id);
|
||||
void ac_build_uif(struct ac_llvm_context *ctx, LLVMValueRef value,
|
||||
int lable_id);
|
||||
void ac_build_if(struct ac_llvm_context *ctx, LLVMValueRef value, int lable_id);
|
||||
void ac_build_uif(struct ac_llvm_context *ctx, LLVMValueRef value, int lable_id);
|
||||
|
||||
LLVMValueRef ac_build_alloca(struct ac_llvm_context *ac, LLVMTypeRef type,
|
||||
const char *name);
|
||||
LLVMValueRef ac_build_alloca_undef(struct ac_llvm_context *ac, LLVMTypeRef type,
|
||||
const char *name);
|
||||
LLVMValueRef ac_build_alloca(struct ac_llvm_context *ac, LLVMTypeRef type, const char *name);
|
||||
LLVMValueRef ac_build_alloca_undef(struct ac_llvm_context *ac, LLVMTypeRef type, const char *name);
|
||||
|
||||
LLVMValueRef ac_cast_ptr(struct ac_llvm_context *ctx, LLVMValueRef ptr,
|
||||
LLVMTypeRef type);
|
||||
LLVMValueRef ac_cast_ptr(struct ac_llvm_context *ctx, LLVMValueRef ptr, LLVMTypeRef type);
|
||||
|
||||
LLVMValueRef ac_trim_vector(struct ac_llvm_context *ctx, LLVMValueRef value,
|
||||
unsigned count);
|
||||
LLVMValueRef ac_trim_vector(struct ac_llvm_context *ctx, LLVMValueRef value, unsigned count);
|
||||
|
||||
LLVMValueRef ac_unpack_param(struct ac_llvm_context *ctx, LLVMValueRef param,
|
||||
unsigned rshift, unsigned bitwidth);
|
||||
LLVMValueRef ac_unpack_param(struct ac_llvm_context *ctx, LLVMValueRef param, unsigned rshift,
|
||||
unsigned bitwidth);
|
||||
|
||||
void ac_apply_fmask_to_sample(struct ac_llvm_context *ac, LLVMValueRef fmask,
|
||||
LLVMValueRef *addr, bool is_array_tex);
|
||||
void ac_apply_fmask_to_sample(struct ac_llvm_context *ac, LLVMValueRef fmask, LLVMValueRef *addr,
|
||||
bool is_array_tex);
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_ds_swizzle(struct ac_llvm_context *ctx, LLVMValueRef src, unsigned mask);
|
||||
LLVMValueRef ac_build_ds_swizzle(struct ac_llvm_context *ctx, LLVMValueRef src, unsigned mask);
|
||||
|
||||
LLVMValueRef ac_build_readlane_no_opt_barrier(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef src, LLVMValueRef lane);
|
||||
LLVMValueRef ac_build_readlane_no_opt_barrier(struct ac_llvm_context *ctx, LLVMValueRef src,
|
||||
LLVMValueRef lane);
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_readlane(struct ac_llvm_context *ctx, LLVMValueRef src, LLVMValueRef lane);
|
||||
LLVMValueRef ac_build_readlane(struct ac_llvm_context *ctx, LLVMValueRef src, LLVMValueRef lane);
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_writelane(struct ac_llvm_context *ctx, LLVMValueRef src, LLVMValueRef value, LLVMValueRef lane);
|
||||
LLVMValueRef ac_build_writelane(struct ac_llvm_context *ctx, LLVMValueRef src, LLVMValueRef value,
|
||||
LLVMValueRef lane);
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_mbcnt(struct ac_llvm_context *ctx, LLVMValueRef mask);
|
||||
LLVMValueRef ac_build_mbcnt(struct ac_llvm_context *ctx, LLVMValueRef mask);
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_inclusive_scan(struct ac_llvm_context *ctx, LLVMValueRef src, nir_op op);
|
||||
LLVMValueRef ac_build_inclusive_scan(struct ac_llvm_context *ctx, LLVMValueRef src, nir_op op);
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_exclusive_scan(struct ac_llvm_context *ctx, LLVMValueRef src, nir_op op);
|
||||
LLVMValueRef ac_build_exclusive_scan(struct ac_llvm_context *ctx, LLVMValueRef src, nir_op op);
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_reduce(struct ac_llvm_context *ctx, LLVMValueRef src, nir_op op, unsigned cluster_size);
|
||||
LLVMValueRef ac_build_reduce(struct ac_llvm_context *ctx, LLVMValueRef src, nir_op op,
|
||||
unsigned cluster_size);
|
||||
|
||||
/**
|
||||
* Common arguments for a scan/reduce operation that accumulates per-wave
|
||||
@@ -701,63 +533,43 @@ struct ac_wg_scan {
|
||||
unsigned maxwaves;
|
||||
};
|
||||
|
||||
void
|
||||
ac_build_wg_wavescan_top(struct ac_llvm_context *ctx, struct ac_wg_scan *ws);
|
||||
void
|
||||
ac_build_wg_wavescan_bottom(struct ac_llvm_context *ctx, struct ac_wg_scan *ws);
|
||||
void
|
||||
ac_build_wg_wavescan(struct ac_llvm_context *ctx, struct ac_wg_scan *ws);
|
||||
void ac_build_wg_wavescan_top(struct ac_llvm_context *ctx, struct ac_wg_scan *ws);
|
||||
void ac_build_wg_wavescan_bottom(struct ac_llvm_context *ctx, struct ac_wg_scan *ws);
|
||||
void ac_build_wg_wavescan(struct ac_llvm_context *ctx, struct ac_wg_scan *ws);
|
||||
|
||||
void
|
||||
ac_build_wg_scan_top(struct ac_llvm_context *ctx, struct ac_wg_scan *ws);
|
||||
void
|
||||
ac_build_wg_scan_bottom(struct ac_llvm_context *ctx, struct ac_wg_scan *ws);
|
||||
void
|
||||
ac_build_wg_scan(struct ac_llvm_context *ctx, struct ac_wg_scan *ws);
|
||||
void ac_build_wg_scan_top(struct ac_llvm_context *ctx, struct ac_wg_scan *ws);
|
||||
void ac_build_wg_scan_bottom(struct ac_llvm_context *ctx, struct ac_wg_scan *ws);
|
||||
void ac_build_wg_scan(struct ac_llvm_context *ctx, struct ac_wg_scan *ws);
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_quad_swizzle(struct ac_llvm_context *ctx, LLVMValueRef src,
|
||||
unsigned lane0, unsigned lane1, unsigned lane2, unsigned lane3);
|
||||
LLVMValueRef ac_build_quad_swizzle(struct ac_llvm_context *ctx, LLVMValueRef src, unsigned lane0,
|
||||
unsigned lane1, unsigned lane2, unsigned lane3);
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_shuffle(struct ac_llvm_context *ctx, LLVMValueRef src, LLVMValueRef index);
|
||||
LLVMValueRef ac_build_shuffle(struct ac_llvm_context *ctx, LLVMValueRef src, LLVMValueRef index);
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_frexp_exp(struct ac_llvm_context *ctx, LLVMValueRef src0,
|
||||
LLVMValueRef ac_build_frexp_exp(struct ac_llvm_context *ctx, LLVMValueRef src0, unsigned bitsize);
|
||||
|
||||
LLVMValueRef ac_build_frexp_mant(struct ac_llvm_context *ctx, LLVMValueRef src0, unsigned bitsize);
|
||||
|
||||
LLVMValueRef ac_build_canonicalize(struct ac_llvm_context *ctx, LLVMValueRef src0,
|
||||
unsigned bitsize);
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_frexp_mant(struct ac_llvm_context *ctx, LLVMValueRef src0,
|
||||
unsigned bitsize);
|
||||
LLVMValueRef ac_build_ddxy_interp(struct ac_llvm_context *ctx, LLVMValueRef interp_ij);
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_canonicalize(struct ac_llvm_context *ctx, LLVMValueRef src0,
|
||||
unsigned bitsize);
|
||||
LLVMValueRef ac_build_load_helper_invocation(struct ac_llvm_context *ctx);
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_ddxy_interp(struct ac_llvm_context *ctx, LLVMValueRef interp_ij);
|
||||
LLVMValueRef ac_build_is_helper_invocation(struct ac_llvm_context *ctx);
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_load_helper_invocation(struct ac_llvm_context *ctx);
|
||||
|
||||
LLVMValueRef
|
||||
ac_build_is_helper_invocation(struct ac_llvm_context *ctx);
|
||||
|
||||
LLVMValueRef ac_build_call(struct ac_llvm_context *ctx, LLVMValueRef func,
|
||||
LLVMValueRef *args, unsigned num_args);
|
||||
LLVMValueRef ac_build_call(struct ac_llvm_context *ctx, LLVMValueRef func, LLVMValueRef *args,
|
||||
unsigned num_args);
|
||||
|
||||
LLVMValueRef ac_build_atomic_rmw(struct ac_llvm_context *ctx, LLVMAtomicRMWBinOp op,
|
||||
LLVMValueRef ptr, LLVMValueRef val,
|
||||
const char *sync_scope);
|
||||
LLVMValueRef ptr, LLVMValueRef val, const char *sync_scope);
|
||||
|
||||
LLVMValueRef ac_build_atomic_cmp_xchg(struct ac_llvm_context *ctx, LLVMValueRef ptr,
|
||||
LLVMValueRef cmp, LLVMValueRef val,
|
||||
const char *sync_scope);
|
||||
LLVMValueRef cmp, LLVMValueRef val, const char *sync_scope);
|
||||
|
||||
void
|
||||
ac_export_mrt_z(struct ac_llvm_context *ctx, LLVMValueRef depth,
|
||||
LLVMValueRef stencil, LLVMValueRef samplemask,
|
||||
struct ac_export_args *args);
|
||||
void ac_export_mrt_z(struct ac_llvm_context *ctx, LLVMValueRef depth, LLVMValueRef stencil,
|
||||
LLVMValueRef samplemask, struct ac_export_args *args);
|
||||
|
||||
void ac_build_sendmsg_gs_alloc_req(struct ac_llvm_context *ctx, LLVMValueRef wave_id,
|
||||
LLVMValueRef vtx_cnt, LLVMValueRef prim_cnt);
|
||||
@@ -770,19 +582,17 @@ struct ac_ngg_prim {
|
||||
LLVMValueRef passthrough;
|
||||
};
|
||||
|
||||
LLVMValueRef ac_pack_prim_export(struct ac_llvm_context *ctx,
|
||||
const struct ac_ngg_prim *prim);
|
||||
void ac_build_export_prim(struct ac_llvm_context *ctx,
|
||||
const struct ac_ngg_prim *prim);
|
||||
LLVMValueRef ac_pack_prim_export(struct ac_llvm_context *ctx, const struct ac_ngg_prim *prim);
|
||||
void ac_build_export_prim(struct ac_llvm_context *ctx, const struct ac_ngg_prim *prim);
|
||||
|
||||
static inline LLVMValueRef
|
||||
ac_get_arg(struct ac_llvm_context *ctx, struct ac_arg arg)
|
||||
static inline LLVMValueRef ac_get_arg(struct ac_llvm_context *ctx, struct ac_arg arg)
|
||||
{
|
||||
assert(arg.used);
|
||||
return LLVMGetParam(ctx->main_function, arg.arg_index);
|
||||
}
|
||||
|
||||
enum ac_llvm_calling_convention {
|
||||
enum ac_llvm_calling_convention
|
||||
{
|
||||
AC_LLVM_AMDGPU_VS = 87,
|
||||
AC_LLVM_AMDGPU_GS = 88,
|
||||
AC_LLVM_AMDGPU_PS = 89,
|
||||
@@ -790,19 +600,15 @@ enum ac_llvm_calling_convention {
|
||||
AC_LLVM_AMDGPU_HS = 93,
|
||||
};
|
||||
|
||||
LLVMValueRef ac_build_main(const struct ac_shader_args *args,
|
||||
struct ac_llvm_context *ctx,
|
||||
enum ac_llvm_calling_convention convention,
|
||||
const char *name, LLVMTypeRef ret_type,
|
||||
LLVMModuleRef module);
|
||||
LLVMValueRef ac_build_main(const struct ac_shader_args *args, struct ac_llvm_context *ctx,
|
||||
enum ac_llvm_calling_convention convention, const char *name,
|
||||
LLVMTypeRef ret_type, LLVMModuleRef module);
|
||||
void ac_build_s_endpgm(struct ac_llvm_context *ctx);
|
||||
|
||||
LLVMValueRef ac_prefix_bitcount(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef mask, LLVMValueRef index);
|
||||
LLVMValueRef ac_prefix_bitcount_2x64(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef mask[2], LLVMValueRef index);
|
||||
void ac_build_triangle_strip_indices_to_triangle(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef is_odd,
|
||||
LLVMValueRef ac_prefix_bitcount(struct ac_llvm_context *ctx, LLVMValueRef mask, LLVMValueRef index);
|
||||
LLVMValueRef ac_prefix_bitcount_2x64(struct ac_llvm_context *ctx, LLVMValueRef mask[2],
|
||||
LLVMValueRef index);
|
||||
void ac_build_triangle_strip_indices_to_triangle(struct ac_llvm_context *ctx, LLVMValueRef is_odd,
|
||||
LLVMValueRef flatshade_first,
|
||||
LLVMValueRef index[3]);
|
||||
|
||||
|
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
|
||||
#include "ac_llvm_cull.h"
|
||||
|
||||
#include <llvm-c/Core.h>
|
||||
|
||||
struct ac_position_w_info {
|
||||
@@ -50,8 +51,7 @@ struct ac_position_w_info {
|
||||
LLVMValueRef any_w_negative;
|
||||
};
|
||||
|
||||
static void ac_analyze_position_w(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef pos[3][4],
|
||||
static void ac_analyze_position_w(struct ac_llvm_context *ctx, LLVMValueRef pos[3][4],
|
||||
struct ac_position_w_info *w)
|
||||
{
|
||||
LLVMBuilderRef builder = ctx->builder;
|
||||
@@ -74,11 +74,8 @@ static void ac_analyze_position_w(struct ac_llvm_context *ctx,
|
||||
}
|
||||
|
||||
/* Perform front/back face culling and return true if the primitive is accepted. */
|
||||
static LLVMValueRef ac_cull_face(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef pos[3][4],
|
||||
struct ac_position_w_info *w,
|
||||
bool cull_front,
|
||||
bool cull_back,
|
||||
static LLVMValueRef ac_cull_face(struct ac_llvm_context *ctx, LLVMValueRef pos[3][4],
|
||||
struct ac_position_w_info *w, bool cull_front, bool cull_back,
|
||||
bool cull_zero_area)
|
||||
{
|
||||
LLVMBuilderRef builder = ctx->builder;
|
||||
@@ -101,9 +98,7 @@ static LLVMValueRef ac_cull_face(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef det = LLVMBuildFSub(builder, det_p0, det_p1, "");
|
||||
|
||||
/* Negative W negates the determinant. */
|
||||
det = LLVMBuildSelect(builder, w->w_reflection,
|
||||
LLVMBuildFNeg(builder, det, ""),
|
||||
det, "");
|
||||
det = LLVMBuildSelect(builder, w->w_reflection, LLVMBuildFNeg(builder, det, ""), det, "");
|
||||
|
||||
LLVMValueRef accepted = NULL;
|
||||
if (cull_front) {
|
||||
@@ -120,17 +115,11 @@ static LLVMValueRef ac_cull_face(struct ac_llvm_context *ctx,
|
||||
|
||||
/* Perform view culling and small primitive elimination and return true
|
||||
* if the primitive is accepted and initially_accepted == true. */
|
||||
static LLVMValueRef cull_bbox(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef pos[3][4],
|
||||
LLVMValueRef initially_accepted,
|
||||
struct ac_position_w_info *w,
|
||||
LLVMValueRef vp_scale[2],
|
||||
LLVMValueRef vp_translate[2],
|
||||
LLVMValueRef small_prim_precision,
|
||||
bool cull_view_xy,
|
||||
bool cull_view_near_z,
|
||||
bool cull_view_far_z,
|
||||
bool cull_small_prims,
|
||||
static LLVMValueRef cull_bbox(struct ac_llvm_context *ctx, LLVMValueRef pos[3][4],
|
||||
LLVMValueRef initially_accepted, struct ac_position_w_info *w,
|
||||
LLVMValueRef vp_scale[2], LLVMValueRef vp_translate[2],
|
||||
LLVMValueRef small_prim_precision, bool cull_view_xy,
|
||||
bool cull_view_near_z, bool cull_view_far_z, bool cull_small_prims,
|
||||
bool use_halfz_clip_space)
|
||||
{
|
||||
LLVMBuilderRef builder = ctx->builder;
|
||||
@@ -142,8 +131,7 @@ static LLVMValueRef cull_bbox(struct ac_llvm_context *ctx,
|
||||
* if any W is negative. The bounding box culling doesn't work when
|
||||
* W is negative.
|
||||
*/
|
||||
LLVMValueRef cond = LLVMBuildAnd(builder, initially_accepted,
|
||||
w->all_w_positive, "");
|
||||
LLVMValueRef cond = LLVMBuildAnd(builder, initially_accepted, w->all_w_positive, "");
|
||||
LLVMValueRef accepted_var = ac_build_alloca_undef(ctx, ctx->i1, "");
|
||||
LLVMBuildStore(builder, initially_accepted, accepted_var);
|
||||
|
||||
@@ -166,18 +154,15 @@ static LLVMValueRef cull_bbox(struct ac_llvm_context *ctx,
|
||||
for (unsigned chan = 0; chan < 3; chan++) {
|
||||
LLVMValueRef visible;
|
||||
|
||||
if ((cull_view_xy && chan <= 1) ||
|
||||
(cull_view_near_z && chan == 2)) {
|
||||
if ((cull_view_xy && chan <= 1) || (cull_view_near_z && chan == 2)) {
|
||||
float t = chan == 2 && use_halfz_clip_space ? 0 : -1;
|
||||
visible = LLVMBuildFCmp(builder, LLVMRealOGE, bbox_max[chan],
|
||||
LLVMConstReal(ctx->f32, t), "");
|
||||
accepted = LLVMBuildAnd(builder, accepted, visible, "");
|
||||
}
|
||||
|
||||
if ((cull_view_xy && chan <= 1) ||
|
||||
(cull_view_far_z && chan == 2)) {
|
||||
visible = LLVMBuildFCmp(builder, LLVMRealOLE, bbox_min[chan],
|
||||
ctx->f32_1, "");
|
||||
if ((cull_view_xy && chan <= 1) || (cull_view_far_z && chan == 2)) {
|
||||
visible = LLVMBuildFCmp(builder, LLVMRealOLE, bbox_min[chan], ctx->f32_1, "");
|
||||
accepted = LLVMBuildAnd(builder, accepted, visible, "");
|
||||
}
|
||||
}
|
||||
@@ -197,10 +182,8 @@ static LLVMValueRef cull_bbox(struct ac_llvm_context *ctx,
|
||||
|
||||
for (unsigned chan = 0; chan < 2; chan++) {
|
||||
/* Convert the position to screen-space coordinates. */
|
||||
min = ac_build_fmad(ctx, bbox_min[chan],
|
||||
vp_scale[chan], vp_translate[chan]);
|
||||
max = ac_build_fmad(ctx, bbox_max[chan],
|
||||
vp_scale[chan], vp_translate[chan]);
|
||||
min = ac_build_fmad(ctx, bbox_min[chan], vp_scale[chan], vp_translate[chan]);
|
||||
max = ac_build_fmad(ctx, bbox_max[chan], vp_scale[chan], vp_translate[chan]);
|
||||
/* Scale the bounding box according to the precision of
|
||||
* the rasterizer and the number of MSAA samples. */
|
||||
min = LLVMBuildFSub(builder, min, small_prim_precision, "");
|
||||
@@ -241,12 +224,9 @@ static LLVMValueRef cull_bbox(struct ac_llvm_context *ctx,
|
||||
* subpixel_bits are defined by the quantization mode.
|
||||
* \param options See ac_cull_options.
|
||||
*/
|
||||
LLVMValueRef ac_cull_triangle(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef pos[3][4],
|
||||
LLVMValueRef initially_accepted,
|
||||
LLVMValueRef vp_scale[2],
|
||||
LLVMValueRef vp_translate[2],
|
||||
LLVMValueRef small_prim_precision,
|
||||
LLVMValueRef ac_cull_triangle(struct ac_llvm_context *ctx, LLVMValueRef pos[3][4],
|
||||
LLVMValueRef initially_accepted, LLVMValueRef vp_scale[2],
|
||||
LLVMValueRef vp_translate[2], LLVMValueRef small_prim_precision,
|
||||
struct ac_cull_options *options)
|
||||
{
|
||||
struct ac_position_w_info w;
|
||||
@@ -257,19 +237,14 @@ LLVMValueRef ac_cull_triangle(struct ac_llvm_context *ctx,
|
||||
accepted = LLVMBuildAnd(ctx->builder, accepted, initially_accepted, "");
|
||||
|
||||
/* Face culling. */
|
||||
accepted = LLVMBuildAnd(ctx->builder, accepted,
|
||||
ac_cull_face(ctx, pos, &w,
|
||||
options->cull_front,
|
||||
options->cull_back,
|
||||
options->cull_zero_area), "");
|
||||
accepted = LLVMBuildAnd(
|
||||
ctx->builder, accepted,
|
||||
ac_cull_face(ctx, pos, &w, options->cull_front, options->cull_back, options->cull_zero_area),
|
||||
"");
|
||||
|
||||
/* View culling and small primitive elimination. */
|
||||
accepted = cull_bbox(ctx, pos, accepted, &w, vp_scale, vp_translate,
|
||||
small_prim_precision,
|
||||
options->cull_view_xy,
|
||||
options->cull_view_near_z,
|
||||
options->cull_view_far_z,
|
||||
options->cull_small_prims,
|
||||
options->use_halfz_clip_space);
|
||||
accepted = cull_bbox(ctx, pos, accepted, &w, vp_scale, vp_translate, small_prim_precision,
|
||||
options->cull_view_xy, options->cull_view_near_z, options->cull_view_far_z,
|
||||
options->cull_small_prims, options->use_halfz_clip_space);
|
||||
return accepted;
|
||||
}
|
||||
|
@@ -48,12 +48,9 @@ struct ac_cull_options {
|
||||
bool use_halfz_clip_space;
|
||||
};
|
||||
|
||||
LLVMValueRef ac_cull_triangle(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef pos[3][4],
|
||||
LLVMValueRef initially_accepted,
|
||||
LLVMValueRef vp_scale[2],
|
||||
LLVMValueRef vp_translate[2],
|
||||
LLVMValueRef small_prim_precision,
|
||||
LLVMValueRef ac_cull_triangle(struct ac_llvm_context *ctx, LLVMValueRef pos[3][4],
|
||||
LLVMValueRef initially_accepted, LLVMValueRef vp_scale[2],
|
||||
LLVMValueRef vp_translate[2], LLVMValueRef small_prim_precision,
|
||||
struct ac_cull_options *options);
|
||||
|
||||
#endif
|
||||
|
@@ -23,15 +23,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include <llvm-c/Core.h>
|
||||
#include <llvm/Target/TargetMachine.h>
|
||||
#include <llvm/IR/IRBuilder.h>
|
||||
#include <llvm/Analysis/TargetLibraryInfo.h>
|
||||
#include <llvm/IR/IRBuilder.h>
|
||||
#include <llvm/IR/LegacyPassManager.h>
|
||||
#include <llvm/Target/TargetMachine.h>
|
||||
#include <llvm/Transforms/IPO.h>
|
||||
|
||||
#include <llvm/IR/LegacyPassManager.h>
|
||||
#include <cstring>
|
||||
|
||||
/* DO NOT REORDER THE HEADERS
|
||||
* The LLVM headers need to all be included before any Mesa header,
|
||||
@@ -42,7 +41,6 @@
|
||||
#include "ac_binary.h"
|
||||
#include "ac_llvm_util.h"
|
||||
#include "ac_llvm_build.h"
|
||||
|
||||
#include "util/macros.h"
|
||||
|
||||
void ac_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes)
|
||||
@@ -91,8 +89,7 @@ LLVMModuleRef ac_create_module(LLVMTargetMachineRef tm, LLVMContextRef ctx)
|
||||
return module;
|
||||
}
|
||||
|
||||
LLVMBuilderRef ac_create_builder(LLVMContextRef ctx,
|
||||
enum ac_float_mode float_mode)
|
||||
LLVMBuilderRef ac_create_builder(LLVMContextRef ctx, enum ac_float_mode float_mode)
|
||||
{
|
||||
LLVMBuilderRef builder = LLVMCreateBuilderInContext(ctx);
|
||||
|
||||
@@ -146,14 +143,13 @@ void ac_disable_signed_zeros(struct ac_llvm_context *ctx)
|
||||
}
|
||||
}
|
||||
|
||||
LLVMTargetLibraryInfoRef
|
||||
ac_create_target_library_info(const char *triple)
|
||||
LLVMTargetLibraryInfoRef ac_create_target_library_info(const char *triple)
|
||||
{
|
||||
return reinterpret_cast<LLVMTargetLibraryInfoRef>(new llvm::TargetLibraryInfoImpl(llvm::Triple(triple)));
|
||||
return reinterpret_cast<LLVMTargetLibraryInfoRef>(
|
||||
new llvm::TargetLibraryInfoImpl(llvm::Triple(triple)));
|
||||
}
|
||||
|
||||
void
|
||||
ac_dispose_target_library_info(LLVMTargetLibraryInfoRef library_info)
|
||||
void ac_dispose_target_library_info(LLVMTargetLibraryInfoRef library_info)
|
||||
{
|
||||
delete reinterpret_cast<llvm::TargetLibraryInfoImpl *>(library_info);
|
||||
}
|
||||
@@ -212,8 +208,7 @@ struct raw_memory_ostream : public llvm::raw_pwrite_stream {
|
||||
|
||||
void pwrite_impl(const char *ptr, size_t size, uint64_t offset) override
|
||||
{
|
||||
assert(offset == (size_t)offset &&
|
||||
offset + size >= offset && offset + size <= written);
|
||||
assert(offset == (size_t)offset && offset + size >= offset && offset + size <= written);
|
||||
memcpy(buffer + offset, ptr, size);
|
||||
}
|
||||
|
||||
@@ -239,8 +234,7 @@ struct ac_compiler_passes *ac_create_llvm_passes(LLVMTargetMachineRef tm)
|
||||
|
||||
llvm::TargetMachine *TM = reinterpret_cast<llvm::TargetMachine *>(tm);
|
||||
|
||||
if (TM->addPassesToEmitFile(p->passmgr, p->ostream,
|
||||
nullptr,
|
||||
if (TM->addPassesToEmitFile(p->passmgr, p->ostream, nullptr,
|
||||
#if LLVM_VERSION_MAJOR >= 10
|
||||
llvm::CGFT_ObjectFile)) {
|
||||
#else
|
||||
@@ -278,8 +272,8 @@ void ac_enable_global_isel(LLVMTargetMachineRef tm)
|
||||
}
|
||||
|
||||
LLVMValueRef ac_build_atomic_rmw(struct ac_llvm_context *ctx, LLVMAtomicRMWBinOp op,
|
||||
LLVMValueRef ptr, LLVMValueRef val,
|
||||
const char *sync_scope) {
|
||||
LLVMValueRef ptr, LLVMValueRef val, const char *sync_scope)
|
||||
{
|
||||
llvm::AtomicRMWInst::BinOp binop;
|
||||
switch (op) {
|
||||
case LLVMAtomicRMWBinOpXchg:
|
||||
@@ -320,17 +314,18 @@ LLVMValueRef ac_build_atomic_rmw(struct ac_llvm_context *ctx, LLVMAtomicRMWBinOp
|
||||
break;
|
||||
}
|
||||
unsigned SSID = llvm::unwrap(ctx->context)->getOrInsertSyncScopeID(sync_scope);
|
||||
return llvm::wrap(llvm::unwrap(ctx->builder)->CreateAtomicRMW(
|
||||
binop, llvm::unwrap(ptr), llvm::unwrap(val),
|
||||
return llvm::wrap(llvm::unwrap(ctx->builder)
|
||||
->CreateAtomicRMW(binop, llvm::unwrap(ptr), llvm::unwrap(val),
|
||||
llvm::AtomicOrdering::SequentiallyConsistent, SSID));
|
||||
}
|
||||
|
||||
LLVMValueRef ac_build_atomic_cmp_xchg(struct ac_llvm_context *ctx, LLVMValueRef ptr,
|
||||
LLVMValueRef cmp, LLVMValueRef val,
|
||||
const char *sync_scope) {
|
||||
LLVMValueRef cmp, LLVMValueRef val, const char *sync_scope)
|
||||
{
|
||||
unsigned SSID = llvm::unwrap(ctx->context)->getOrInsertSyncScopeID(sync_scope);
|
||||
return llvm::wrap(llvm::unwrap(ctx->builder)->CreateAtomicCmpXchg(
|
||||
llvm::unwrap(ptr), llvm::unwrap(cmp), llvm::unwrap(val),
|
||||
return llvm::wrap(llvm::unwrap(ctx->builder)
|
||||
->CreateAtomicCmpXchg(llvm::unwrap(ptr), llvm::unwrap(cmp),
|
||||
llvm::unwrap(val),
|
||||
llvm::AtomicOrdering::SequentiallyConsistent,
|
||||
llvm::AtomicOrdering::SequentiallyConsistent, SSID));
|
||||
}
|
||||
|
@@ -24,16 +24,17 @@
|
||||
*/
|
||||
/* based on pieces from si_pipe.c and radeon_llvm_emit.c */
|
||||
#include "ac_llvm_util.h"
|
||||
|
||||
#include "ac_llvm_build.h"
|
||||
#include "c11/threads.h"
|
||||
#include "gallivm/lp_bld_misc.h"
|
||||
#include "util/bitscan.h"
|
||||
#include "util/u_math.h"
|
||||
#include <llvm-c/Core.h>
|
||||
#include <llvm-c/Support.h>
|
||||
#include <llvm-c/Transforms/IPO.h>
|
||||
#include <llvm-c/Transforms/Scalar.h>
|
||||
#include <llvm-c/Transforms/Utils.h>
|
||||
#include "c11/threads.h"
|
||||
#include "gallivm/lp_bld_misc.h"
|
||||
#include "util/u_math.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
@@ -191,23 +192,18 @@ static LLVMTargetMachineRef ac_create_target_machine(enum radeon_family family,
|
||||
const char *triple = (tm_options & AC_TM_SUPPORTS_SPILL) ? "amdgcn-mesa-mesa3d" : "amdgcn--";
|
||||
LLVMTargetRef target = ac_get_llvm_target(triple);
|
||||
|
||||
snprintf(features, sizeof(features),
|
||||
"+DumpCode%s%s%s%s%s",
|
||||
snprintf(features, sizeof(features), "+DumpCode%s%s%s%s%s",
|
||||
LLVM_VERSION_MAJOR >= 11 ? "" : ",-fp32-denormals,+fp64-denormals",
|
||||
family >= CHIP_NAVI10 && !(tm_options & AC_TM_WAVE32) ?
|
||||
",+wavefrontsize64,-wavefrontsize32" : "",
|
||||
family >= CHIP_NAVI10 && !(tm_options & AC_TM_WAVE32)
|
||||
? ",+wavefrontsize64,-wavefrontsize32"
|
||||
: "",
|
||||
family <= CHIP_NAVI14 && tm_options & AC_TM_FORCE_ENABLE_XNACK ? ",+xnack" : "",
|
||||
family <= CHIP_NAVI14 && tm_options & AC_TM_FORCE_DISABLE_XNACK ? ",-xnack" : "",
|
||||
tm_options & AC_TM_PROMOTE_ALLOCA_TO_SCRATCH ? ",-promote-alloca" : "");
|
||||
|
||||
LLVMTargetMachineRef tm = LLVMCreateTargetMachine(
|
||||
target,
|
||||
triple,
|
||||
ac_get_llvm_processor_name(family),
|
||||
features,
|
||||
level,
|
||||
LLVMRelocDefault,
|
||||
LLVMCodeModelDefault);
|
||||
LLVMTargetMachineRef tm =
|
||||
LLVMCreateTargetMachine(target, triple, ac_get_llvm_processor_name(family), features, level,
|
||||
LLVMRelocDefault, LLVMCodeModelDefault);
|
||||
|
||||
if (out_triple)
|
||||
*out_triple = triple;
|
||||
@@ -224,8 +220,7 @@ static LLVMPassManagerRef ac_create_passmgr(LLVMTargetLibraryInfoRef target_libr
|
||||
return NULL;
|
||||
|
||||
if (target_library_info)
|
||||
LLVMAddTargetLibraryInfo(target_library_info,
|
||||
passmgr);
|
||||
LLVMAddTargetLibraryInfo(target_library_info, passmgr);
|
||||
|
||||
if (check_ir)
|
||||
LLVMAddVerifierPass(passmgr);
|
||||
@@ -252,28 +247,35 @@ static LLVMPassManagerRef ac_create_passmgr(LLVMTargetLibraryInfoRef target_libr
|
||||
static const char *attr_to_str(enum ac_func_attr attr)
|
||||
{
|
||||
switch (attr) {
|
||||
case AC_FUNC_ATTR_ALWAYSINLINE: return "alwaysinline";
|
||||
case AC_FUNC_ATTR_INREG: return "inreg";
|
||||
case AC_FUNC_ATTR_NOALIAS: return "noalias";
|
||||
case AC_FUNC_ATTR_NOUNWIND: return "nounwind";
|
||||
case AC_FUNC_ATTR_READNONE: return "readnone";
|
||||
case AC_FUNC_ATTR_READONLY: return "readonly";
|
||||
case AC_FUNC_ATTR_WRITEONLY: return "writeonly";
|
||||
case AC_FUNC_ATTR_INACCESSIBLE_MEM_ONLY: return "inaccessiblememonly";
|
||||
case AC_FUNC_ATTR_CONVERGENT: return "convergent";
|
||||
case AC_FUNC_ATTR_ALWAYSINLINE:
|
||||
return "alwaysinline";
|
||||
case AC_FUNC_ATTR_INREG:
|
||||
return "inreg";
|
||||
case AC_FUNC_ATTR_NOALIAS:
|
||||
return "noalias";
|
||||
case AC_FUNC_ATTR_NOUNWIND:
|
||||
return "nounwind";
|
||||
case AC_FUNC_ATTR_READNONE:
|
||||
return "readnone";
|
||||
case AC_FUNC_ATTR_READONLY:
|
||||
return "readonly";
|
||||
case AC_FUNC_ATTR_WRITEONLY:
|
||||
return "writeonly";
|
||||
case AC_FUNC_ATTR_INACCESSIBLE_MEM_ONLY:
|
||||
return "inaccessiblememonly";
|
||||
case AC_FUNC_ATTR_CONVERGENT:
|
||||
return "convergent";
|
||||
default:
|
||||
fprintf(stderr, "Unhandled function attribute: %x\n", attr);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ac_add_function_attr(LLVMContextRef ctx, LLVMValueRef function,
|
||||
int attr_idx, enum ac_func_attr attr)
|
||||
void ac_add_function_attr(LLVMContextRef ctx, LLVMValueRef function, int attr_idx,
|
||||
enum ac_func_attr attr)
|
||||
{
|
||||
const char *attr_name = attr_to_str(attr);
|
||||
unsigned kind_id = LLVMGetEnumAttributeKindForName(attr_name,
|
||||
strlen(attr_name));
|
||||
unsigned kind_id = LLVMGetEnumAttributeKindForName(attr_name, strlen(attr_name));
|
||||
LLVMAttributeRef llvm_attr = LLVMCreateEnumAttribute(ctx, kind_id, 0);
|
||||
|
||||
if (LLVMIsAFunction(function))
|
||||
@@ -282,8 +284,7 @@ ac_add_function_attr(LLVMContextRef ctx, LLVMValueRef function,
|
||||
LLVMAddCallSiteAttribute(function, attr_idx, llvm_attr);
|
||||
}
|
||||
|
||||
void ac_add_func_attributes(LLVMContextRef ctx, LLVMValueRef function,
|
||||
unsigned attrib_mask)
|
||||
void ac_add_func_attributes(LLVMContextRef ctx, LLVMValueRef function, unsigned attrib_mask)
|
||||
{
|
||||
attrib_mask |= AC_FUNC_ATTR_NOUNWIND;
|
||||
attrib_mask &= ~AC_FUNC_ATTR_LEGACY;
|
||||
@@ -294,17 +295,14 @@ void ac_add_func_attributes(LLVMContextRef ctx, LLVMValueRef function,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ac_dump_module(LLVMModuleRef module)
|
||||
void ac_dump_module(LLVMModuleRef module)
|
||||
{
|
||||
char *str = LLVMPrintModuleToString(module);
|
||||
fprintf(stderr, "%s", str);
|
||||
LLVMDisposeMessage(str);
|
||||
}
|
||||
|
||||
void
|
||||
ac_llvm_add_target_dep_function_attr(LLVMValueRef F,
|
||||
const char *name, unsigned value)
|
||||
void ac_llvm_add_target_dep_function_attr(LLVMValueRef F, const char *name, unsigned value)
|
||||
{
|
||||
char str[16];
|
||||
|
||||
@@ -322,8 +320,7 @@ void ac_llvm_set_workgroup_size(LLVMValueRef F, unsigned size)
|
||||
LLVMAddTargetDependentFunctionAttr(F, "amdgpu-flat-work-group-size", str);
|
||||
}
|
||||
|
||||
unsigned
|
||||
ac_count_scratch_private_memory(LLVMValueRef function)
|
||||
unsigned ac_count_scratch_private_memory(LLVMValueRef function)
|
||||
{
|
||||
unsigned private_mem_vgprs = 0;
|
||||
|
||||
@@ -351,45 +348,37 @@ ac_count_scratch_private_memory(LLVMValueRef function)
|
||||
return private_mem_vgprs;
|
||||
}
|
||||
|
||||
bool
|
||||
ac_init_llvm_compiler(struct ac_llvm_compiler *compiler,
|
||||
enum radeon_family family,
|
||||
bool ac_init_llvm_compiler(struct ac_llvm_compiler *compiler, enum radeon_family family,
|
||||
enum ac_target_machine_options tm_options)
|
||||
{
|
||||
const char *triple;
|
||||
memset(compiler, 0, sizeof(*compiler));
|
||||
|
||||
compiler->tm = ac_create_target_machine(family, tm_options,
|
||||
LLVMCodeGenLevelDefault,
|
||||
&triple);
|
||||
compiler->tm = ac_create_target_machine(family, tm_options, LLVMCodeGenLevelDefault, &triple);
|
||||
if (!compiler->tm)
|
||||
return false;
|
||||
|
||||
if (tm_options & AC_TM_CREATE_LOW_OPT) {
|
||||
compiler->low_opt_tm =
|
||||
ac_create_target_machine(family, tm_options,
|
||||
LLVMCodeGenLevelLess, NULL);
|
||||
ac_create_target_machine(family, tm_options, LLVMCodeGenLevelLess, NULL);
|
||||
if (!compiler->low_opt_tm)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (family >= CHIP_NAVI10) {
|
||||
assert(!(tm_options & AC_TM_CREATE_LOW_OPT));
|
||||
compiler->tm_wave32 = ac_create_target_machine(family,
|
||||
tm_options | AC_TM_WAVE32,
|
||||
LLVMCodeGenLevelDefault,
|
||||
NULL);
|
||||
compiler->tm_wave32 =
|
||||
ac_create_target_machine(family, tm_options | AC_TM_WAVE32, LLVMCodeGenLevelDefault, NULL);
|
||||
if (!compiler->tm_wave32)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
compiler->target_library_info =
|
||||
ac_create_target_library_info(triple);
|
||||
compiler->target_library_info = ac_create_target_library_info(triple);
|
||||
if (!compiler->target_library_info)
|
||||
goto fail;
|
||||
|
||||
compiler->passmgr = ac_create_passmgr(compiler->target_library_info,
|
||||
tm_options & AC_TM_CHECK_IR);
|
||||
compiler->passmgr =
|
||||
ac_create_passmgr(compiler->target_library_info, tm_options & AC_TM_CHECK_IR);
|
||||
if (!compiler->passmgr)
|
||||
goto fail;
|
||||
|
||||
@@ -399,8 +388,7 @@ fail:
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
ac_destroy_llvm_compiler(struct ac_llvm_compiler *compiler)
|
||||
void ac_destroy_llvm_compiler(struct ac_llvm_compiler *compiler)
|
||||
{
|
||||
ac_destroy_llvm_passes(compiler->passes);
|
||||
ac_destroy_llvm_passes(compiler->passes_wave32);
|
||||
|
@@ -26,11 +26,11 @@
|
||||
#ifndef AC_LLVM_UTIL_H
|
||||
#define AC_LLVM_UTIL_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "amd_family.h"
|
||||
#include <llvm-c/TargetMachine.h>
|
||||
#include <llvm/Config/llvm-config.h>
|
||||
|
||||
#include "amd_family.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -39,7 +39,8 @@ extern "C" {
|
||||
struct ac_compiler_passes;
|
||||
struct ac_llvm_context;
|
||||
|
||||
enum ac_func_attr {
|
||||
enum ac_func_attr
|
||||
{
|
||||
AC_FUNC_ATTR_ALWAYSINLINE = (1 << 0),
|
||||
AC_FUNC_ATTR_INREG = (1 << 2),
|
||||
AC_FUNC_ATTR_NOALIAS = (1 << 3),
|
||||
@@ -57,7 +58,8 @@ enum ac_func_attr {
|
||||
AC_FUNC_ATTR_LEGACY = (1u << 31),
|
||||
};
|
||||
|
||||
enum ac_target_machine_options {
|
||||
enum ac_target_machine_options
|
||||
{
|
||||
AC_TM_SUPPORTS_SPILL = (1 << 0),
|
||||
AC_TM_FORCE_ENABLE_XNACK = (1 << 1),
|
||||
AC_TM_FORCE_DISABLE_XNACK = (1 << 2),
|
||||
@@ -68,7 +70,8 @@ enum ac_target_machine_options {
|
||||
AC_TM_WAVE32 = (1 << 7),
|
||||
};
|
||||
|
||||
enum ac_float_mode {
|
||||
enum ac_float_mode
|
||||
{
|
||||
AC_FLOAT_MODE_DEFAULT,
|
||||
AC_FLOAT_MODE_DEFAULT_OPENGL,
|
||||
AC_FLOAT_MODE_DENORM_FLUSH_TO_ZERO,
|
||||
@@ -98,46 +101,37 @@ const char *ac_get_llvm_processor_name(enum radeon_family family);
|
||||
void ac_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes);
|
||||
void ac_add_attr_alignment(LLVMValueRef val, uint64_t bytes);
|
||||
bool ac_is_sgpr_param(LLVMValueRef param);
|
||||
void ac_add_function_attr(LLVMContextRef ctx, LLVMValueRef function,
|
||||
int attr_idx, enum ac_func_attr attr);
|
||||
void ac_add_func_attributes(LLVMContextRef ctx, LLVMValueRef function,
|
||||
unsigned attrib_mask);
|
||||
void ac_add_function_attr(LLVMContextRef ctx, LLVMValueRef function, int attr_idx,
|
||||
enum ac_func_attr attr);
|
||||
void ac_add_func_attributes(LLVMContextRef ctx, LLVMValueRef function, unsigned attrib_mask);
|
||||
void ac_dump_module(LLVMModuleRef module);
|
||||
|
||||
LLVMValueRef ac_llvm_get_called_value(LLVMValueRef call);
|
||||
bool ac_llvm_is_function(LLVMValueRef v);
|
||||
LLVMModuleRef ac_create_module(LLVMTargetMachineRef tm, LLVMContextRef ctx);
|
||||
|
||||
LLVMBuilderRef ac_create_builder(LLVMContextRef ctx,
|
||||
enum ac_float_mode float_mode);
|
||||
LLVMBuilderRef ac_create_builder(LLVMContextRef ctx, enum ac_float_mode float_mode);
|
||||
void ac_enable_signed_zeros(struct ac_llvm_context *ctx);
|
||||
void ac_disable_signed_zeros(struct ac_llvm_context *ctx);
|
||||
|
||||
void
|
||||
ac_llvm_add_target_dep_function_attr(LLVMValueRef F,
|
||||
const char *name, unsigned value);
|
||||
void ac_llvm_add_target_dep_function_attr(LLVMValueRef F, const char *name, unsigned value);
|
||||
void ac_llvm_set_workgroup_size(LLVMValueRef F, unsigned size);
|
||||
|
||||
static inline unsigned
|
||||
ac_get_load_intr_attribs(bool can_speculate)
|
||||
static inline unsigned ac_get_load_intr_attribs(bool can_speculate)
|
||||
{
|
||||
/* READNONE means writes can't affect it, while READONLY means that
|
||||
* writes can affect it. */
|
||||
return can_speculate ? AC_FUNC_ATTR_READNONE :
|
||||
AC_FUNC_ATTR_READONLY;
|
||||
return can_speculate ? AC_FUNC_ATTR_READNONE : AC_FUNC_ATTR_READONLY;
|
||||
}
|
||||
|
||||
unsigned
|
||||
ac_count_scratch_private_memory(LLVMValueRef function);
|
||||
unsigned ac_count_scratch_private_memory(LLVMValueRef function);
|
||||
|
||||
LLVMTargetLibraryInfoRef ac_create_target_library_info(const char *triple);
|
||||
void ac_dispose_target_library_info(LLVMTargetLibraryInfoRef library_info);
|
||||
void ac_init_shared_llvm_once(void); /* Do not use directly, use ac_init_llvm_once */
|
||||
void ac_init_llvm_once(void);
|
||||
|
||||
|
||||
bool ac_init_llvm_compiler(struct ac_llvm_compiler *compiler,
|
||||
enum radeon_family family,
|
||||
bool ac_init_llvm_compiler(struct ac_llvm_compiler *compiler, enum radeon_family family,
|
||||
enum ac_target_machine_options tm_options);
|
||||
void ac_destroy_llvm_compiler(struct ac_llvm_compiler *compiler);
|
||||
|
||||
@@ -148,8 +142,7 @@ bool ac_compile_module_to_elf(struct ac_compiler_passes *p, LLVMModuleRef module
|
||||
void ac_llvm_add_barrier_noop_pass(LLVMPassManagerRef passmgr);
|
||||
void ac_enable_global_isel(LLVMTargetMachineRef tm);
|
||||
|
||||
static inline bool
|
||||
ac_has_vec3_support(enum chip_class chip, bool use_format)
|
||||
static inline bool ac_has_vec3_support(enum chip_class chip, bool use_format)
|
||||
{
|
||||
if (chip == GFX6 && !use_format) {
|
||||
/* GFX6 only supports vec3 with load/store format. */
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -24,11 +24,12 @@
|
||||
#ifndef AC_NIR_TO_LLVM_H
|
||||
#define AC_NIR_TO_LLVM_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "llvm-c/Core.h"
|
||||
#include "llvm-c/TargetMachine.h"
|
||||
#include "amd_family.h"
|
||||
#include "compiler/shader_enums.h"
|
||||
#include "llvm-c/Core.h"
|
||||
#include "llvm-c/TargetMachine.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
struct nir_shader;
|
||||
struct nir_variable;
|
||||
@@ -53,11 +54,8 @@ bool ac_are_tessfactors_def_in_all_invocs(const struct nir_shader *nir);
|
||||
void ac_nir_translate(struct ac_llvm_context *ac, struct ac_shader_abi *abi,
|
||||
const struct ac_shader_args *args, struct nir_shader *nir);
|
||||
|
||||
void
|
||||
ac_handle_shader_output_decl(struct ac_llvm_context *ctx,
|
||||
struct ac_shader_abi *abi,
|
||||
struct nir_shader *nir,
|
||||
struct nir_variable *variable,
|
||||
void ac_handle_shader_output_decl(struct ac_llvm_context *ctx, struct ac_shader_abi *abi,
|
||||
struct nir_shader *nir, struct nir_variable *variable,
|
||||
gl_shader_stage stage);
|
||||
|
||||
void ac_emit_barrier(struct ac_llvm_context *ac, gl_shader_stage stage);
|
||||
|
@@ -24,11 +24,11 @@
|
||||
#ifndef AC_SHADER_ABI_H
|
||||
#define AC_SHADER_ABI_H
|
||||
|
||||
#include <llvm-c/Core.h>
|
||||
#include <assert.h>
|
||||
#include "ac_shader_args.h"
|
||||
|
||||
#include "compiler/shader_enums.h"
|
||||
#include <llvm-c/Core.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
struct nir_variable;
|
||||
|
||||
@@ -36,7 +36,8 @@ struct nir_variable;
|
||||
|
||||
#define AC_MAX_INLINE_PUSH_CONSTS 8
|
||||
|
||||
enum ac_descriptor_type {
|
||||
enum ac_descriptor_type
|
||||
{
|
||||
AC_DESC_IMAGE,
|
||||
AC_DESC_FMASK,
|
||||
AC_DESC_SAMPLER,
|
||||
@@ -69,63 +70,39 @@ struct ac_shader_abi {
|
||||
/* Varying -> attribute number mapping. Also NIR-only */
|
||||
unsigned fs_input_attr_indices[MAX_VARYING];
|
||||
|
||||
void (*emit_outputs)(struct ac_shader_abi *abi,
|
||||
unsigned max_outputs,
|
||||
LLVMValueRef *addrs);
|
||||
void (*emit_outputs)(struct ac_shader_abi *abi, unsigned max_outputs, LLVMValueRef *addrs);
|
||||
|
||||
void (*emit_vertex)(struct ac_shader_abi *abi,
|
||||
unsigned stream,
|
||||
LLVMValueRef *addrs);
|
||||
void (*emit_vertex)(struct ac_shader_abi *abi, unsigned stream, LLVMValueRef *addrs);
|
||||
|
||||
void (*emit_primitive)(struct ac_shader_abi *abi,
|
||||
unsigned stream);
|
||||
void (*emit_primitive)(struct ac_shader_abi *abi, unsigned stream);
|
||||
|
||||
void (*emit_vertex_with_counter)(struct ac_shader_abi *abi,
|
||||
unsigned stream,
|
||||
LLVMValueRef vertexidx,
|
||||
LLVMValueRef *addrs);
|
||||
void (*emit_vertex_with_counter)(struct ac_shader_abi *abi, unsigned stream,
|
||||
LLVMValueRef vertexidx, LLVMValueRef *addrs);
|
||||
|
||||
LLVMValueRef (*load_inputs)(struct ac_shader_abi *abi,
|
||||
unsigned location,
|
||||
unsigned driver_location,
|
||||
unsigned component,
|
||||
unsigned num_components,
|
||||
unsigned vertex_index,
|
||||
unsigned const_index,
|
||||
LLVMValueRef (*load_inputs)(struct ac_shader_abi *abi, unsigned location,
|
||||
unsigned driver_location, unsigned component,
|
||||
unsigned num_components, unsigned vertex_index, unsigned const_index,
|
||||
LLVMTypeRef type);
|
||||
|
||||
LLVMValueRef (*load_tess_varyings)(struct ac_shader_abi *abi,
|
||||
LLVMTypeRef type,
|
||||
LLVMValueRef vertex_index,
|
||||
LLVMValueRef param_index,
|
||||
unsigned const_index,
|
||||
unsigned location,
|
||||
unsigned driver_location,
|
||||
unsigned component,
|
||||
unsigned num_components,
|
||||
bool is_patch,
|
||||
bool is_compact,
|
||||
LLVMValueRef (*load_tess_varyings)(struct ac_shader_abi *abi, LLVMTypeRef type,
|
||||
LLVMValueRef vertex_index, LLVMValueRef param_index,
|
||||
unsigned const_index, unsigned location,
|
||||
unsigned driver_location, unsigned component,
|
||||
unsigned num_components, bool is_patch, bool is_compact,
|
||||
bool load_inputs);
|
||||
|
||||
void (*store_tcs_outputs)(struct ac_shader_abi *abi,
|
||||
const struct nir_variable *var,
|
||||
LLVMValueRef vertex_index,
|
||||
LLVMValueRef param_index,
|
||||
unsigned const_index,
|
||||
LLVMValueRef src,
|
||||
unsigned writemask,
|
||||
unsigned component,
|
||||
unsigned driver_location);
|
||||
void (*store_tcs_outputs)(struct ac_shader_abi *abi, const struct nir_variable *var,
|
||||
LLVMValueRef vertex_index, LLVMValueRef param_index,
|
||||
unsigned const_index, LLVMValueRef src, unsigned writemask,
|
||||
unsigned component, unsigned driver_location);
|
||||
|
||||
LLVMValueRef (*load_tess_coord)(struct ac_shader_abi *abi);
|
||||
|
||||
LLVMValueRef (*load_patch_vertices_in)(struct ac_shader_abi *abi);
|
||||
|
||||
LLVMValueRef (*load_tess_level)(struct ac_shader_abi *abi,
|
||||
unsigned varying_id,
|
||||
LLVMValueRef (*load_tess_level)(struct ac_shader_abi *abi, unsigned varying_id,
|
||||
bool load_default_state);
|
||||
|
||||
|
||||
LLVMValueRef (*load_ubo)(struct ac_shader_abi *abi, LLVMValueRef index);
|
||||
|
||||
/**
|
||||
@@ -135,8 +112,7 @@ struct ac_shader_abi {
|
||||
* in Vulkan, and the buffer index in OpenGL/Gallium
|
||||
* \param write whether buffer contents will be written
|
||||
*/
|
||||
LLVMValueRef (*load_ssbo)(struct ac_shader_abi *abi,
|
||||
LLVMValueRef buffer, bool write);
|
||||
LLVMValueRef (*load_ssbo)(struct ac_shader_abi *abi, LLVMValueRef buffer, bool write);
|
||||
|
||||
/**
|
||||
* Load a descriptor associated to a sampler.
|
||||
@@ -149,14 +125,10 @@ struct ac_shader_abi {
|
||||
* \param desc_type the type of descriptor to load
|
||||
* \param image whether the descriptor is loaded for an image operation
|
||||
*/
|
||||
LLVMValueRef (*load_sampler_desc)(struct ac_shader_abi *abi,
|
||||
unsigned descriptor_set,
|
||||
unsigned base_index,
|
||||
unsigned constant_index,
|
||||
LLVMValueRef index,
|
||||
enum ac_descriptor_type desc_type,
|
||||
bool image, bool write,
|
||||
bool bindless);
|
||||
LLVMValueRef (*load_sampler_desc)(struct ac_shader_abi *abi, unsigned descriptor_set,
|
||||
unsigned base_index, unsigned constant_index,
|
||||
LLVMValueRef index, enum ac_descriptor_type desc_type,
|
||||
bool image, bool write, bool bindless);
|
||||
|
||||
/**
|
||||
* Load a Vulkan-specific resource.
|
||||
@@ -165,13 +137,10 @@ struct ac_shader_abi {
|
||||
* \param desc_set descriptor set
|
||||
* \param binding descriptor set binding
|
||||
*/
|
||||
LLVMValueRef (*load_resource)(struct ac_shader_abi *abi,
|
||||
LLVMValueRef index,
|
||||
unsigned desc_set,
|
||||
LLVMValueRef (*load_resource)(struct ac_shader_abi *abi, LLVMValueRef index, unsigned desc_set,
|
||||
unsigned binding);
|
||||
|
||||
LLVMValueRef (*load_sample_position)(struct ac_shader_abi *abi,
|
||||
LLVMValueRef sample_id);
|
||||
LLVMValueRef (*load_sample_position)(struct ac_shader_abi *abi, LLVMValueRef sample_id);
|
||||
|
||||
LLVMValueRef (*load_local_group_size)(struct ac_shader_abi *abi);
|
||||
|
||||
|
Reference in New Issue
Block a user