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 <marek.olsak@amd.com> Reviewed-by: Tom Stellard <tstellar@redhat.com>
This commit is contained in:

committed by
Marek Olšák

parent
820d5e51b7
commit
0866edede0
@@ -171,3 +171,10 @@ void ac_llvm_add_barrier_noop_pass(LLVMPassManagerRef passmgr)
|
|||||||
{
|
{
|
||||||
llvm::unwrap(passmgr)->add(llvm::createBarrierNoopPass());
|
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
|
||||||
|
}
|
||||||
|
@@ -34,6 +34,7 @@
|
|||||||
#include <llvm-c/Transforms/Utils.h>
|
#include <llvm-c/Transforms/Utils.h>
|
||||||
#endif
|
#endif
|
||||||
#include "c11/threads.h"
|
#include "c11/threads.h"
|
||||||
|
#include "gallivm/lp_bld_misc.h"
|
||||||
#include "util/u_math.h"
|
#include "util/u_math.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@@ -55,9 +56,13 @@ static void ac_init_llvm_target()
|
|||||||
* https://reviews.llvm.org/D26348
|
* https://reviews.llvm.org/D26348
|
||||||
*
|
*
|
||||||
* "mesa" is the prefix for error messages.
|
* "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" };
|
const char *argv[3] = { "mesa", "-simplifycfg-sink-common=false", "-global-isel-abort=2" };
|
||||||
LLVMParseCommandLineOptions(2, argv, NULL);
|
LLVMParseCommandLineOptions(3, argv, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static once_flag ac_init_llvm_target_once_flag = ONCE_FLAG_INIT;
|
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)
|
if (out_triple)
|
||||||
*out_triple = triple;
|
*out_triple = triple;
|
||||||
|
if (tm_options & AC_TM_ENABLE_GLOBAL_ISEL)
|
||||||
|
ac_enable_global_isel(tm);
|
||||||
return tm;
|
return tm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -63,6 +63,7 @@ enum ac_target_machine_options {
|
|||||||
AC_TM_FORCE_DISABLE_XNACK = (1 << 3),
|
AC_TM_FORCE_DISABLE_XNACK = (1 << 3),
|
||||||
AC_TM_PROMOTE_ALLOCA_TO_SCRATCH = (1 << 4),
|
AC_TM_PROMOTE_ALLOCA_TO_SCRATCH = (1 << 4),
|
||||||
AC_TM_CHECK_IR = (1 << 5),
|
AC_TM_CHECK_IR = (1 << 5),
|
||||||
|
AC_TM_ENABLE_GLOBAL_ISEL = (1 << 6),
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ac_float_mode {
|
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,
|
bool ac_compile_module_to_binary(struct ac_compiler_passes *p, LLVMModuleRef module,
|
||||||
struct ac_shader_binary *binary);
|
struct ac_shader_binary *binary);
|
||||||
void ac_llvm_add_barrier_noop_pass(LLVMPassManagerRef passmgr);
|
void ac_llvm_add_barrier_noop_pass(LLVMPassManagerRef passmgr);
|
||||||
|
void ac_enable_global_isel(LLVMTargetMachineRef tm);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@@ -57,6 +57,7 @@ static const struct debug_named_value debug_options[] = {
|
|||||||
/* Shader compiler options the shader cache should be aware of: */
|
/* Shader compiler options the shader cache should be aware of: */
|
||||||
{ "unsafemath", DBG(UNSAFE_MATH), "Enable unsafe math shader optimizations" },
|
{ "unsafemath", DBG(UNSAFE_MATH), "Enable unsafe math shader optimizations" },
|
||||||
{ "sisched", DBG(SI_SCHED), "Enable LLVM SI Machine Instruction Scheduler." },
|
{ "sisched", DBG(SI_SCHED), "Enable LLVM SI Machine Instruction Scheduler." },
|
||||||
|
{ "gisel", DBG(GISEL), "Enable LLVM global instruction selector." },
|
||||||
|
|
||||||
/* Shader compiler options (with no effect on the shader cache): */
|
/* Shader compiler options (with no effect on the shader cache): */
|
||||||
{ "checkir", DBG(CHECK_IR), "Enable additional sanity checks on shader IR" },
|
{ "checkir", DBG(CHECK_IR), "Enable additional sanity checks on shader IR" },
|
||||||
@@ -109,6 +110,7 @@ static void si_init_compiler(struct si_screen *sscreen,
|
|||||||
{
|
{
|
||||||
enum ac_target_machine_options tm_options =
|
enum ac_target_machine_options tm_options =
|
||||||
(sscreen->debug_flags & DBG(SI_SCHED) ? AC_TM_SISCHED : 0) |
|
(sscreen->debug_flags & DBG(SI_SCHED) ? AC_TM_SISCHED : 0) |
|
||||||
|
(sscreen->debug_flags & DBG(GISEL) ? AC_TM_ENABLE_GLOBAL_ISEL : 0) |
|
||||||
(sscreen->info.chip_class >= GFX9 ? AC_TM_FORCE_ENABLE_XNACK : 0) |
|
(sscreen->info.chip_class >= GFX9 ? AC_TM_FORCE_ENABLE_XNACK : 0) |
|
||||||
(sscreen->info.chip_class < GFX9 ? AC_TM_FORCE_DISABLE_XNACK : 0) |
|
(sscreen->info.chip_class < GFX9 ? AC_TM_FORCE_DISABLE_XNACK : 0) |
|
||||||
(!sscreen->llvm_has_working_vgpr_indexing ? AC_TM_PROMOTE_ALLOCA_TO_SCRATCH : 0) |
|
(!sscreen->llvm_has_working_vgpr_indexing ? AC_TM_PROMOTE_ALLOCA_TO_SCRATCH : 0) |
|
||||||
@@ -756,6 +758,7 @@ static void si_disk_cache_create(struct si_screen *sscreen)
|
|||||||
/* These flags affect shader compilation. */
|
/* These flags affect shader compilation. */
|
||||||
#define ALL_FLAGS (DBG(FS_CORRECT_DERIVS_AFTER_KILL) | \
|
#define ALL_FLAGS (DBG(FS_CORRECT_DERIVS_AFTER_KILL) | \
|
||||||
DBG(SI_SCHED) | \
|
DBG(SI_SCHED) | \
|
||||||
|
DBG(GISEL) | \
|
||||||
DBG(UNSAFE_MATH) | \
|
DBG(UNSAFE_MATH) | \
|
||||||
DBG(NIR))
|
DBG(NIR))
|
||||||
uint64_t shader_debug_flags = sscreen->debug_flags &
|
uint64_t shader_debug_flags = sscreen->debug_flags &
|
||||||
|
@@ -121,6 +121,7 @@ enum {
|
|||||||
DBG_FS_CORRECT_DERIVS_AFTER_KILL,
|
DBG_FS_CORRECT_DERIVS_AFTER_KILL,
|
||||||
DBG_UNSAFE_MATH,
|
DBG_UNSAFE_MATH,
|
||||||
DBG_SI_SCHED,
|
DBG_SI_SCHED,
|
||||||
|
DBG_GISEL,
|
||||||
|
|
||||||
/* Shader compiler options (with no effect on the shader cache): */
|
/* Shader compiler options (with no effect on the shader cache): */
|
||||||
DBG_CHECK_IR,
|
DBG_CHECK_IR,
|
||||||
|
Reference in New Issue
Block a user