radeonsi: move data_layout into si_compiler
authorMarek Olšák <marek.olsak@amd.com>
Mon, 9 Apr 2018 23:23:55 +0000 (19:23 -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 eeb7ff81f92d7f96da6f1598713835071412edc7..aa92f889e6e9f913a7b4c6200c7a039a719c0719 100644 (file)
@@ -149,10 +149,19 @@ static void si_init_compiler(struct si_screen *sscreen,
        /* This is recommended by the instruction combining pass. */
        LLVMAddEarlyCSEMemSSAPass(compiler->passmgr);
        LLVMAddInstructionCombiningPass(compiler->passmgr);
+
+       /* Get the data layout. */
+       LLVMTargetDataRef data_layout = LLVMCreateTargetDataLayout(compiler->tm);
+       if (!data_layout)
+               return;
+       compiler->data_layout = LLVMCopyStringRepOfTargetData(data_layout);
+       LLVMDisposeTargetData(data_layout);
 }
 
 static void si_destroy_compiler(struct si_compiler *compiler)
 {
+       if (compiler->data_layout)
+               LLVMDisposeMessage((char*)compiler->data_layout);
        if (compiler->passmgr)
                LLVMDisposePassManager(compiler->passmgr);
        if (compiler->target_library_info)
index a0122d239103ce75047ba9abf38e8360662aca11..94366f4120454af00a92a50cebcf2236aacaf052 100644 (file)
@@ -315,6 +315,7 @@ struct si_shader;
 struct si_compiler {
        LLVMTargetMachineRef            tm;
        const char                      *triple;
+       const char                      *data_layout;
        LLVMTargetLibraryInfoRef        target_library_info;
        LLVMPassManagerRef              passmgr;
 };
index 29b1e50dc47d0206f425e8280edbadb71c5dcd09..a4c2a1f27aba86e44bdcb9947a12267c310f3bcc 100644 (file)
@@ -1005,12 +1005,7 @@ void si_llvm_context_init(struct si_shader_context *ctx,
        ctx->gallivm.module = LLVMModuleCreateWithNameInContext("tgsi",
                                                ctx->gallivm.context);
        LLVMSetTarget(ctx->gallivm.module, compiler->triple);
-
-       LLVMTargetDataRef data_layout = LLVMCreateTargetDataLayout(compiler->tm);
-       char *data_layout_str = LLVMCopyStringRepOfTargetData(data_layout);
-       LLVMSetDataLayout(ctx->gallivm.module, data_layout_str);
-       LLVMDisposeTargetData(data_layout);
-       LLVMDisposeMessage(data_layout_str);
+       LLVMSetDataLayout(ctx->gallivm.module, compiler->data_layout);
 
        bool unsafe_fpmath = (sscreen->debug_flags & DBG(UNSAFE_MATH)) != 0;
        enum ac_float_mode float_mode =