summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2012-06-26 17:09:29 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2012-06-26 17:09:29 +0000
commit34f5a2b596236a5452ddc664066138ca7a0c7af2 (patch)
tree65b401edf6787c8434541d44e0bf9c8df7eb7c93
parent0e20eb496ef65988023ab439259010cac82cd1ca (diff)
downloadexternal_llvm-34f5a2b596236a5452ddc664066138ca7a0c7af2.zip
external_llvm-34f5a2b596236a5452ddc664066138ca7a0c7af2.tar.gz
external_llvm-34f5a2b596236a5452ddc664066138ca7a0c7af2.tar.bz2
Allow targets to inject passes before the virtual register rewriter.
Such passes can be used to tweak the register assignments in a target-dependent way, for example to avoid write-after-write dependencies. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159209 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/CodeGen/Passes.h12
-rw-r--r--lib/CodeGen/Passes.cpp6
2 files changed, 17 insertions, 1 deletions
diff --git a/include/llvm/CodeGen/Passes.h b/include/llvm/CodeGen/Passes.h
index cc3b3d7..206bc2e 100644
--- a/include/llvm/CodeGen/Passes.h
+++ b/include/llvm/CodeGen/Passes.h
@@ -175,6 +175,18 @@ protected:
/// LLVMTargetMachine provides standard regalloc passes for most targets.
virtual void addOptimizedRegAlloc(FunctionPass *RegAllocPass);
+ /// addPreRewrite - Add passes to the optimized register allocation pipeline
+ /// after register allocation is complete, but before virtual registers are
+ /// rewritten to physical registers.
+ ///
+ /// These passes must preserve VirtRegMap and LiveIntervals, and when running
+ /// after RABasic or RAGreedy, they should take advantage of LiveRegMatrix.
+ /// When these passes run, VirtRegMap contains legal physreg assignments for
+ /// all virtual registers.
+ virtual bool addPreRewrite() {
+ return false;
+ }
+
/// addFinalizeRegAlloc - This method may be implemented by targets that want
/// to run passes within the regalloc pipeline, immediately after the register
/// allocation pass itself. These passes run as soon as virtual regisiters
diff --git a/lib/CodeGen/Passes.cpp b/lib/CodeGen/Passes.cpp
index b166dbe..bf244a5 100644
--- a/lib/CodeGen/Passes.cpp
+++ b/lib/CodeGen/Passes.cpp
@@ -603,7 +603,11 @@ void TargetPassConfig::addOptimizedRegAlloc(FunctionPass *RegAllocPass) {
// Add the selected register allocation pass.
PM->add(RegAllocPass);
- printAndVerify("After Register Allocation");
+ printAndVerify("After Register Allocation, before rewriter");
+
+ // Allow targets to change the register assignments before rewriting.
+ if (addPreRewrite())
+ printAndVerify("After pre-rewrite passes");
// Finally rewrite virtual registers.
addPass(VirtRegRewriterID);