summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2015-07-01 17:17:17 +0000
committerMatthias Braun <matze@braunis.de>2015-07-01 17:17:17 +0000
commite1cd96bf9e80e93805418fe8f1c6f721bb49f378 (patch)
treedf2deba18122b30e4650608ce672a598e515cc83 /llvm/lib/CodeGen
parentd0d9a1f63f1770458df9efd811fa4455a6aeacae (diff)
downloadbcm5719-llvm-e1cd96bf9e80e93805418fe8f1c6f721bb49f378.tar.gz
bcm5719-llvm-e1cd96bf9e80e93805418fe8f1c6f721bb49f378.zip
LivePhysRegs: Add support to add pristine registers when populating with live-in/live-out registers.
Differential Revision: http://reviews.llvm.org/D10139 llvm-svn: 241172
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/LivePhysRegs.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/LivePhysRegs.cpp b/llvm/lib/CodeGen/LivePhysRegs.cpp
index eef7643367f..cbd98e3f345 100644
--- a/llvm/lib/CodeGen/LivePhysRegs.cpp
+++ b/llvm/lib/CodeGen/LivePhysRegs.cpp
@@ -14,6 +14,8 @@
//===----------------------------------------------------------------------===//
#include "llvm/CodeGen/LivePhysRegs.h"
+#include "llvm/CodeGen/MachineFrameInfo.h"
+#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstrBundle.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
@@ -123,3 +125,42 @@ void LivePhysRegs::dump() const {
dbgs() << " " << *this;
#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);
+}
OpenPOWER on IntegriCloud