From: Marek Olšák Date: Mon, 9 Apr 2018 22:43:54 +0000 (-0400) Subject: radeonsi: move target_library_info into si_compiler X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c1823ff661b016defe93baa0038e5fd6ca8522c4;p=mesa.git radeonsi: move target_library_info into si_compiler Reviewed-by: Timothy Arceri Tested-by: Benedikt Schemmer Reviewed-by: Nicolai Hähnle --- diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index dbfb9c8fdea..19b570e569e 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -29,6 +29,7 @@ #include "sid.h" #include "radeon/radeon_uvd.h" +#include "gallivm/lp_bld_misc.h" #include "util/disk_cache.h" #include "util/hash_table.h" #include "util/u_log.h" @@ -113,10 +114,19 @@ static void si_init_compiler(struct si_screen *sscreen, compiler->tm = ac_create_target_machine(sscreen->info.family, tm_options, &compiler->triple); + if (!compiler->tm) + return; + + compiler->target_library_info = + gallivm_create_target_library_info(compiler->triple); + if (!compiler->target_library_info) + return; } static void si_destroy_compiler(struct si_compiler *compiler) { + if (compiler->target_library_info) + gallivm_dispose_target_library_info(compiler->target_library_info); if (compiler->tm) LLVMDisposeTargetMachine(compiler->tm); } diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h index e6205a204c1..8761bc7e7c9 100644 --- a/src/gallium/drivers/radeonsi/si_shader.h +++ b/src/gallium/drivers/radeonsi/si_shader.h @@ -315,6 +315,7 @@ struct si_shader; struct si_compiler { LLVMTargetMachineRef tm; const char *triple; + LLVMTargetLibraryInfoRef target_library_info; }; /* State of the context creating the shader object. */ diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c index f354417b89e..86366f4063c 100644 --- a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c +++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c @@ -1213,7 +1213,6 @@ void si_llvm_create_func(struct si_shader_context *ctx, void si_llvm_optimize_module(struct si_shader_context *ctx) { struct gallivm_state *gallivm = &ctx->gallivm; - LLVMTargetLibraryInfoRef target_library_info; /* Dump LLVM IR before any optimization passes */ if (ctx->screen->debug_flags & DBG(PREOPT_IR) && @@ -1223,9 +1222,8 @@ void si_llvm_optimize_module(struct si_shader_context *ctx) /* Create the pass manager */ gallivm->passmgr = LLVMCreatePassManager(); - target_library_info = - gallivm_create_target_library_info(ctx->compiler->triple); - LLVMAddTargetLibraryInfo(target_library_info, gallivm->passmgr); + LLVMAddTargetLibraryInfo(ctx->compiler->target_library_info, + gallivm->passmgr); if (si_extra_shader_checks(ctx->screen, ctx->type)) LLVMAddVerifierPass(gallivm->passmgr); @@ -1249,7 +1247,6 @@ void si_llvm_optimize_module(struct si_shader_context *ctx) LLVMDisposeBuilder(ctx->ac.builder); LLVMDisposePassManager(gallivm->passmgr); - gallivm_dispose_target_library_info(target_library_info); } void si_llvm_dispose(struct si_shader_context *ctx)