diff options
author | Evan Cheng <evan.cheng@apple.com> | 2009-04-17 01:29:40 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2009-04-17 01:29:40 +0000 |
commit | b96a1082a9910840c78568f7c04e743d4f0cae9b (patch) | |
tree | d6042f25161c1fece9a8d6ed089f9e7d0517e5c1 /llvm/lib/CodeGen/Spiller.h | |
parent | c3e7cff6d3cc890a4c1a8ddcb0a716c052141fc2 (diff) | |
download | bcm5719-llvm-b96a1082a9910840c78568f7c04e743d4f0cae9b.tar.gz bcm5719-llvm-b96a1082a9910840c78568f7c04e743d4f0cae9b.zip |
Teach spiller to unfold instructions which modref spill slot when a scratch
register is available and when it's profitable.
e.g.
xorq %r12<kill>, %r13
addq %rax, -184(%rbp)
addq %r13, -184(%rbp)
==>
xorq %r12<kill>, %r13
movq -184(%rbp), %r12
addq %rax, %r12
addq %r13, %r12
movq %r12, -184(%rbp)
Two more instructions, but fewer memory accesses. It can also open up
opportunities for more optimizations.
llvm-svn: 69341
Diffstat (limited to 'llvm/lib/CodeGen/Spiller.h')
-rw-r--r-- | llvm/lib/CodeGen/Spiller.h | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/Spiller.h b/llvm/lib/CodeGen/Spiller.h index 5a42a8279db..c0d08379604 100644 --- a/llvm/lib/CodeGen/Spiller.h +++ b/llvm/lib/CodeGen/Spiller.h @@ -97,7 +97,7 @@ namespace llvm { const TargetRegisterInfo *getRegInfo() const { return TRI; } /// getSpillSlotOrReMatPhysReg - If the specified stack slot or remat is - /// available in a physical register, return that PhysReg, otherwise + /// available in a physical register, return that PhysReg, otherwise /// return 0. unsigned getSpillSlotOrReMatPhysReg(int Slot) const { std::map<int, unsigned>::const_iterator I = @@ -284,6 +284,7 @@ namespace llvm { MachineRegisterInfo *RegInfo; const TargetRegisterInfo *TRI; const TargetInstrInfo *TII; + BitVector AllocatableRegs; DenseMap<MachineInstr*, unsigned> DistanceMap; public: bool runOnMachineFunction(MachineFunction &MF, VirtRegMap &VRM); @@ -291,12 +292,22 @@ namespace llvm { void TransferDeadness(MachineBasicBlock *MBB, unsigned CurDist, unsigned Reg, BitVector &RegKills, std::vector<MachineOperand*> &KillOps); - bool PrepForUnfoldOpti(MachineBasicBlock &MBB, - MachineBasicBlock::iterator &MII, + + bool OptimizeByUnfold(MachineBasicBlock &MBB, + MachineBasicBlock::iterator &MII, + std::vector<MachineInstr*> &MaybeDeadStores, + AvailableSpills &Spills, BitVector &RegKills, + std::vector<MachineOperand*> &KillOps, + VirtRegMap &VRM); + + bool OptimizeByUnfold2(unsigned VirtReg, int SS, + MachineBasicBlock &MBB, + MachineBasicBlock::iterator &MII, std::vector<MachineInstr*> &MaybeDeadStores, AvailableSpills &Spills, BitVector &RegKills, std::vector<MachineOperand*> &KillOps, VirtRegMap &VRM); + bool CommuteToFoldReload(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MII, unsigned VirtReg, unsigned SrcReg, int SS, @@ -305,6 +316,7 @@ namespace llvm { std::vector<MachineOperand*> &KillOps, const TargetRegisterInfo *TRI, VirtRegMap &VRM); + void SpillRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MII, int Idx, unsigned PhysReg, int StackSlot, @@ -315,6 +327,7 @@ namespace llvm { BitVector &RegKills, std::vector<MachineOperand*> &KillOps, VirtRegMap &VRM); + void RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM, AvailableSpills &Spills, BitVector &RegKills, std::vector<MachineOperand*> &KillOps); |