mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-05 02:07:16 +00:00
Change the createSpiller interface to take a MachineFunctionPass argument.
The spillers can pluck the analyses they need from the pass reference. Switch some never-null pointers to references. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108969 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
549979f550
commit
f2c6e367c1
@ -58,15 +58,19 @@ class InlineSpiller : public Spiller {
|
||||
~InlineSpiller() {}
|
||||
|
||||
public:
|
||||
InlineSpiller(MachineFunction *mf, LiveIntervals *lis, MachineLoopInfo *mli,
|
||||
VirtRegMap *vrm)
|
||||
: mf_(*mf), lis_(*lis), loops_(*mli), vrm_(*vrm),
|
||||
mfi_(*mf->getFrameInfo()),
|
||||
mri_(mf->getRegInfo()),
|
||||
tii_(*mf->getTarget().getInstrInfo()),
|
||||
tri_(*mf->getTarget().getRegisterInfo()),
|
||||
InlineSpiller(MachineFunctionPass &pass,
|
||||
MachineFunction &mf,
|
||||
VirtRegMap &vrm)
|
||||
: mf_(mf),
|
||||
lis_(pass.getAnalysis<LiveIntervals>()),
|
||||
loops_(pass.getAnalysis<MachineLoopInfo>()),
|
||||
vrm_(vrm),
|
||||
mfi_(*mf.getFrameInfo()),
|
||||
mri_(mf.getRegInfo()),
|
||||
tii_(*mf.getTarget().getInstrInfo()),
|
||||
tri_(*mf.getTarget().getRegisterInfo()),
|
||||
reserved_(tri_.getReservedRegs(mf_)),
|
||||
splitAnalysis_(mf, lis, mli) {}
|
||||
splitAnalysis_(mf, lis_, loops_) {}
|
||||
|
||||
void spill(LiveInterval *li,
|
||||
std::vector<LiveInterval*> &newIntervals,
|
||||
@ -89,11 +93,10 @@ private:
|
||||
}
|
||||
|
||||
namespace llvm {
|
||||
Spiller *createInlineSpiller(MachineFunction *mf,
|
||||
LiveIntervals *lis,
|
||||
MachineLoopInfo *mli,
|
||||
VirtRegMap *vrm) {
|
||||
return new InlineSpiller(mf, lis, mli, vrm);
|
||||
Spiller *createInlineSpiller(MachineFunctionPass &pass,
|
||||
MachineFunction &mf,
|
||||
VirtRegMap &vrm) {
|
||||
return new InlineSpiller(pass, mf, vrm);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -483,7 +483,7 @@ bool RALinScan::runOnMachineFunction(MachineFunction &fn) {
|
||||
vrm_ = &getAnalysis<VirtRegMap>();
|
||||
if (!rewriter_.get()) rewriter_.reset(createVirtRegRewriter());
|
||||
|
||||
spiller_.reset(createSpiller(mf_, li_, loopInfo, vrm_));
|
||||
spiller_.reset(createSpiller(*this, *mf_, *vrm_));
|
||||
|
||||
initIntervalSets();
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "llvm/CodeGen/MachineFrameInfo.h"
|
||||
#include "llvm/CodeGen/MachineFunction.h"
|
||||
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
||||
#include "llvm/CodeGen/MachineLoopInfo.h"
|
||||
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Target/TargetInstrInfo.h"
|
||||
@ -49,22 +50,24 @@ namespace {
|
||||
/// Utility class for spillers.
|
||||
class SpillerBase : public Spiller {
|
||||
protected:
|
||||
MachineFunctionPass *pass;
|
||||
MachineFunction *mf;
|
||||
VirtRegMap *vrm;
|
||||
LiveIntervals *lis;
|
||||
MachineFrameInfo *mfi;
|
||||
MachineRegisterInfo *mri;
|
||||
const TargetInstrInfo *tii;
|
||||
const TargetRegisterInfo *tri;
|
||||
VirtRegMap *vrm;
|
||||
|
||||
/// Construct a spiller base.
|
||||
SpillerBase(MachineFunction *mf, LiveIntervals *lis, VirtRegMap *vrm)
|
||||
: mf(mf), lis(lis), vrm(vrm)
|
||||
SpillerBase(MachineFunctionPass &pass, MachineFunction &mf, VirtRegMap &vrm)
|
||||
: pass(&pass), mf(&mf), vrm(&vrm)
|
||||
{
|
||||
mfi = mf->getFrameInfo();
|
||||
mri = &mf->getRegInfo();
|
||||
tii = mf->getTarget().getInstrInfo();
|
||||
tri = mf->getTarget().getRegisterInfo();
|
||||
lis = &pass.getAnalysis<LiveIntervals>();
|
||||
mfi = mf.getFrameInfo();
|
||||
mri = &mf.getRegInfo();
|
||||
tii = mf.getTarget().getInstrInfo();
|
||||
tri = mf.getTarget().getRegisterInfo();
|
||||
}
|
||||
|
||||
/// Add spill ranges for every use/def of the live interval, inserting loads
|
||||
@ -173,8 +176,9 @@ namespace {
|
||||
class TrivialSpiller : public SpillerBase {
|
||||
public:
|
||||
|
||||
TrivialSpiller(MachineFunction *mf, LiveIntervals *lis, VirtRegMap *vrm)
|
||||
: SpillerBase(mf, lis, vrm) {}
|
||||
TrivialSpiller(MachineFunctionPass &pass, MachineFunction &mf,
|
||||
VirtRegMap &vrm)
|
||||
: SpillerBase(pass, mf, vrm) {}
|
||||
|
||||
void spill(LiveInterval *li,
|
||||
std::vector<LiveInterval*> &newIntervals,
|
||||
@ -196,9 +200,11 @@ protected:
|
||||
MachineLoopInfo *loopInfo;
|
||||
VirtRegMap *vrm;
|
||||
public:
|
||||
StandardSpiller(LiveIntervals *lis, MachineLoopInfo *loopInfo,
|
||||
VirtRegMap *vrm)
|
||||
: lis(lis), loopInfo(loopInfo), vrm(vrm) {}
|
||||
StandardSpiller(MachineFunctionPass &pass, MachineFunction &mf,
|
||||
VirtRegMap &vrm)
|
||||
: lis(&pass.getAnalysis<LiveIntervals>()),
|
||||
loopInfo(pass.getAnalysisIfAvailable<MachineLoopInfo>()),
|
||||
vrm(&vrm) {}
|
||||
|
||||
/// Falls back on LiveIntervals::addIntervalsForSpills.
|
||||
void spill(LiveInterval *li,
|
||||
@ -221,13 +227,12 @@ namespace {
|
||||
/// then the spiller falls back on the standard spilling mechanism.
|
||||
class SplittingSpiller : public StandardSpiller {
|
||||
public:
|
||||
SplittingSpiller(MachineFunction *mf, LiveIntervals *lis,
|
||||
MachineLoopInfo *loopInfo, VirtRegMap *vrm)
|
||||
: StandardSpiller(lis, loopInfo, vrm) {
|
||||
|
||||
mri = &mf->getRegInfo();
|
||||
tii = mf->getTarget().getInstrInfo();
|
||||
tri = mf->getTarget().getRegisterInfo();
|
||||
SplittingSpiller(MachineFunctionPass &pass, MachineFunction &mf,
|
||||
VirtRegMap &vrm)
|
||||
: StandardSpiller(pass, mf, vrm) {
|
||||
mri = &mf.getRegInfo();
|
||||
tii = mf.getTarget().getInstrInfo();
|
||||
tri = mf.getTarget().getRegisterInfo();
|
||||
}
|
||||
|
||||
void spill(LiveInterval *li,
|
||||
@ -506,20 +511,19 @@ private:
|
||||
|
||||
|
||||
namespace llvm {
|
||||
Spiller *createInlineSpiller(MachineFunction*,
|
||||
LiveIntervals*,
|
||||
MachineLoopInfo*,
|
||||
VirtRegMap*);
|
||||
Spiller *createInlineSpiller(MachineFunctionPass &pass,
|
||||
MachineFunction &mf,
|
||||
VirtRegMap &vrm);
|
||||
}
|
||||
|
||||
llvm::Spiller* llvm::createSpiller(MachineFunction *mf, LiveIntervals *lis,
|
||||
MachineLoopInfo *loopInfo,
|
||||
VirtRegMap *vrm) {
|
||||
llvm::Spiller* llvm::createSpiller(MachineFunctionPass &pass,
|
||||
MachineFunction &mf,
|
||||
VirtRegMap &vrm) {
|
||||
switch (spillerOpt) {
|
||||
default: assert(0 && "unknown spiller");
|
||||
case trivial: return new TrivialSpiller(mf, lis, vrm);
|
||||
case standard: return new StandardSpiller(lis, loopInfo, vrm);
|
||||
case splitting: return new SplittingSpiller(mf, lis, loopInfo, vrm);
|
||||
case inline_: return createInlineSpiller(mf, lis, loopInfo, vrm);
|
||||
case trivial: return new TrivialSpiller(pass, mf, vrm);
|
||||
case standard: return new StandardSpiller(pass, mf, vrm);
|
||||
case splitting: return new SplittingSpiller(pass, mf, vrm);
|
||||
case inline_: return createInlineSpiller(pass, mf, vrm);
|
||||
}
|
||||
}
|
||||
|
@ -16,14 +16,10 @@
|
||||
namespace llvm {
|
||||
|
||||
class LiveInterval;
|
||||
class LiveIntervals;
|
||||
class LiveStacks;
|
||||
class MachineFunction;
|
||||
class MachineInstr;
|
||||
class MachineLoopInfo;
|
||||
class MachineFunctionPass;
|
||||
class SlotIndex;
|
||||
class VirtRegMap;
|
||||
class VNInfo;
|
||||
|
||||
/// Spiller interface.
|
||||
///
|
||||
@ -50,8 +46,9 @@ namespace llvm {
|
||||
};
|
||||
|
||||
/// Create and return a spiller object, as specified on the command line.
|
||||
Spiller* createSpiller(MachineFunction *mf, LiveIntervals *li,
|
||||
MachineLoopInfo *loopInfo, VirtRegMap *vrm);
|
||||
Spiller* createSpiller(MachineFunctionPass &pass,
|
||||
MachineFunction &mf,
|
||||
VirtRegMap &vrm);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -34,13 +34,13 @@ AllowSplit("spiller-splits-edges",
|
||||
// Split Analysis
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
SplitAnalysis::SplitAnalysis(const MachineFunction *mf,
|
||||
const LiveIntervals *lis,
|
||||
const MachineLoopInfo *mli)
|
||||
: mf_(*mf),
|
||||
lis_(*lis),
|
||||
loops_(*mli),
|
||||
tii_(*mf->getTarget().getInstrInfo()),
|
||||
SplitAnalysis::SplitAnalysis(const MachineFunction &mf,
|
||||
const LiveIntervals &lis,
|
||||
const MachineLoopInfo &mli)
|
||||
: mf_(mf),
|
||||
lis_(lis),
|
||||
loops_(mli),
|
||||
tii_(*mf.getTarget().getInstrInfo()),
|
||||
curli_(0) {}
|
||||
|
||||
void SplitAnalysis::clear() {
|
||||
|
@ -56,8 +56,8 @@ class SplitAnalysis {
|
||||
bool canAnalyzeBranch(const MachineBasicBlock *MBB);
|
||||
|
||||
public:
|
||||
SplitAnalysis(const MachineFunction *mf, const LiveIntervals *lis,
|
||||
const MachineLoopInfo *mli);
|
||||
SplitAnalysis(const MachineFunction &mf, const LiveIntervals &lis,
|
||||
const MachineLoopInfo &mli);
|
||||
|
||||
/// analyze - set curli to the specified interval, and analyze how it may be
|
||||
/// split.
|
||||
|
Loading…
Reference in New Issue
Block a user