aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2009-08-13 16:19:33 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2009-08-13 16:19:33 +0000
commit4a0f08c5fc14d840e4e411fade036f1cd815b795 (patch)
treeb21035e01c4ffe07646bdf2e47a34f012edad944
parent710461688bba935f0ad5c75da7fec2ad0f225c00 (diff)
downloadexternal_llvm-4a0f08c5fc14d840e4e411fade036f1cd815b795.zip
external_llvm-4a0f08c5fc14d840e4e411fade036f1cd815b795.tar.gz
external_llvm-4a0f08c5fc14d840e4e411fade036f1cd815b795.tar.bz2
Add MachineFrameInfo::getPristineRegisters(MBB) method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78911 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/CodeGen/MachineFrameInfo.h24
-rw-r--r--lib/CodeGen/MachineFunction.cpp32
-rw-r--r--lib/CodeGen/PrologEpilogInserter.cpp2
3 files changed, 56 insertions, 2 deletions
diff --git a/include/llvm/CodeGen/MachineFrameInfo.h b/include/llvm/CodeGen/MachineFrameInfo.h
index 83f7def..2a9b458 100644
--- a/include/llvm/CodeGen/MachineFrameInfo.h
+++ b/include/llvm/CodeGen/MachineFrameInfo.h
@@ -14,6 +14,7 @@
#ifndef LLVM_CODEGEN_MACHINEFRAMEINFO_H
#define LLVM_CODEGEN_MACHINEFRAMEINFO_H
+#include "llvm/ADT/BitVector.h"
#include "llvm/Support/DataTypes.h"
#include <cassert>
#include <iosfwd>
@@ -25,6 +26,7 @@ class TargetRegisterClass;
class Type;
class MachineModuleInfo;
class MachineFunction;
+class MachineBasicBlock;
class TargetFrameInfo;
/// The CalleeSavedInfo class tracks the information need to locate where a
@@ -166,7 +168,10 @@ class MachineFrameInfo {
/// epilog code inserter, this data used for debug info and exception
/// handling.
std::vector<CalleeSavedInfo> CSInfo;
-
+
+ /// CSIValid - Has CSInfo been set yet?
+ bool CSIValid;
+
/// MMI - This field is set (via setMachineModuleInfo) by a module info
/// consumer (ex. DwarfWriter) to indicate that frame layout information
/// should be acquired. Typically, it's the responsibility of the target's
@@ -185,6 +190,7 @@ public:
HasCalls = false;
StackProtectorIdx = -1;
MaxCallFrameSize = 0;
+ CSIValid = false;
MMI = 0;
}
@@ -389,6 +395,22 @@ public:
CSInfo = CSI;
}
+ /// isCalleeSavedInfoValid - Has the callee saved info been calculated yet?
+ bool isCalleeSavedInfoValid() const { return CSIValid; }
+
+ void setCalleeSavedInfoValid(bool v) { CSIValid = v; }
+
+ /// getPristineRegs - Return a set of physical registers that are pristine on
+ /// entry to the MBB.
+ ///
+ /// Pristine registers hold a value that is useless to the current function,
+ /// but that must be preserved - they are callee saved registers that have not
+ /// been saved yet.
+ ///
+ /// Before the PrologueEpilogueInserter has placed the CSR spill code, this
+ /// method always returns an empty set.
+ BitVector getPristineRegs(const MachineBasicBlock *MBB) const;
+
/// getMachineModuleInfo - Used by a prologue/epilogue
/// emitter (TargetRegisterInfo) to provide frame layout information.
MachineModuleInfo *getMachineModuleInfo() const { return MMI; }
diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp
index ab037c2..3b854a5 100644
--- a/lib/CodeGen/MachineFunction.cpp
+++ b/lib/CodeGen/MachineFunction.cpp
@@ -380,6 +380,37 @@ int MachineFrameInfo::CreateFixedObject(uint64_t Size, int64_t SPOffset,
}
+BitVector
+MachineFrameInfo::getPristineRegs(const MachineBasicBlock *MBB) const {
+ assert(MBB && "MBB must be valid");
+ const MachineFunction *MF = MBB->getParent();
+ assert(MF && "MBB must be part of a MachineFunction");
+ const TargetMachine &TM = MF->getTarget();
+ const TargetRegisterInfo *TRI = TM.getRegisterInfo();
+ BitVector BV(TRI->getNumRegs());
+
+ // Before CSI is calculated, no registers are considered pristine. They can be
+ // freely used and PEI will make sure they are saved.
+ if (!isCalleeSavedInfoValid())
+ return BV;
+
+ for (const unsigned *CSR = TRI->getCalleeSavedRegs(MF); CSR && *CSR; ++CSR)
+ BV.set(*CSR);
+
+ // The entry MBB always has all CSRs pristine.
+ if (MBB == &MF->front())
+ return BV;
+
+ // On other MBBs the saved CSRs are not pristine.
+ const std::vector<CalleeSavedInfo> &CSI = getCalleeSavedInfo();
+ for (std::vector<CalleeSavedInfo>::const_iterator I = CSI.begin(),
+ E = CSI.end(); I != E; ++I)
+ BV.reset(I->getReg());
+
+ return BV;
+}
+
+
void MachineFrameInfo::print(const MachineFunction &MF, std::ostream &OS) const{
const TargetFrameInfo *FI = MF.getTarget().getFrameInfo();
int ValOffset = (FI ? FI->getOffsetOfLocalArea() : 0);
@@ -420,7 +451,6 @@ void MachineFrameInfo::dump(const MachineFunction &MF) const {
print(MF, *cerr.stream());
}
-
//===----------------------------------------------------------------------===//
// MachineJumpTableInfo implementation
//===----------------------------------------------------------------------===//
diff --git a/lib/CodeGen/PrologEpilogInserter.cpp b/lib/CodeGen/PrologEpilogInserter.cpp
index 5aa37c9..8b05f4c 100644
--- a/lib/CodeGen/PrologEpilogInserter.cpp
+++ b/lib/CodeGen/PrologEpilogInserter.cpp
@@ -214,6 +214,8 @@ void PEI::calculateCalleeSavedRegisters(MachineFunction &Fn) {
}
}
+ FFI->setCalleeSavedInfoValid(true);
+
if (CSI.empty())
return; // Early exit if no callee saved registers are modified!