diff options
author | Dave Airlie <[email protected]> | 2018-06-27 08:52:20 +1000 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2018-07-04 05:18:01 +1000 |
commit | 584ad1eda956f89338648fcd22e950ab9c32f465 (patch) | |
tree | 4d00a1f93e8bba73693a081ad1202108c879f0d5 /src/amd | |
parent | f2b3e96e754a5d722f2b0fa1bd5efa1c0640ed3b (diff) |
ac/radeonsi: refactor out pass manager init to common code.
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/amd')
-rw-r--r-- | src/amd/common/ac_llvm_util.c | 30 | ||||
-rw-r--r-- | src/amd/common/ac_llvm_util.h | 2 |
2 files changed, 32 insertions, 0 deletions
diff --git a/src/amd/common/ac_llvm_util.c b/src/amd/common/ac_llvm_util.c index 25ff4a8c22a..b25f9e3e6dd 100644 --- a/src/amd/common/ac_llvm_util.c +++ b/src/amd/common/ac_llvm_util.c @@ -28,6 +28,11 @@ #include "util/bitscan.h" #include <llvm-c/Core.h> #include <llvm-c/Support.h> +#include <llvm-c/Transforms/IPO.h> +#include <llvm-c/Transforms/Scalar.h> +#if HAVE_LLVM >= 0x0700 +#include <llvm-c/Transforms/Utils.h> +#endif #include "c11/threads.h" #include "util/u_math.h" @@ -160,6 +165,31 @@ LLVMTargetMachineRef ac_create_target_machine(enum radeon_family family, return tm; } +LLVMPassManagerRef ac_create_passmgr(LLVMTargetLibraryInfoRef target_library_info, + bool check_ir) +{ + LLVMPassManagerRef passmgr = LLVMCreatePassManager(); + if (!passmgr) + return NULL; + + LLVMAddTargetLibraryInfo(target_library_info, + passmgr); + + if (check_ir) + LLVMAddVerifierPass(passmgr); + LLVMAddAlwaysInlinerPass(passmgr); + /* This pass should eliminate all the load and store instructions. */ + LLVMAddPromoteMemoryToRegisterPass(passmgr); + LLVMAddScalarReplAggregatesPass(passmgr); + LLVMAddLICMPass(passmgr); + LLVMAddAggressiveDCEPass(passmgr); + LLVMAddCFGSimplificationPass(passmgr); + /* This is recommended by the instruction combining pass. */ + LLVMAddEarlyCSEMemSSAPass(passmgr); + LLVMAddInstructionCombiningPass(passmgr); + return passmgr; +} + static const char *attr_to_str(enum ac_func_attr attr) { switch (attr) { diff --git a/src/amd/common/ac_llvm_util.h b/src/amd/common/ac_llvm_util.h index 4311c5ea8a4..8d4f7d83150 100644 --- a/src/amd/common/ac_llvm_util.h +++ b/src/amd/common/ac_llvm_util.h @@ -111,6 +111,8 @@ ac_get_store_intr_attribs(bool writeonly_memory) unsigned ac_count_scratch_private_memory(LLVMValueRef function); +LLVMPassManagerRef ac_create_passmgr(LLVMTargetLibraryInfoRef target_library_info, + bool check_ir); void ac_init_llvm_once(void); #ifdef __cplusplus |