radeonsi: move llvm internal header to si_shader_llvm.h

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25632>
This commit is contained in:
Qiang Yu 2023-09-04 14:56:21 +08:00
parent 032c592619
commit b511edc0d5
9 changed files with 116 additions and 86 deletions

View file

@ -73,6 +73,7 @@ files_libradeonsi = files(
'si_shader_info.c',
'si_shader_internal.h',
'si_shader_llvm.c',
'si_shader_llvm.h',
'si_shader_llvm_gs.c',
'si_shader_llvm_ps.c',
'si_shader_llvm_tess.c',

View file

@ -10,7 +10,6 @@
#include "driver_ddebug/dd_util.h"
#include "radeon_uvd.h"
#include "si_public.h"
#include "si_shader_internal.h"
#include "sid.h"
#include "ac_shadowed_regs.h"
#include "compiler/nir/nir.h"
@ -26,6 +25,10 @@
#include "vl/vl_decoder.h"
#include "si_utrace.h"
#ifdef LLVM_AVAILABLE
#include "ac_llvm_util.h"
#endif
#include <xf86drm.h>
static struct pipe_context *si_create_context(struct pipe_screen *screen, unsigned flags);

View file

@ -8,8 +8,8 @@
#define SI_SHADER_PRIVATE_H
#include "ac_hw_stage.h"
#include "ac_shader_abi.h"
#include "ac_llvm_build.h"
#include "ac_shader_args.h"
#include "ac_shader_util.h"
#include "si_shader.h"
#define SI_SPI_PS_INPUT_ADDR_FOR_PROLOG ( \
@ -78,49 +78,15 @@ struct si_shader_args {
struct ac_arg cs_image[3];
};
struct si_shader_context {
struct ac_llvm_context ac;
struct si_shader *shader;
struct si_screen *screen;
gl_shader_stage stage;
/* For clamping the non-constant index in resource indexing: */
unsigned num_const_buffers;
unsigned num_shader_buffers;
unsigned num_images;
unsigned num_samplers;
struct si_shader_args *args;
struct ac_shader_abi abi;
LLVMBasicBlockRef merged_wrap_if_entry_block;
int merged_wrap_if_label;
struct ac_llvm_pointer main_fn;
LLVMTypeRef return_type;
struct ac_llvm_compiler *compiler;
/* Preloaded descriptors. */
LLVMValueRef instance_divisor_constbuf;
LLVMValueRef gs_ngg_emit;
struct ac_llvm_pointer gs_ngg_scratch;
LLVMValueRef return_value;
};
static inline struct si_shader_context *si_shader_context_from_abi(struct ac_shader_abi *abi)
{
return container_of(abi, struct si_shader_context, abi);
}
struct ac_nir_gs_output_info;
typedef struct ac_nir_gs_output_info ac_nir_gs_output_info;
struct nir_builder;
typedef struct nir_builder nir_builder;
struct nir_shader;
typedef struct nir_shader nir_shader;
/* si_shader.c */
bool si_is_multi_part_shader(struct si_shader *shader);
bool si_is_merged_shader(struct si_shader *shader);
@ -184,31 +150,6 @@ bool si_nir_lower_vs_inputs(nir_shader *nir, struct si_shader *shader,
struct si_shader_args *args);
/* si_shader_llvm.c */
bool si_compile_llvm(struct si_screen *sscreen, struct si_shader_binary *binary,
struct ac_shader_config *conf, struct ac_llvm_compiler *compiler,
struct ac_llvm_context *ac, struct util_debug_callback *debug,
gl_shader_stage stage, const char *name, bool less_optimized);
void si_llvm_context_init(struct si_shader_context *ctx, struct si_screen *sscreen,
struct ac_llvm_compiler *compiler, unsigned wave_size,
bool exports_color_null, bool exports_mrtz,
enum ac_float_mode float_mode);
void si_llvm_create_func(struct si_shader_context *ctx, const char *name, LLVMTypeRef *return_types,
unsigned num_return_elems, unsigned max_workgroup_size);
void si_llvm_create_main_func(struct si_shader_context *ctx);
void si_llvm_optimize_module(struct si_shader_context *ctx);
void si_llvm_dispose(struct si_shader_context *ctx);
LLVMValueRef si_buffer_load_const(struct si_shader_context *ctx, LLVMValueRef resource,
LLVMValueRef offset);
void si_llvm_build_ret(struct si_shader_context *ctx, LLVMValueRef ret);
LLVMValueRef si_insert_input_ret(struct si_shader_context *ctx, LLVMValueRef ret,
struct ac_arg param, unsigned return_index);
LLVMValueRef si_insert_input_ret_float(struct si_shader_context *ctx, LLVMValueRef ret,
struct ac_arg param, unsigned return_index);
LLVMValueRef si_insert_input_ptr(struct si_shader_context *ctx, LLVMValueRef ret,
struct ac_arg param, unsigned return_index);
LLVMValueRef si_prolog_get_internal_binding_slot(struct si_shader_context *ctx, unsigned slot);
LLVMValueRef si_unpack_param(struct si_shader_context *ctx, struct ac_arg param, unsigned rshift,
unsigned bitwidth);
bool si_llvm_compile_shader(struct si_screen *sscreen, struct ac_llvm_compiler *compiler,
struct si_shader *shader, struct si_shader_args *args,
struct util_debug_callback *debug, struct nir_shader *nir);
@ -217,27 +158,6 @@ bool si_llvm_build_shader_part(struct si_screen *sscreen, gl_shader_stage stage,
struct util_debug_callback *debug, const char *name,
struct si_shader_part *result);
/* si_shader_llvm_gs.c */
LLVMValueRef si_is_es_thread(struct si_shader_context *ctx);
LLVMValueRef si_is_gs_thread(struct si_shader_context *ctx);
void si_llvm_es_build_end(struct si_shader_context *ctx);
void si_llvm_gs_build_end(struct si_shader_context *ctx);
/* si_shader_llvm_tess.c */
LLVMValueRef si_get_rel_patch_id(struct si_shader_context *ctx);
void si_llvm_ls_build_end(struct si_shader_context *ctx);
void si_llvm_build_tcs_epilog(struct si_shader_context *ctx, union si_shader_part_key *key);
void si_llvm_tcs_build_end(struct si_shader_context *ctx);
void si_llvm_init_tcs_callbacks(struct si_shader_context *ctx);
/* si_shader_llvm_ps.c */
void si_llvm_build_ps_prolog(struct si_shader_context *ctx, union si_shader_part_key *key);
void si_llvm_build_ps_epilog(struct si_shader_context *ctx, union si_shader_part_key *key);
void si_llvm_ps_build_end(struct si_shader_context *ctx);
/* si_shader_llvm_vs.c */
void si_llvm_build_vs_prolog(struct si_shader_context *ctx, union si_shader_part_key *key);
/* si_shader_aco.c */
bool si_aco_compile_shader(struct si_shader *shader,
struct si_shader_args *args,

View file

@ -9,6 +9,7 @@
#include "ac_rtld.h"
#include "si_pipe.h"
#include "si_shader_internal.h"
#include "si_shader_llvm.h"
#include "sid.h"
#include "util/u_memory.h"
#include "util/u_prim.h"

View file

@ -0,0 +1,101 @@
/*
* Copyright 2016 Advanced Micro Devices, Inc.
*
* SPDX-License-Identifier: MIT
*/
#ifndef SI_SHADER_LLVM_H
#define SI_SHADER_LLVM_H
#include "ac_shader_abi.h"
#include "ac_llvm_build.h"
#include "si_shader.h"
struct si_shader_args;
struct si_shader_context {
struct ac_llvm_context ac;
struct si_shader *shader;
struct si_screen *screen;
gl_shader_stage stage;
/* For clamping the non-constant index in resource indexing: */
unsigned num_const_buffers;
unsigned num_shader_buffers;
unsigned num_images;
unsigned num_samplers;
struct si_shader_args *args;
struct ac_shader_abi abi;
LLVMBasicBlockRef merged_wrap_if_entry_block;
int merged_wrap_if_label;
struct ac_llvm_pointer main_fn;
LLVMTypeRef return_type;
struct ac_llvm_compiler *compiler;
/* Preloaded descriptors. */
LLVMValueRef instance_divisor_constbuf;
LLVMValueRef gs_ngg_emit;
struct ac_llvm_pointer gs_ngg_scratch;
LLVMValueRef return_value;
};
static inline struct si_shader_context *si_shader_context_from_abi(struct ac_shader_abi *abi)
{
return container_of(abi, struct si_shader_context, abi);
}
/* si_shader_llvm.c */
bool si_compile_llvm(struct si_screen *sscreen, struct si_shader_binary *binary,
struct ac_shader_config *conf, struct ac_llvm_compiler *compiler,
struct ac_llvm_context *ac, struct util_debug_callback *debug,
gl_shader_stage stage, const char *name, bool less_optimized);
void si_llvm_context_init(struct si_shader_context *ctx, struct si_screen *sscreen,
struct ac_llvm_compiler *compiler, unsigned wave_size,
bool exports_color_null, bool exports_mrtz,
enum ac_float_mode float_mode);
void si_llvm_create_func(struct si_shader_context *ctx, const char *name, LLVMTypeRef *return_types,
unsigned num_return_elems, unsigned max_workgroup_size);
void si_llvm_create_main_func(struct si_shader_context *ctx);
void si_llvm_optimize_module(struct si_shader_context *ctx);
void si_llvm_dispose(struct si_shader_context *ctx);
LLVMValueRef si_buffer_load_const(struct si_shader_context *ctx, LLVMValueRef resource,
LLVMValueRef offset);
void si_llvm_build_ret(struct si_shader_context *ctx, LLVMValueRef ret);
LLVMValueRef si_insert_input_ret(struct si_shader_context *ctx, LLVMValueRef ret,
struct ac_arg param, unsigned return_index);
LLVMValueRef si_insert_input_ret_float(struct si_shader_context *ctx, LLVMValueRef ret,
struct ac_arg param, unsigned return_index);
LLVMValueRef si_insert_input_ptr(struct si_shader_context *ctx, LLVMValueRef ret,
struct ac_arg param, unsigned return_index);
LLVMValueRef si_prolog_get_internal_binding_slot(struct si_shader_context *ctx, unsigned slot);
LLVMValueRef si_unpack_param(struct si_shader_context *ctx, struct ac_arg param, unsigned rshift,
unsigned bitwidth);
/* si_shader_llvm_gs.c */
LLVMValueRef si_is_es_thread(struct si_shader_context *ctx);
LLVMValueRef si_is_gs_thread(struct si_shader_context *ctx);
void si_llvm_es_build_end(struct si_shader_context *ctx);
void si_llvm_gs_build_end(struct si_shader_context *ctx);
/* si_shader_llvm_tess.c */
LLVMValueRef si_get_rel_patch_id(struct si_shader_context *ctx);
void si_llvm_ls_build_end(struct si_shader_context *ctx);
void si_llvm_build_tcs_epilog(struct si_shader_context *ctx, union si_shader_part_key *key);
void si_llvm_tcs_build_end(struct si_shader_context *ctx);
void si_llvm_init_tcs_callbacks(struct si_shader_context *ctx);
/* si_shader_llvm_ps.c */
void si_llvm_build_ps_prolog(struct si_shader_context *ctx, union si_shader_part_key *key);
void si_llvm_build_ps_epilog(struct si_shader_context *ctx, union si_shader_part_key *key);
void si_llvm_ps_build_end(struct si_shader_context *ctx);
/* si_shader_llvm_vs.c */
void si_llvm_build_vs_prolog(struct si_shader_context *ctx, union si_shader_part_key *key);
#endif

View file

@ -7,6 +7,7 @@
#include "ac_nir.h"
#include "si_pipe.h"
#include "si_shader_internal.h"
#include "si_shader_llvm.h"
#include "si_query.h"
#include "sid.h"
#include "util/u_memory.h"

View file

@ -6,6 +6,7 @@
#include "si_pipe.h"
#include "si_shader_internal.h"
#include "si_shader_llvm.h"
#include "sid.h"
static LLVMValueRef si_build_fs_interp(struct si_shader_context *ctx, unsigned attr_index,

View file

@ -6,6 +6,7 @@
#include "si_pipe.h"
#include "si_shader_internal.h"
#include "si_shader_llvm.h"
#include "sid.h"
LLVMValueRef si_get_rel_patch_id(struct si_shader_context *ctx)

View file

@ -6,6 +6,7 @@
#include "si_pipe.h"
#include "si_shader_internal.h"
#include "si_shader_llvm.h"
#include "sid.h"
#include "util/u_memory.h"
#include "ac_nir.h"