llvm.org GIT mirror llvm / f2c6e36
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 Jakob Stoklund Olesen 10 years ago
6 changed file(s) with 64 addition(s) and 60 deletion(s). Raw diff Collapse all Expand all
5757 ~InlineSpiller() {}
5858
5959 public:
60 InlineSpiller(MachineFunction *mf, LiveIntervals *lis, MachineLoopInfo *mli,
61 VirtRegMap *vrm)
62 : mf_(*mf), lis_(*lis), loops_(*mli), vrm_(*vrm),
63 mfi_(*mf->getFrameInfo()),
64 mri_(mf->getRegInfo()),
65 tii_(*mf->getTarget().getInstrInfo()),
66 tri_(*mf->getTarget().getRegisterInfo()),
60 InlineSpiller(MachineFunctionPass &pass,
61 MachineFunction &mf,
62 VirtRegMap &vrm)
63 : mf_(mf),
64 lis_(pass.getAnalysis()),
65 loops_(pass.getAnalysis()),
66 vrm_(vrm),
67 mfi_(*mf.getFrameInfo()),
68 mri_(mf.getRegInfo()),
69 tii_(*mf.getTarget().getInstrInfo()),
70 tri_(*mf.getTarget().getRegisterInfo()),
6771 reserved_(tri_.getReservedRegs(mf_)),
68 splitAnalysis_(mf, lis, mli) {}
72 splitAnalysis_(mf, lis_, loops_) {}
6973
7074 void spill(LiveInterval *li,
7175 std::vector &newIntervals,
8892 }
8993
9094 namespace llvm {
91 Spiller *createInlineSpiller(MachineFunction *mf,
92 LiveIntervals *lis,
93 MachineLoopInfo *mli,
94 VirtRegMap *vrm) {
95 return new InlineSpiller(mf, lis, mli, vrm);
95 Spiller *createInlineSpiller(MachineFunctionPass &pass,
96 MachineFunction &mf,
97 VirtRegMap &vrm) {
98 return new InlineSpiller(pass, mf, vrm);
9699 }
97100 }
98101
482482 vrm_ = &getAnalysis();
483483 if (!rewriter_.get()) rewriter_.reset(createVirtRegRewriter());
484484
485 spiller_.reset(createSpiller(mf_, li_, loopInfo, vrm_));
485 spiller_.reset(createSpiller(*this, *mf_, *vrm_));
486486
487487 initIntervalSets();
488488
1414 #include "llvm/CodeGen/MachineFrameInfo.h"
1515 #include "llvm/CodeGen/MachineFunction.h"
1616 #include "llvm/CodeGen/MachineInstrBuilder.h"
17 #include "llvm/CodeGen/MachineLoopInfo.h"
1718 #include "llvm/CodeGen/MachineRegisterInfo.h"
1819 #include "llvm/Target/TargetMachine.h"
1920 #include "llvm/Target/TargetInstrInfo.h"
4849 /// Utility class for spillers.
4950 class SpillerBase : public Spiller {
5051 protected:
52 MachineFunctionPass *pass;
5153 MachineFunction *mf;
54 VirtRegMap *vrm;
5255 LiveIntervals *lis;
5356 MachineFrameInfo *mfi;
5457 MachineRegisterInfo *mri;
5558 const TargetInstrInfo *tii;
5659 const TargetRegisterInfo *tri;
57 VirtRegMap *vrm;
5860
5961 /// Construct a spiller base.
60 SpillerBase(MachineFunction *mf, LiveIntervals *lis, VirtRegMap *vrm)
61 : mf(mf), lis(lis), vrm(vrm)
62 SpillerBase(MachineFunctionPass &pass, MachineFunction &mf, VirtRegMap &vrm)
63 : pass(&pass), mf(&mf), vrm(&vrm)
6264 {
63 mfi = mf->getFrameInfo();
64 mri = &mf->getRegInfo();
65 tii = mf->getTarget().getInstrInfo();
66 tri = mf->getTarget().getRegisterInfo();
65 lis = &pass.getAnalysis();
66 mfi = mf.getFrameInfo();
67 mri = &mf.getRegInfo();
68 tii = mf.getTarget().getInstrInfo();
69 tri = mf.getTarget().getRegisterInfo();
6770 }
6871
6972 /// Add spill ranges for every use/def of the live interval, inserting loads
172175 class TrivialSpiller : public SpillerBase {
173176 public:
174177
175 TrivialSpiller(MachineFunction *mf, LiveIntervals *lis, VirtRegMap *vrm)
176 : SpillerBase(mf, lis, vrm) {}
178 TrivialSpiller(MachineFunctionPass &pass, MachineFunction &mf,
179 VirtRegMap &vrm)
180 : SpillerBase(pass, mf, vrm) {}
177181
178182 void spill(LiveInterval *li,
179183 std::vector &newIntervals,
195199 MachineLoopInfo *loopInfo;
196200 VirtRegMap *vrm;
197201 public:
198 StandardSpiller(LiveIntervals *lis, MachineLoopInfo *loopInfo,
199 VirtRegMap *vrm)
200 : lis(lis), loopInfo(loopInfo), vrm(vrm) {}
202 StandardSpiller(MachineFunctionPass &pass, MachineFunction &mf,
203 VirtRegMap &vrm)
204 : lis(&pass.getAnalysis()),
205 loopInfo(pass.getAnalysisIfAvailable()),
206 vrm(&vrm) {}
201207
202208 /// Falls back on LiveIntervals::addIntervalsForSpills.
203209 void spill(LiveInterval *li,
220226 /// then the spiller falls back on the standard spilling mechanism.
221227 class SplittingSpiller : public StandardSpiller {
222228 public:
223 SplittingSpiller(MachineFunction *mf, LiveIntervals *lis,
224 MachineLoopInfo *loopInfo, VirtRegMap *vrm)
225 : StandardSpiller(lis, loopInfo, vrm) {
226
227 mri = &mf->getRegInfo();
228 tii = mf->getTarget().getInstrInfo();
229 tri = mf->getTarget().getRegisterInfo();
229 SplittingSpiller(MachineFunctionPass &pass, MachineFunction &mf,
230 VirtRegMap &vrm)
231 : StandardSpiller(pass, mf, vrm) {
232 mri = &mf.getRegInfo();
233 tii = mf.getTarget().getInstrInfo();
234 tri = mf.getTarget().getRegisterInfo();
230235 }
231236
232237 void spill(LiveInterval *li,
505510
506511
507512 namespace llvm {
508 Spiller *createInlineSpiller(MachineFunction*,
509 LiveIntervals*,
510 MachineLoopInfo*,
511 VirtRegMap*);
513 Spiller *createInlineSpiller(MachineFunctionPass &pass,
514 MachineFunction &mf,
515 VirtRegMap &vrm);
512516 }
513517
514 llvm::Spiller* llvm::createSpiller(MachineFunction *mf, LiveIntervals *lis,
515 MachineLoopInfo *loopInfo,
516 VirtRegMap *vrm) {
518 llvm::Spiller* llvm::createSpiller(MachineFunctionPass &pass,
519 MachineFunction &mf,
520 VirtRegMap &vrm) {
517521 switch (spillerOpt) {
518522 default: assert(0 && "unknown spiller");
519 case trivial: return new TrivialSpiller(mf, lis, vrm);
520 case standard: return new StandardSpiller(lis, loopInfo, vrm);
521 case splitting: return new SplittingSpiller(mf, lis, loopInfo, vrm);
522 case inline_: return createInlineSpiller(mf, lis, loopInfo, vrm);
523 case trivial: return new TrivialSpiller(pass, mf, vrm);
524 case standard: return new StandardSpiller(pass, mf, vrm);
525 case splitting: return new SplittingSpiller(pass, mf, vrm);
526 case inline_: return createInlineSpiller(pass, mf, vrm);
523527 }
524528 }
1515 namespace llvm {
1616
1717 class LiveInterval;
18 class LiveIntervals;
19 class LiveStacks;
2018 class MachineFunction;
21 class MachineInstr;
22 class MachineLoopInfo;
19 class MachineFunctionPass;
2320 class SlotIndex;
2421 class VirtRegMap;
25 class VNInfo;
2622
2723 /// Spiller interface.
2824 ///
4945 };
5046
5147 /// Create and return a spiller object, as specified on the command line.
52 Spiller* createSpiller(MachineFunction *mf, LiveIntervals *li,
53 MachineLoopInfo *loopInfo, VirtRegMap *vrm);
48 Spiller* createSpiller(MachineFunctionPass &pass,
49 MachineFunction &mf,
50 VirtRegMap &vrm);
5451 }
5552
5653 #endif
3333 // Split Analysis
3434 //===----------------------------------------------------------------------===//
3535
36 SplitAnalysis::SplitAnalysis(const MachineFunction *mf,
37 const LiveIntervals *lis,
38 const MachineLoopInfo *mli)
39 : mf_(*mf),
40 lis_(*lis),
41 loops_(*mli),
42 tii_(*mf->getTarget().getInstrInfo()),
36 SplitAnalysis::SplitAnalysis(const MachineFunction &mf,
37 const LiveIntervals &lis,
38 const MachineLoopInfo &mli)
39 : mf_(mf),
40 lis_(lis),
41 loops_(mli),
42 tii_(*mf.getTarget().getInstrInfo()),
4343 curli_(0) {}
4444
4545 void SplitAnalysis::clear() {
5555 bool canAnalyzeBranch(const MachineBasicBlock *MBB);
5656
5757 public:
58 SplitAnalysis(const MachineFunction *mf, const LiveIntervals *lis,
59 const MachineLoopInfo *mli);
58 SplitAnalysis(const MachineFunction &mf, const LiveIntervals &lis,
59 const MachineLoopInfo &mli);
6060
6161 /// analyze - set curli to the specified interval, and analyze how it may be
6262 /// split.