mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-25 23:45:36 +00:00
[GlobalISel] Add a way for targets to enable GISel.
Until now, we've had to use -global-isel to enable GISel. But using that on other targets that don't support it will result in an abort, as we can't build a full pipeline. Additionally, we want to experiment with enabling GISel by default for some targets: we can't just enable GISel by default, even among those target that do have some support, because the level of support varies. This first step adds an override for the target to explicitly define its level of support. For AArch64, do that using a new command-line option (I know..): -aarch64-enable-global-isel-at-O=<N> Where N is the opt-level below which GISel should be used. Default that to -1, so that we still don't enable GISel anywhere. We're not there yet! While there, remove a couple LLVM_UNLIKELYs. Building the pipeline is such a cold path that in practice that shouldn't matter at all. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296710 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2880f2df26
commit
b424c9db34
@ -286,6 +286,10 @@ public:
|
||||
/// verification is enabled.
|
||||
void addVerifyPass(const std::string &Banner);
|
||||
|
||||
/// Check whether or not GlobalISel should be enabled by default.
|
||||
/// Fallback/abort behavior is controlled via other methods.
|
||||
virtual bool isGlobalISelEnabled() const;
|
||||
|
||||
/// Check whether or not GlobalISel should abort on error.
|
||||
/// When this is disable, GlobalISel will fall back on SDISel instead of
|
||||
/// erroring out.
|
||||
|
@ -42,8 +42,8 @@ static cl::opt<cl::boolOrDefault>
|
||||
EnableFastISelOption("fast-isel", cl::Hidden,
|
||||
cl::desc("Enable the \"fast\" instruction selector"));
|
||||
|
||||
static cl::opt<bool>
|
||||
EnableGlobalISel("global-isel", cl::Hidden, cl::init(false),
|
||||
static cl::opt<cl::boolOrDefault>
|
||||
EnableGlobalISel("global-isel", cl::Hidden,
|
||||
cl::desc("Enable the \"global\" instruction selector"));
|
||||
|
||||
void LLVMTargetMachine::initAsmInfo() {
|
||||
@ -149,7 +149,9 @@ addPassesToGenerateCode(LLVMTargetMachine *TM, PassManagerBase &PM,
|
||||
TM->setFastISel(true);
|
||||
|
||||
// Ask the target for an isel.
|
||||
if (LLVM_UNLIKELY(EnableGlobalISel)) {
|
||||
// Enable GlobalISel if the target wants to, but allow that to be overriden.
|
||||
if (EnableGlobalISel == cl::BOU_TRUE || (EnableGlobalISel == cl::BOU_UNSET &&
|
||||
PassConfig->isGlobalISelEnabled())) {
|
||||
if (PassConfig->addIRTranslator())
|
||||
return nullptr;
|
||||
|
||||
@ -177,7 +179,7 @@ addPassesToGenerateCode(LLVMTargetMachine *TM, PassManagerBase &PM,
|
||||
|
||||
// Provide a fallback path when we do not want to abort on
|
||||
// not-yet-supported input.
|
||||
if (LLVM_UNLIKELY(!PassConfig->isGlobalISelAbortEnabled()) &&
|
||||
if (!PassConfig->isGlobalISelAbortEnabled() &&
|
||||
PassConfig->addInstSelector())
|
||||
return nullptr;
|
||||
|
||||
|
@ -910,6 +910,11 @@ void TargetPassConfig::addBlockPlacement() {
|
||||
//===---------------------------------------------------------------------===//
|
||||
/// GlobalISel Configuration
|
||||
//===---------------------------------------------------------------------===//
|
||||
|
||||
bool TargetPassConfig::isGlobalISelEnabled() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TargetPassConfig::isGlobalISelAbortEnabled() const {
|
||||
return EnableGlobalISelAbort == 1;
|
||||
}
|
||||
|
@ -139,6 +139,11 @@ static cl::opt<bool>
|
||||
cl::desc("Enable the loop data prefetch pass"),
|
||||
cl::init(true));
|
||||
|
||||
static cl::opt<int> EnableGlobalISelAtO(
|
||||
"aarch64-enable-global-isel-at-O", cl::Hidden,
|
||||
cl::desc("Enable GlobalISel at or below an opt level (-1 to disable)"),
|
||||
cl::init(-1));
|
||||
|
||||
extern "C" void LLVMInitializeAArch64Target() {
|
||||
// Register the target.
|
||||
RegisterTargetMachine<AArch64leTargetMachine> X(getTheAArch64leTarget());
|
||||
@ -358,6 +363,8 @@ public:
|
||||
void addPostRegAlloc() override;
|
||||
void addPreSched2() override;
|
||||
void addPreEmitPass() override;
|
||||
|
||||
bool isGlobalISelEnabled() const override;
|
||||
};
|
||||
|
||||
} // end anonymous namespace
|
||||
@ -467,6 +474,10 @@ bool AArch64PassConfig::addGlobalInstructionSelect() {
|
||||
}
|
||||
#endif
|
||||
|
||||
bool AArch64PassConfig::isGlobalISelEnabled() const {
|
||||
return TM->getOptLevel() <= EnableGlobalISelAtO;
|
||||
}
|
||||
|
||||
bool AArch64PassConfig::addILPOpts() {
|
||||
if (EnableCondOpt)
|
||||
addPass(createAArch64ConditionOptimizerPass());
|
||||
|
48
test/CodeGen/AArch64/GlobalISel/gisel-commandline-option.ll
Normal file
48
test/CodeGen/AArch64/GlobalISel/gisel-commandline-option.ll
Normal file
@ -0,0 +1,48 @@
|
||||
; RUN: llc -mtriple=aarch64-- -debug-pass=Structure %s -o /dev/null 2>&1 \
|
||||
; RUN: -O0 -aarch64-enable-global-isel-at-O=0 \
|
||||
; RUN: | FileCheck %s --check-prefix ENABLED --check-prefix NOFALLBACK
|
||||
|
||||
; RUN: llc -mtriple=aarch64-- -debug-pass=Structure %s -o /dev/null 2>&1 \
|
||||
; RUN: -O0 -aarch64-enable-global-isel-at-O=0 -global-isel-abort=2 \
|
||||
; RUN: | FileCheck %s --check-prefix ENABLED --check-prefix FALLBACK
|
||||
|
||||
; RUN: llc -mtriple=aarch64-- -debug-pass=Structure %s -o /dev/null 2>&1 \
|
||||
; RUN: -global-isel \
|
||||
; RUN: | FileCheck %s --check-prefix ENABLED --check-prefix NOFALLBACK
|
||||
|
||||
; RUN: llc -mtriple=aarch64-- -debug-pass=Structure %s -o /dev/null 2>&1 \
|
||||
; RUN: -global-isel -global-isel-abort=2 \
|
||||
; RUN: | FileCheck %s --check-prefix ENABLED --check-prefix FALLBACK
|
||||
|
||||
; RUN: llc -mtriple=aarch64-- -debug-pass=Structure %s -o /dev/null 2>&1 \
|
||||
; RUN: -O1 -aarch64-enable-global-isel-at-O=3 \
|
||||
; RUN: | FileCheck %s --check-prefix ENABLED
|
||||
|
||||
; RUN: llc -mtriple=aarch64-- -debug-pass=Structure %s -o /dev/null 2>&1 \
|
||||
; RUN: -O1 -aarch64-enable-global-isel-at-O=0 \
|
||||
; RUN: | FileCheck %s --check-prefix DISABLED
|
||||
|
||||
; RUN: llc -mtriple=aarch64-- -debug-pass=Structure %s -o /dev/null 2>&1 \
|
||||
; RUN: -aarch64-enable-global-isel-at-O=-1 \
|
||||
; RUN: | FileCheck %s --check-prefix DISABLED
|
||||
|
||||
; RUN: llc -mtriple=aarch64-- -debug-pass=Structure %s -o /dev/null 2>&1 \
|
||||
; RUN: | FileCheck %s --check-prefix DISABLED
|
||||
|
||||
; ENABLED: IRTranslator
|
||||
; ENABLED-NEXT: Legalizer
|
||||
; ENABLED-NEXT: RegBankSelect
|
||||
; ENABLED-NEXT: InstructionSelect
|
||||
; ENABLED-NEXT: ResetMachineFunction
|
||||
|
||||
; FALLBACK: AArch64 Instruction Selection
|
||||
; NOFALLBACK-NOT: AArch64 Instruction Selection
|
||||
|
||||
; DISABLED-NOT: IRTranslator
|
||||
|
||||
; DISABLED: AArch64 Instruction Selection
|
||||
; DISABLED: Expand ISel Pseudo-instructions
|
||||
|
||||
define void @empty() {
|
||||
ret void
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user