summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAnton Korobeynikov <asl@math.spbu.ru>2009-07-16 13:49:25 +0000
committerAnton Korobeynikov <asl@math.spbu.ru>2009-07-16 13:49:25 +0000
commit51f613fb2b177a19fcc92c38cc58c99de4c330b0 (patch)
tree322cdea5d0d128d55bfae7eb3d9e2d96ade2e214 /lib
parent81c0325cdf7442c2948fbf3b8822d56d46a0d988 (diff)
downloadllvm-51f613fb2b177a19fcc92c38cc58c99de4c330b0.tar.gz
llvm-51f613fb2b177a19fcc92c38cc58c99de4c330b0.tar.bz2
llvm-51f613fb2b177a19fcc92c38cc58c99de4c330b0.tar.xz
Add simple frame index elimination
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75939 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Target/SystemZ/SystemZRegisterInfo.cpp40
-rw-r--r--lib/Target/SystemZ/SystemZRegisterInfo.h2
-rw-r--r--lib/Target/SystemZ/SystemZTargetMachine.cpp2
3 files changed, 42 insertions, 2 deletions
diff --git a/lib/Target/SystemZ/SystemZRegisterInfo.cpp b/lib/Target/SystemZ/SystemZRegisterInfo.cpp
index 98bcf387a3..3773a2a496 100644
--- a/lib/Target/SystemZ/SystemZRegisterInfo.cpp
+++ b/lib/Target/SystemZ/SystemZRegisterInfo.cpp
@@ -17,6 +17,7 @@
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
+#include "llvm/Target/TargetFrameInfo.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/ADT/BitVector.h"
@@ -77,9 +78,46 @@ eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
assert(0 && "Not implemented yet!");
}
+int SystemZRegisterInfo::getFrameIndexOffset(MachineFunction &MF, int FI) const {
+ const TargetFrameInfo &TFI = *MF.getTarget().getFrameInfo();
+ MachineFrameInfo *MFI = MF.getFrameInfo();
+ int Offset = MFI->getObjectOffset(FI) + MFI->getOffsetAdjustment();
+ uint64_t StackSize = MFI->getStackSize();
+
+ Offset += StackSize - TFI.getOffsetOfLocalArea();
+
+ // Skip the register save area if we generated the stack frame.
+ if (StackSize)
+ Offset -= TFI.getOffsetOfLocalArea();
+
+ return Offset;
+}
+
void SystemZRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
int SPAdj, RegScavenger *RS) const {
- assert(0 && "Not implemented yet!");
+ assert(SPAdj == 0 && "Unxpected");
+
+ unsigned i = 0;
+ MachineInstr &MI = *II;
+ MachineFunction &MF = *MI.getParent()->getParent();
+ while (!MI.getOperand(i).isFI()) {
+ ++i;
+ assert(i < MI.getNumOperands() && "Instr doesn't have FrameIndex operand!");
+ }
+
+ int FrameIndex = MI.getOperand(i).getIndex();
+
+ unsigned BasePtr = (hasFP(MF) ? SystemZ::R11D : SystemZ::R15D);
+
+ // This must be part of a rri or ri operand memory reference. Replace the
+ // FrameIndex with base register with BasePtr. Add an offset to the
+ // displacement field.
+ MI.getOperand(i).ChangeToRegister(BasePtr, false);
+
+ // Offset is a 20-bit integer.
+ // FIXME: handle "too long" displacements.
+ int Offset = getFrameIndexOffset(MF, FrameIndex) + MI.getOperand(i+1).getImm();
+ MI.getOperand(i+1).ChangeToImmediate(Offset);
}
void SystemZRegisterInfo::emitPrologue(MachineFunction &MF) const {
diff --git a/lib/Target/SystemZ/SystemZRegisterInfo.h b/lib/Target/SystemZ/SystemZRegisterInfo.h
index 1af6f931ae..4de46bf6ce 100644
--- a/lib/Target/SystemZ/SystemZRegisterInfo.h
+++ b/lib/Target/SystemZ/SystemZRegisterInfo.h
@@ -39,6 +39,8 @@ struct SystemZRegisterInfo : public SystemZGenRegisterInfo {
bool hasFP(const MachineFunction &MF) const;
+ int getFrameIndexOffset(MachineFunction &MF, int FI) const;
+
void eliminateCallFramePseudoInstr(MachineFunction &MF,
MachineBasicBlock &MBB,
MachineBasicBlock::iterator I) const;
diff --git a/lib/Target/SystemZ/SystemZTargetMachine.cpp b/lib/Target/SystemZ/SystemZTargetMachine.cpp
index a8b2b7688c..8160953454 100644
--- a/lib/Target/SystemZ/SystemZTargetMachine.cpp
+++ b/lib/Target/SystemZ/SystemZTargetMachine.cpp
@@ -41,7 +41,7 @@ SystemZTargetMachine::SystemZTargetMachine(const Module &M, const std::string &F
: Subtarget(*this, M, FS),
DataLayout("E-p:64:64:64-i1:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128"),
InstrInfo(*this), TLInfo(*this),
- FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) {
+ FrameInfo(TargetFrameInfo::StackGrowsDown, 8, -160) {
}
bool SystemZTargetMachine::addInstSelector(PassManagerBase &PM,