aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/CodeGen/MachineFrameInfo.h
diff options
context:
space:
mode:
authorDavid Greene <greened@obbligato.org>2009-11-12 20:49:22 +0000
committerDavid Greene <greened@obbligato.org>2009-11-12 20:49:22 +0000
commit3f2bf85d14759cc4b28a86805f566ac805a54d00 (patch)
treee400e38dbd9b2104903d9b54f5229771bb6ca338 /include/llvm/CodeGen/MachineFrameInfo.h
parent05872ea804cdc9534960b30d28a391928c61481a (diff)
downloadexternal_llvm-3f2bf85d14759cc4b28a86805f566ac805a54d00.zip
external_llvm-3f2bf85d14759cc4b28a86805f566ac805a54d00.tar.gz
external_llvm-3f2bf85d14759cc4b28a86805f566ac805a54d00.tar.bz2
Add a bool flag to StackObjects telling whether they reference spill
slots. The AsmPrinter will use this information to determine whether to print a spill/reload comment. Remove default argument values. It's too easy to pass a wrong argument value when multiple arguments have default values. Make everything explicit to trap bugs early. Update all targets to adhere to the new interfaces.. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@87022 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen/MachineFrameInfo.h')
-rw-r--r--include/llvm/CodeGen/MachineFrameInfo.h55
1 files changed, 45 insertions, 10 deletions
diff --git a/include/llvm/CodeGen/MachineFrameInfo.h b/include/llvm/CodeGen/MachineFrameInfo.h
index 07c1eca..3dcdc79 100644
--- a/include/llvm/CodeGen/MachineFrameInfo.h
+++ b/include/llvm/CodeGen/MachineFrameInfo.h
@@ -15,9 +15,11 @@
#define LLVM_CODEGEN_MACHINEFRAMEINFO_H
#include "llvm/ADT/BitVector.h"
-#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallVector.h"
#include "llvm/System/DataTypes.h"
#include <cassert>
+#include <limits>
#include <vector>
namespace llvm {
@@ -106,8 +108,8 @@ class MachineFrameInfo {
// cannot alias any other memory objects.
bool isSpillSlot;
- StackObject(uint64_t Sz, unsigned Al, int64_t SP = 0, bool IM = false,
- bool isSS = false)
+ StackObject(uint64_t Sz, unsigned Al, int64_t SP, bool IM,
+ bool isSS)
: SPOffset(SP), Size(Sz), Alignment(Al), isImmutable(IM),
isSpillSlot(isSS) {}
};
@@ -182,6 +184,10 @@ class MachineFrameInfo {
/// CSIValid - Has CSInfo been set yet?
bool CSIValid;
+ /// SpillObjects - A vector indicating which frame indices refer to
+ /// spill slots.
+ SmallVector<bool, 8> SpillObjects;
+
/// 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
@@ -192,6 +198,7 @@ class MachineFrameInfo {
/// TargetFrameInfo - Target information about frame layout.
///
const TargetFrameInfo &TFI;
+
public:
explicit MachineFrameInfo(const TargetFrameInfo &tfi) : TFI(tfi) {
StackSize = NumFixedObjects = OffsetAdjustment = MaxAlignment = 0;
@@ -341,7 +348,7 @@ public:
/// index with a negative value.
///
int CreateFixedObject(uint64_t Size, int64_t SPOffset,
- bool Immutable = true);
+ bool Immutable, bool isSS);
/// isFixedObjectIndex - Returns true if the specified index corresponds to a
@@ -374,13 +381,31 @@ public:
return Objects[ObjectIdx+NumFixedObjects].Size == ~0ULL;
}
- /// CreateStackObject - Create a new statically sized stack object, returning
- /// a nonnegative identifier to represent it.
+ /// CreateStackObject - Create a new statically sized stack object,
+ /// returning a nonnegative identifier to represent it.
///
- int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS = false) {
+ int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS) {
assert(Size != 0 && "Cannot allocate zero size stack objects!");
Objects.push_back(StackObject(Size, Alignment, 0, false, isSS));
- return (int)Objects.size()-NumFixedObjects-1;
+ int Index = (int)Objects.size()-NumFixedObjects-1;
+ assert(Index >= 0 && "Bad frame index!");
+ if (SpillObjects.size() <= static_cast<unsigned>(Index))
+ SpillObjects.resize(Index+1);
+ SpillObjects[Index] = false;
+ return Index;
+ }
+
+ /// CreateSpillStackObject - Create a new statically sized stack
+ /// object that represents a spill slot, returning a nonnegative
+ /// identifier to represent it.
+ ///
+ int CreateSpillStackObject(uint64_t Size, unsigned Alignment) {
+ CreateStackObject(Size, Alignment, true);
+ int Index = (int)Objects.size()-NumFixedObjects-1;
+ if (SpillObjects.size() <= static_cast<unsigned>(Index))
+ SpillObjects.resize(Index+1);
+ SpillObjects[Index] = true;
+ return Index;
}
/// RemoveStackObject - Remove or mark dead a statically sized stack object.
@@ -397,10 +422,20 @@ public:
///
int CreateVariableSizedObject() {
HasVarSizedObjects = true;
- Objects.push_back(StackObject(0, 1));
+ Objects.push_back(StackObject(0, 1, 0, false, false));
return (int)Objects.size()-NumFixedObjects-1;
}
-
+
+ /// isSpillObject - Return whether the index refers to a spill slot.
+ ///
+ bool isSpillObject(int Index) const {
+ // Negative indices can't be spill slots.
+ if (Index < 0) return false;
+ assert(static_cast<unsigned>(Index) < SpillObjects.size() &&
+ "Invalid frame index!");
+ return SpillObjects[Index];
+ }
+
/// getCalleeSavedInfo - Returns a reference to call saved info vector for the
/// current function.
const std::vector<CalleeSavedInfo> &getCalleeSavedInfo() const {