diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/radeonsi/si_pipe.c | 30 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_pipe.h | 7 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_shader.h | 1 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c | 34 |
4 files changed, 32 insertions, 40 deletions
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index 19b570e569e..eeb7ff81f92 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -41,6 +41,12 @@ #include "vl/vl_decoder.h" #include "driver_ddebug/dd_util.h" +#include <llvm-c/Transforms/IPO.h> +#include <llvm-c/Transforms/Scalar.h> +#if HAVE_LLVM >= 0x0700 +#include <llvm-c/Transforms/Utils.h> +#endif + static const struct debug_named_value debug_options[] = { /* Shader logging options: */ { "vs", DBG(VS), "Print vertex shaders" }, @@ -121,10 +127,34 @@ static void si_init_compiler(struct si_screen *sscreen, gallivm_create_target_library_info(compiler->triple); if (!compiler->target_library_info) return; + + compiler->passmgr = LLVMCreatePassManager(); + if (!compiler->passmgr) + return; + + LLVMAddTargetLibraryInfo(compiler->target_library_info, + compiler->passmgr); + + /* Add LLVM passes into the pass manager. */ + if (sscreen->debug_flags & DBG(CHECK_IR)) + LLVMAddVerifierPass(compiler->passmgr); + + LLVMAddAlwaysInlinerPass(compiler->passmgr); + /* This pass should eliminate all the load and store instructions. */ + LLVMAddPromoteMemoryToRegisterPass(compiler->passmgr); + LLVMAddScalarReplAggregatesPass(compiler->passmgr); + LLVMAddLICMPass(compiler->passmgr); + LLVMAddAggressiveDCEPass(compiler->passmgr); + LLVMAddCFGSimplificationPass(compiler->passmgr); + /* This is recommended by the instruction combining pass. */ + LLVMAddEarlyCSEMemSSAPass(compiler->passmgr); + LLVMAddInstructionCombiningPass(compiler->passmgr); } static void si_destroy_compiler(struct si_compiler *compiler) { + if (compiler->passmgr) + LLVMDisposePassManager(compiler->passmgr); if (compiler->target_library_info) gallivm_dispose_target_library_info(compiler->target_library_info); if (compiler->tm) diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index 54c9b725fcb..a67786c84d9 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -1391,13 +1391,6 @@ static inline bool si_can_dump_shader(struct si_screen *sscreen, return sscreen->debug_flags & (1 << processor); } -static inline bool si_extra_shader_checks(struct si_screen *sscreen, - unsigned processor) -{ - return (sscreen->debug_flags & DBG(CHECK_IR)) || - si_can_dump_shader(sscreen, processor); -} - static inline bool si_get_strmout_en(struct si_context *sctx) { return sctx->streamout.streamout_enabled || diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h index 8761bc7e7c9..a0122d23910 100644 --- a/src/gallium/drivers/radeonsi/si_shader.h +++ b/src/gallium/drivers/radeonsi/si_shader.h @@ -316,6 +316,7 @@ struct si_compiler { LLVMTargetMachineRef tm; const char *triple; LLVMTargetLibraryInfoRef target_library_info; + LLVMPassManagerRef passmgr; }; /* 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 86366f4063c..29b1e50dc47 100644 --- a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c +++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c @@ -39,11 +39,6 @@ #include "util/u_debug.h" #include <stdio.h> -#include <llvm-c/Transforms/IPO.h> -#include <llvm-c/Transforms/Scalar.h> -#if HAVE_LLVM >= 0x0700 -#include <llvm-c/Transforms/Utils.h> -#endif enum si_llvm_calling_convention { RADEON_LLVM_AMDGPU_VS = 87, @@ -1212,41 +1207,14 @@ 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; - /* Dump LLVM IR before any optimization passes */ if (ctx->screen->debug_flags & DBG(PREOPT_IR) && si_can_dump_shader(ctx->screen, ctx->type)) LLVMDumpModule(ctx->gallivm.module); - /* Create the pass manager */ - gallivm->passmgr = LLVMCreatePassManager(); - - LLVMAddTargetLibraryInfo(ctx->compiler->target_library_info, - gallivm->passmgr); - - if (si_extra_shader_checks(ctx->screen, ctx->type)) - LLVMAddVerifierPass(gallivm->passmgr); - - LLVMAddAlwaysInlinerPass(gallivm->passmgr); - - /* This pass should eliminate all the load and store instructions */ - LLVMAddPromoteMemoryToRegisterPass(gallivm->passmgr); - - /* Add some optimization passes */ - LLVMAddScalarReplAggregatesPass(gallivm->passmgr); - LLVMAddLICMPass(gallivm->passmgr); - LLVMAddAggressiveDCEPass(gallivm->passmgr); - LLVMAddCFGSimplificationPass(gallivm->passmgr); - /* This is recommended by the instruction combining pass. */ - LLVMAddEarlyCSEMemSSAPass(gallivm->passmgr); - LLVMAddInstructionCombiningPass(gallivm->passmgr); - /* Run the pass */ - LLVMRunPassManager(gallivm->passmgr, ctx->gallivm.module); - + LLVMRunPassManager(ctx->compiler->passmgr, ctx->gallivm.module); LLVMDisposeBuilder(ctx->ac.builder); - LLVMDisposePassManager(gallivm->passmgr); } void si_llvm_dispose(struct si_shader_context *ctx) |