radeonsi: move target_library_info into si_compiler
authorMarek Olšák <marek.olsak@amd.com>
Mon, 9 Apr 2018 22:43:54 +0000 (18:43 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 27 Apr 2018 21:56:04 +0000 (17:56 -0400)
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Tested-by: Benedikt Schemmer <ben at besd.de>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeonsi/si_pipe.c
src/gallium/drivers/radeonsi/si_shader.h
src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c

index dbfb9c8fdea0d8f2f78ff2afa5a07c832a58e6e0..19b570e569e92e555b44b78eb13ddbb346cf2437 100644 (file)
@@ -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);
 }
index e6205a204c1beefc333af5b215e5f089f180c5ea..8761bc7e7c93eb73145a5a298626f715e0e48c08 100644 (file)
@@ -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. */
index f354417b89e28d717516c5738fe10ca9156b12b9..86366f4063c95d374898fd934ff893708470e28a 100644 (file)
@@ -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)