summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Colombet <qcolombet@apple.com>2016-04-07 20:27:33 +0000
committerQuentin Colombet <qcolombet@apple.com>2016-04-07 20:27:33 +0000
commitd4131814b3117c00c3eb2b0dc30b6a03297421f4 (patch)
tree34955f69c97708cd232d411112cafaecea77450f
parenteb37fcbc875d6aea445b187ec8871b842fb06a4a (diff)
downloadbcm5719-llvm-d4131814b3117c00c3eb2b0dc30b6a03297421f4.tar.gz
bcm5719-llvm-d4131814b3117c00c3eb2b0dc30b6a03297421f4.zip
[GlobalISel] Add RegBankSelect hooks into the pass pipeline.
Now, RegBankSelect will happen after the IRTranslation and the target may optionally add additional passes in between. llvm-svn: 265716
-rw-r--r--llvm/include/llvm/CodeGen/Passes.h9
-rw-r--r--llvm/lib/CodeGen/LLVMTargetMachine.cpp8
-rw-r--r--llvm/lib/Target/AArch64/AArch64TargetMachine.cpp6
3 files changed, 23 insertions, 0 deletions
diff --git a/llvm/include/llvm/CodeGen/Passes.h b/llvm/include/llvm/CodeGen/Passes.h
index 61b3ea8ec27..8275b0fb60a 100644
--- a/llvm/include/llvm/CodeGen/Passes.h
+++ b/llvm/include/llvm/CodeGen/Passes.h
@@ -220,6 +220,15 @@ public:
/// LLVM code to machine instructions with possibly generic opcodes.
virtual bool addIRTranslator() { return true; }
+ /// This method may be implemented by targets that want to run passes
+ /// immediately before the register bank selection.
+ virtual void addPreRegBankSelect() {}
+
+ /// This method should install a register bank selector pass, which
+ /// assigns register banks to virtual registers without a register
+ /// class or register banks.
+ virtual bool addRegBankSelect() { return true; }
+
/// Add the complete, standard set of LLVM CodeGen passes.
/// Fully developed targets will not generally override this.
virtual void addMachinePasses();
diff --git a/llvm/lib/CodeGen/LLVMTargetMachine.cpp b/llvm/lib/CodeGen/LLVMTargetMachine.cpp
index 9c6236ec02b..a19049360c0 100644
--- a/llvm/lib/CodeGen/LLVMTargetMachine.cpp
+++ b/llvm/lib/CodeGen/LLVMTargetMachine.cpp
@@ -143,6 +143,14 @@ addPassesToGenerateCode(LLVMTargetMachine *TM, PassManagerBase &PM,
if (LLVM_UNLIKELY(EnableGlobalISel)) {
if (PassConfig->addIRTranslator())
return nullptr;
+
+ // Before running the register bank selector, ask the target if it
+ // wants to run some passes.
+ PassConfig->addPreRegBankSelect();
+
+ if (PassConfig->addRegBankSelect())
+ return nullptr;
+
} else if (PassConfig->addInstSelector())
return nullptr;
diff --git a/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp b/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
index 9712d0ee88e..d4de69febb5 100644
--- a/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
+++ b/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
@@ -19,6 +19,7 @@
#ifdef LLVM_BUILD_GLOBAL_ISEL
# include "llvm/CodeGen/GlobalISel/IRTranslator.h"
#endif
+#include "llvm/CodeGen/GlobalISel/RegBankSelect.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/RegAllocRegistry.h"
#include "llvm/IR/Function.h"
@@ -241,6 +242,7 @@ public:
bool addInstSelector() override;
#ifdef LLVM_BUILD_GLOBAL_ISEL
bool addIRTranslator() override;
+ bool addRegBankSelect() override;
#endif
bool addILPOpts() override;
void addPreRegAlloc() override;
@@ -339,6 +341,10 @@ bool AArch64PassConfig::addIRTranslator() {
addPass(new IRTranslator());
return false;
}
+bool AArch64PassConfig::addRegBankSelect() {
+ addPass(new RegBankSelect());
+ return false;
+}
#endif
bool AArch64PassConfig::addILPOpts() {
OpenPOWER on IntegriCloud