initial implementation of addressing mode 2
[oota-llvm.git] / lib / Target / MRegisterInfo.cpp
index 4ddfe9f323049a4fd5331e7eb071713bc4592c84..eb58a3a05998e0179e59a515fb87370f8fde6b12 100644 (file)
@@ -11,7 +11,9 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/MRegisterInfo.h"
+#include "llvm/Target/TargetFrameInfo.h"
 
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
@@ -44,22 +46,18 @@ std::vector<bool> MRegisterInfo::getAllocatableSet(MachineFunction &MF) const {
   return Allocatable;
 }
 
-/// getStackDirection - This method should return the factor by which stacks
-/// grow.  The tyical value is -4 which is the grows negatively in 4 byte
-/// increments.
-int MRegisterInfo::getStackDirection() const {
-  return -sizeof(int32_t);
-}
-
 /// getLocation - This method should return the actual location of a frame
 /// variable given the frame index.  The location is returned in ML.
 /// Subclasses should override this method for special handling of frame
 /// variables and then call MRegisterInfo::getLocation for the default action.
 void MRegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
                         MachineLocation &ML) const {
+  const TargetFrameInfo &TFI = *MF.getTarget().getFrameInfo();
   MachineFrameInfo *MFI = MF.getFrameInfo();
   ML.set(getFrameRegister(MF),
-         MFI->getObjectOffset(Index) + MFI->getStackSize());
+         MFI->getObjectOffset(Index) +
+         MFI->getStackSize() -
+         TFI.getOffsetOfLocalArea());
 }
 
 /// getInitialFrameState - Returns a list of machine moves that are assumed