summaryrefslogtreecommitdiff
path: root/lib/CodeGen/Spiller.cpp
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2009-11-19 04:15:33 +0000
committerLang Hames <lhames@gmail.com>2009-11-19 04:15:33 +0000
commit835ca07991c1b8ec47240b15417e1b2732480094 (patch)
tree798d9727b01e463498f682b5987b1aee13f3fea9 /lib/CodeGen/Spiller.cpp
parent2b5e6b1c9c9c3c3f0d07098020f9eb4527515374 (diff)
downloadllvm-835ca07991c1b8ec47240b15417e1b2732480094.tar.gz
llvm-835ca07991c1b8ec47240b15417e1b2732480094.tar.bz2
llvm-835ca07991c1b8ec47240b15417e1b2732480094.tar.xz
Added a new Spiller implementation which wraps LiveIntervals::addIntervalsForSpills.
All spiller calls in RegAllocLinearScan now go through the new Spiller interface. The "-new-spill-framework" command line option has been removed. To use the trivial in-place spiller you should now pass "-spiller=trivial -rewriter=trivial". (Note the trivial spiller/rewriter are only meant to serve as examples of the new in-place modification work. Enabling them will yield terrible, though hopefully functional, code). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89311 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/Spiller.cpp')
-rw-r--r--lib/CodeGen/Spiller.cpp51
1 files changed, 46 insertions, 5 deletions
diff --git a/lib/CodeGen/Spiller.cpp b/lib/CodeGen/Spiller.cpp
index e0445f4d07..20c4a28b1f 100644
--- a/lib/CodeGen/Spiller.cpp
+++ b/lib/CodeGen/Spiller.cpp
@@ -18,11 +18,25 @@
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetInstrInfo.h"
+#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
+namespace {
+ enum SpillerName { trivial, standard };
+}
+
+static cl::opt<SpillerName>
+spillerOpt("spiller",
+ cl::desc("Spiller to use: (default: standard)"),
+ cl::Prefix,
+ cl::values(clEnumVal(trivial, "trivial spiller"),
+ clEnumVal(standard, "default spiller"),
+ clEnumValEnd),
+ cl::init(standard));
+
Spiller::~Spiller() {}
namespace {
@@ -156,18 +170,45 @@ class TrivialSpiller : public SpillerBase {
public:
TrivialSpiller(MachineFunction *mf, LiveIntervals *lis, LiveStacks *ls,
- VirtRegMap *vrm) :
- SpillerBase(mf, lis, ls, vrm) {}
+ VirtRegMap *vrm)
+ : SpillerBase(mf, lis, ls, vrm) {}
- std::vector<LiveInterval*> spill(LiveInterval *li) {
+ std::vector<LiveInterval*> spill(LiveInterval *li,
+ SmallVectorImpl<LiveInterval*> &spillIs) {
+ // Ignore spillIs - we don't use it.
return trivialSpillEverywhere(li);
}
};
+/// Falls back on LiveIntervals::addIntervalsForSpills.
+class StandardSpiller : public Spiller {
+private:
+ LiveIntervals *lis;
+ const MachineLoopInfo *loopInfo;
+ VirtRegMap *vrm;
+public:
+ StandardSpiller(MachineFunction *mf, LiveIntervals *lis, LiveStacks *ls,
+ const MachineLoopInfo *loopInfo, VirtRegMap *vrm)
+ : lis(lis), loopInfo(loopInfo), vrm(vrm) {}
+
+ /// Falls back on LiveIntervals::addIntervalsForSpills.
+ std::vector<LiveInterval*> spill(LiveInterval *li,
+ SmallVectorImpl<LiveInterval*> &spillIs) {
+ return lis->addIntervalsForSpills(*li, spillIs, loopInfo, *vrm);
+ }
+
+};
+
}
llvm::Spiller* llvm::createSpiller(MachineFunction *mf, LiveIntervals *lis,
- LiveStacks *ls, VirtRegMap *vrm) {
- return new TrivialSpiller(mf, lis, ls, vrm);
+ LiveStacks *ls,
+ const MachineLoopInfo *loopInfo,
+ VirtRegMap *vrm) {
+ switch (spillerOpt) {
+ case trivial: return new TrivialSpiller(mf, lis, ls, vrm); break;
+ case standard: return new StandardSpiller(mf, lis, ls, loopInfo, vrm); break;
+ default: llvm_unreachable("Unreachable!"); break;
+ }
}