radeonsi: move passmgr into si_compiler

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Tested-by: Benedikt Schemmer <ben at besd.de>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
This commit is contained in:
Marek Olšák
2018-04-09 19:13:37 -04:00
parent c1823ff661
commit 797d673c9a
4 changed files with 32 additions and 40 deletions
+30
View File
@@ -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)
-7
View File
@@ -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 ||
+1
View File
@@ -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. */
@@ -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)