radv: create/destroy passmgr at the higher level.
This is prep work for moving this to a per-thread struct Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
@@ -2993,15 +2993,11 @@ handle_shader_outputs_post(struct ac_shader_abi *abi, unsigned max_outputs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void ac_llvm_finalize_module(struct radv_shader_context *ctx,
|
static void ac_llvm_finalize_module(struct radv_shader_context *ctx,
|
||||||
|
LLVMPassManagerRef passmgr,
|
||||||
const struct radv_nir_compiler_options *options)
|
const struct radv_nir_compiler_options *options)
|
||||||
{
|
{
|
||||||
LLVMPassManagerRef passmgr;
|
|
||||||
|
|
||||||
passmgr = ac_create_passmgr(NULL, options->check_ir);
|
|
||||||
|
|
||||||
LLVMRunPassManager(passmgr, ctx->ac.module);
|
LLVMRunPassManager(passmgr, ctx->ac.module);
|
||||||
LLVMDisposeBuilder(ctx->ac.builder);
|
LLVMDisposeBuilder(ctx->ac.builder);
|
||||||
LLVMDisposePassManager(passmgr);
|
|
||||||
|
|
||||||
ac_llvm_context_dispose(&ctx->ac);
|
ac_llvm_context_dispose(&ctx->ac);
|
||||||
}
|
}
|
||||||
@@ -3132,6 +3128,7 @@ static void prepare_gs_input_vgprs(struct radv_shader_context *ctx)
|
|||||||
|
|
||||||
static
|
static
|
||||||
LLVMModuleRef ac_translate_nir_to_llvm(LLVMTargetMachineRef tm,
|
LLVMModuleRef ac_translate_nir_to_llvm(LLVMTargetMachineRef tm,
|
||||||
|
LLVMPassManagerRef passmgr,
|
||||||
struct nir_shader *const *shaders,
|
struct nir_shader *const *shaders,
|
||||||
int shader_count,
|
int shader_count,
|
||||||
struct radv_shader_variant_info *shader_info,
|
struct radv_shader_variant_info *shader_info,
|
||||||
@@ -3300,7 +3297,7 @@ LLVMModuleRef ac_translate_nir_to_llvm(LLVMTargetMachineRef tm,
|
|||||||
if (options->dump_preoptir)
|
if (options->dump_preoptir)
|
||||||
ac_dump_module(ctx.ac.module);
|
ac_dump_module(ctx.ac.module);
|
||||||
|
|
||||||
ac_llvm_finalize_module(&ctx, options);
|
ac_llvm_finalize_module(&ctx, passmgr, options);
|
||||||
|
|
||||||
if (shader_count == 1)
|
if (shader_count == 1)
|
||||||
ac_nir_eliminate_const_vs_outputs(&ctx);
|
ac_nir_eliminate_const_vs_outputs(&ctx);
|
||||||
@@ -3501,6 +3498,7 @@ ac_fill_shader_info(struct radv_shader_variant_info *shader_info, struct nir_sha
|
|||||||
|
|
||||||
void
|
void
|
||||||
radv_compile_nir_shader(LLVMTargetMachineRef tm,
|
radv_compile_nir_shader(LLVMTargetMachineRef tm,
|
||||||
|
LLVMPassManagerRef passmgr,
|
||||||
struct ac_shader_binary *binary,
|
struct ac_shader_binary *binary,
|
||||||
struct ac_shader_config *config,
|
struct ac_shader_config *config,
|
||||||
struct radv_shader_variant_info *shader_info,
|
struct radv_shader_variant_info *shader_info,
|
||||||
@@ -3511,7 +3509,7 @@ radv_compile_nir_shader(LLVMTargetMachineRef tm,
|
|||||||
|
|
||||||
LLVMModuleRef llvm_module;
|
LLVMModuleRef llvm_module;
|
||||||
|
|
||||||
llvm_module = ac_translate_nir_to_llvm(tm, nir, nir_count, shader_info,
|
llvm_module = ac_translate_nir_to_llvm(tm, passmgr, nir, nir_count, shader_info,
|
||||||
options);
|
options);
|
||||||
|
|
||||||
ac_compile_llvm_module(tm, llvm_module, binary, config, shader_info,
|
ac_compile_llvm_module(tm, llvm_module, binary, config, shader_info,
|
||||||
@@ -3573,6 +3571,7 @@ ac_gs_copy_shader_emit(struct radv_shader_context *ctx)
|
|||||||
|
|
||||||
void
|
void
|
||||||
radv_compile_gs_copy_shader(LLVMTargetMachineRef tm,
|
radv_compile_gs_copy_shader(LLVMTargetMachineRef tm,
|
||||||
|
LLVMPassManagerRef passmgr,
|
||||||
struct nir_shader *geom_shader,
|
struct nir_shader *geom_shader,
|
||||||
struct ac_shader_binary *binary,
|
struct ac_shader_binary *binary,
|
||||||
struct ac_shader_config *config,
|
struct ac_shader_config *config,
|
||||||
@@ -3617,7 +3616,7 @@ radv_compile_gs_copy_shader(LLVMTargetMachineRef tm,
|
|||||||
|
|
||||||
LLVMBuildRetVoid(ctx.ac.builder);
|
LLVMBuildRetVoid(ctx.ac.builder);
|
||||||
|
|
||||||
ac_llvm_finalize_module(&ctx, options);
|
ac_llvm_finalize_module(&ctx, passmgr, options);
|
||||||
|
|
||||||
ac_compile_llvm_module(tm, ctx.ac.module, binary, config, shader_info,
|
ac_compile_llvm_module(tm, ctx.ac.module, binary, config, shader_info,
|
||||||
MESA_SHADER_VERTEX, options);
|
MESA_SHADER_VERTEX, options);
|
||||||
|
@@ -1796,6 +1796,7 @@ struct radv_shader_variant_info;
|
|||||||
struct radv_nir_compiler_options;
|
struct radv_nir_compiler_options;
|
||||||
|
|
||||||
void radv_compile_gs_copy_shader(LLVMTargetMachineRef tm,
|
void radv_compile_gs_copy_shader(LLVMTargetMachineRef tm,
|
||||||
|
LLVMPassManagerRef passmgr,
|
||||||
struct nir_shader *geom_shader,
|
struct nir_shader *geom_shader,
|
||||||
struct ac_shader_binary *binary,
|
struct ac_shader_binary *binary,
|
||||||
struct ac_shader_config *config,
|
struct ac_shader_config *config,
|
||||||
@@ -1803,6 +1804,7 @@ void radv_compile_gs_copy_shader(LLVMTargetMachineRef tm,
|
|||||||
const struct radv_nir_compiler_options *option);
|
const struct radv_nir_compiler_options *option);
|
||||||
|
|
||||||
void radv_compile_nir_shader(LLVMTargetMachineRef tm,
|
void radv_compile_nir_shader(LLVMTargetMachineRef tm,
|
||||||
|
LLVMPassManagerRef passmgr,
|
||||||
struct ac_shader_binary *binary,
|
struct ac_shader_binary *binary,
|
||||||
struct ac_shader_config *config,
|
struct ac_shader_config *config,
|
||||||
struct radv_shader_variant_info *shader_info,
|
struct radv_shader_variant_info *shader_info,
|
||||||
|
@@ -542,6 +542,7 @@ shader_variant_create(struct radv_device *device,
|
|||||||
struct radv_shader_variant *variant;
|
struct radv_shader_variant *variant;
|
||||||
struct ac_shader_binary binary;
|
struct ac_shader_binary binary;
|
||||||
LLVMTargetMachineRef tm;
|
LLVMTargetMachineRef tm;
|
||||||
|
LLVMPassManagerRef passmgr;
|
||||||
|
|
||||||
variant = calloc(1, sizeof(struct radv_shader_variant));
|
variant = calloc(1, sizeof(struct radv_shader_variant));
|
||||||
if (!variant)
|
if (!variant)
|
||||||
@@ -564,17 +565,19 @@ shader_variant_create(struct radv_device *device,
|
|||||||
|
|
||||||
radv_init_llvm_once();
|
radv_init_llvm_once();
|
||||||
tm = ac_create_target_machine(chip_family, tm_options, NULL);
|
tm = ac_create_target_machine(chip_family, tm_options, NULL);
|
||||||
|
passmgr = ac_create_passmgr(NULL, options->check_ir);
|
||||||
if (gs_copy_shader) {
|
if (gs_copy_shader) {
|
||||||
assert(shader_count == 1);
|
assert(shader_count == 1);
|
||||||
radv_compile_gs_copy_shader(tm, *shaders, &binary,
|
radv_compile_gs_copy_shader(tm, passmgr, *shaders, &binary,
|
||||||
&variant->config, &variant->info,
|
&variant->config, &variant->info,
|
||||||
options);
|
options);
|
||||||
} else {
|
} else {
|
||||||
radv_compile_nir_shader(tm, &binary, &variant->config,
|
radv_compile_nir_shader(tm, passmgr, &binary, &variant->config,
|
||||||
&variant->info, shaders, shader_count,
|
&variant->info, shaders, shader_count,
|
||||||
options);
|
options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LLVMDisposePassManager(passmgr);
|
||||||
LLVMDisposeTargetMachine(tm);
|
LLVMDisposeTargetMachine(tm);
|
||||||
|
|
||||||
radv_fill_shader_variant(device, variant, &binary, stage);
|
radv_fill_shader_variant(device, variant, &binary, stage);
|
||||||
|
Reference in New Issue
Block a user