mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-21 02:24:22 +00:00
LivePhysRegs: Add support to add pristine registers when populating with live-in/live-out registers.
Differential Revision: http://reviews.llvm.org/D10139 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241172 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -116,19 +116,15 @@ public:
|
|||||||
void stepForward(const MachineInstr &MI,
|
void stepForward(const MachineInstr &MI,
|
||||||
SmallVectorImpl<std::pair<unsigned, const MachineOperand*>> &Clobbers);
|
SmallVectorImpl<std::pair<unsigned, const MachineOperand*>> &Clobbers);
|
||||||
|
|
||||||
/// \brief Adds all live-in registers of basic block @p MBB.
|
/// \brief Adds all live-in registers of basic block @p MBB; After prologue/
|
||||||
void addLiveIns(const MachineBasicBlock *MBB) {
|
/// epilogue insertion \p AddPristines should be set to true to insert the
|
||||||
for (MachineBasicBlock::livein_iterator LI = MBB->livein_begin(),
|
/// pristine registers.
|
||||||
LE = MBB->livein_end(); LI != LE; ++LI)
|
void addLiveIns(const MachineBasicBlock *MBB, bool AddPristines = false);
|
||||||
addReg(*LI);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// \brief Adds all live-out registers of basic block @p MBB.
|
/// \brief Adds all live-out registers of basic block @p MBB; After prologue/
|
||||||
void addLiveOuts(const MachineBasicBlock *MBB) {
|
/// epilogue insertion \p AddPristines should be set to true to insert the
|
||||||
for (MachineBasicBlock::const_succ_iterator SI = MBB->succ_begin(),
|
/// pristine registers.
|
||||||
SE = MBB->succ_end(); SI != SE; ++SI)
|
void addLiveOuts(const MachineBasicBlock *MBB, bool AddPristines = false);
|
||||||
addLiveIns(*SI);
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef SparseSet<unsigned>::const_iterator const_iterator;
|
typedef SparseSet<unsigned>::const_iterator const_iterator;
|
||||||
const_iterator begin() const { return LiveRegs.begin(); }
|
const_iterator begin() const { return LiveRegs.begin(); }
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "llvm/CodeGen/LivePhysRegs.h"
|
#include "llvm/CodeGen/LivePhysRegs.h"
|
||||||
|
#include "llvm/CodeGen/MachineFrameInfo.h"
|
||||||
|
#include "llvm/CodeGen/MachineFunction.h"
|
||||||
#include "llvm/CodeGen/MachineInstrBundle.h"
|
#include "llvm/CodeGen/MachineInstrBundle.h"
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
@ -123,3 +125,42 @@ void LivePhysRegs::dump() const {
|
|||||||
dbgs() << " " << *this;
|
dbgs() << " " << *this;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Add live-in registers of basic block \p MBB to \p LiveRegs.
|
||||||
|
static void addLiveIns(LivePhysRegs &LiveRegs, const MachineBasicBlock &MBB) {
|
||||||
|
for (unsigned Reg : make_range(MBB.livein_begin(), MBB.livein_end()))
|
||||||
|
LiveRegs.addReg(Reg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Add pristine registers to the given \p LiveRegs. This function removes
|
||||||
|
/// actually saved callee save registers when \p InPrologueEpilogue is false.
|
||||||
|
static void addPristines(LivePhysRegs &LiveRegs, const MachineFunction &MF,
|
||||||
|
const TargetRegisterInfo &TRI) {
|
||||||
|
const MachineFrameInfo &MFI = *MF.getFrameInfo();
|
||||||
|
if (!MFI.isCalleeSavedInfoValid())
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (const MCPhysReg *CSR = TRI.getCalleeSavedRegs(&MF); CSR && *CSR; ++CSR)
|
||||||
|
LiveRegs.addReg(*CSR);
|
||||||
|
for (const CalleeSavedInfo &Info : MFI.getCalleeSavedInfo())
|
||||||
|
LiveRegs.removeReg(Info.getReg());
|
||||||
|
}
|
||||||
|
|
||||||
|
void LivePhysRegs::addLiveOuts(const MachineBasicBlock *MBB,
|
||||||
|
bool AddPristines) {
|
||||||
|
if (AddPristines) {
|
||||||
|
const MachineFunction &MF = *MBB->getParent();
|
||||||
|
addPristines(*this, MF, *TRI);
|
||||||
|
}
|
||||||
|
for (const MachineBasicBlock *Succ : MBB->successors())
|
||||||
|
::addLiveIns(*this, *Succ);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LivePhysRegs::addLiveIns(const MachineBasicBlock *MBB,
|
||||||
|
bool AddPristines) {
|
||||||
|
if (AddPristines) {
|
||||||
|
const MachineFunction &MF = *MBB->getParent();
|
||||||
|
addPristines(*this, MF, *TRI);
|
||||||
|
}
|
||||||
|
::addLiveIns(*this, *MBB);
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user