diff options
author | Tom Stellard <[email protected]> | 2018-07-20 19:54:56 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2018-07-23 20:23:48 -0400 |
commit | 0866edede0116e33b4bed28737e4d242ad0da2ad (patch) | |
tree | 8da9f3af24c019124ccb95302b52364082b3ce76 /src/amd | |
parent | 820d5e51b7060f02d6c12fbb1c349111022ff37a (diff) |
radeonsi: Add debug option to enable LLVM GlobalISel (v2)
R600_DEBUG=gisel will tell LLVM to use GlobalISel rather than
SelectionDAG for instruction selection.
v2: mareko: move the helper to src/amd/common
Signed-off-by: Marek Olšák <[email protected]>
Reviewed-by: Tom Stellard <[email protected]>
Diffstat (limited to 'src/amd')
-rw-r--r-- | src/amd/common/ac_llvm_helper.cpp | 7 | ||||
-rw-r--r-- | src/amd/common/ac_llvm_util.c | 11 | ||||
-rw-r--r-- | src/amd/common/ac_llvm_util.h | 2 |
3 files changed, 18 insertions, 2 deletions
diff --git a/src/amd/common/ac_llvm_helper.cpp b/src/amd/common/ac_llvm_helper.cpp index e0943135fad..a4b2fde786a 100644 --- a/src/amd/common/ac_llvm_helper.cpp +++ b/src/amd/common/ac_llvm_helper.cpp @@ -171,3 +171,10 @@ void ac_llvm_add_barrier_noop_pass(LLVMPassManagerRef passmgr) { llvm::unwrap(passmgr)->add(llvm::createBarrierNoopPass()); } + +void ac_enable_global_isel(LLVMTargetMachineRef tm) +{ +#if HAVE_LLVM >= 0x0700 + reinterpret_cast<llvm::TargetMachine*>(tm)->setGlobalISel(true); +#endif +} diff --git a/src/amd/common/ac_llvm_util.c b/src/amd/common/ac_llvm_util.c index 0c8dbf1ec51..678bc34e6f8 100644 --- a/src/amd/common/ac_llvm_util.c +++ b/src/amd/common/ac_llvm_util.c @@ -34,6 +34,7 @@ #include <llvm-c/Transforms/Utils.h> #endif #include "c11/threads.h" +#include "gallivm/lp_bld_misc.h" #include "util/u_math.h" #include <assert.h> @@ -55,9 +56,13 @@ static void ac_init_llvm_target() * https://reviews.llvm.org/D26348 * * "mesa" is the prefix for error messages. + * + * -global-isel-abort=2 is a no-op unless global isel has been enabled. + * This option tells the backend to fall-back to SelectionDAG and print + * a diagnostic message if global isel fails. */ - const char *argv[2] = { "mesa", "-simplifycfg-sink-common=false" }; - LLVMParseCommandLineOptions(2, argv, NULL); + const char *argv[3] = { "mesa", "-simplifycfg-sink-common=false", "-global-isel-abort=2" }; + LLVMParseCommandLineOptions(3, argv, NULL); } static once_flag ac_init_llvm_target_once_flag = ONCE_FLAG_INIT; @@ -164,6 +169,8 @@ static LLVMTargetMachineRef ac_create_target_machine(enum radeon_family family, if (out_triple) *out_triple = triple; + if (tm_options & AC_TM_ENABLE_GLOBAL_ISEL) + ac_enable_global_isel(tm); return tm; } diff --git a/src/amd/common/ac_llvm_util.h b/src/amd/common/ac_llvm_util.h index e5b93037d26..d4dea4dfde6 100644 --- a/src/amd/common/ac_llvm_util.h +++ b/src/amd/common/ac_llvm_util.h @@ -63,6 +63,7 @@ enum ac_target_machine_options { AC_TM_FORCE_DISABLE_XNACK = (1 << 3), AC_TM_PROMOTE_ALLOCA_TO_SCRATCH = (1 << 4), AC_TM_CHECK_IR = (1 << 5), + AC_TM_ENABLE_GLOBAL_ISEL = (1 << 6), }; enum ac_float_mode { @@ -134,6 +135,7 @@ void ac_destroy_llvm_passes(struct ac_compiler_passes *p); bool ac_compile_module_to_binary(struct ac_compiler_passes *p, LLVMModuleRef module, struct ac_shader_binary *binary); void ac_llvm_add_barrier_noop_pass(LLVMPassManagerRef passmgr); +void ac_enable_global_isel(LLVMTargetMachineRef tm); #ifdef __cplusplus } |