[llvm-commits] [llvm] r46597 - in /llvm/trunk: include/llvm/Target/MRegisterInfo.h lib/CodeGen/DwarfWriter.cpp lib/Target/MRegisterInfo.cpp

Evan Cheng evan.cheng at apple.com
Wed Jan 30 19:37:29 PST 2008


Author: evancheng
Date: Wed Jan 30 21:37:28 2008
New Revision: 46597

URL: http://llvm.org/viewvc/llvm-project?rev=46597&view=rev
Log:
MRegisterInfo::getLocation() is a really bad idea. Its function is to calculate the offset from frame pointer to a stack slot and then storing the delta in a MachineLocation object. The name is bad (it implies a getter), and MRegisterInfo doesn't need to know about MachineLocation.
Replace getLocation() with getFrameIndexOffset() which returns the delta from frame pointer to stack slot. Dwarf writer can then use the information for whatever it wants.

Modified:
    llvm/trunk/include/llvm/Target/MRegisterInfo.h
    llvm/trunk/lib/CodeGen/DwarfWriter.cpp
    llvm/trunk/lib/Target/MRegisterInfo.cpp

Modified: llvm/trunk/include/llvm/Target/MRegisterInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/MRegisterInfo.h?rev=46597&r1=46596&r2=46597&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Target/MRegisterInfo.h (original)
+++ llvm/trunk/include/llvm/Target/MRegisterInfo.h Wed Jan 30 21:37:28 2008
@@ -27,7 +27,6 @@
 class BitVector;
 class MachineFunction;
 class MachineInstr;
-class MachineLocation;
 class MachineMove;
 class RegScavenger;
 class SDNode;
@@ -586,18 +585,15 @@
   /// getFrameRegister - This method should return the register used as a base
   /// for values allocated in the current stack frame.
   virtual unsigned getFrameRegister(MachineFunction &MF) const = 0;
-  
+
+  /// getFrameIndexOffset - Returns the displacement from the frame register to
+  /// the stack frame of the specified index.
+  virtual int getFrameIndexOffset(MachineFunction &MF, unsigned FI) const;
+                           
   /// getRARegister - This method should return the register where the return
   /// address can be found.
   virtual unsigned getRARegister() const = 0;
   
-  /// 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 call MRegisterInfo::getLocation for the default action.
-  virtual void getLocation(MachineFunction &MF, unsigned Index,
-                           MachineLocation &ML) const;
-                           
   /// getInitialFrameState - Returns a list of machine moves that are assumed
   /// on entry to all functions.  Note that LabelID is ignored (assumed to be
   /// the beginning of the function.)

Modified: llvm/trunk/lib/CodeGen/DwarfWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/DwarfWriter.cpp?rev=46597&r1=46596&r2=46597&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/DwarfWriter.cpp (original)
+++ llvm/trunk/lib/CodeGen/DwarfWriter.cpp Wed Jan 30 21:37:28 2008
@@ -1875,7 +1875,8 @@
     
     // Add variable address.
     MachineLocation Location;
-    RI->getLocation(*MF, DV->getFrameIndex(), Location);
+    Location.set(RI->getFrameRegister(*MF),
+                 RI->getFrameIndexOffset(*MF, DV->getFrameIndex()));
     AddAddress(VariableDie, DW_AT_location, Location);
 
     return VariableDie;

Modified: llvm/trunk/lib/Target/MRegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MRegisterInfo.cpp?rev=46597&r1=46596&r2=46597&view=diff

==============================================================================
--- llvm/trunk/lib/Target/MRegisterInfo.cpp (original)
+++ llvm/trunk/lib/Target/MRegisterInfo.cpp Wed Jan 30 21:37:28 2008
@@ -16,7 +16,6 @@
 #include "llvm/Target/TargetFrameInfo.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
-#include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/ADT/BitVector.h"
 
 using namespace llvm;
@@ -72,19 +71,14 @@
   return Allocatable;
 }
 
-/// 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 {
+/// getFrameIndexOffset - Returns the displacement from the frame register to
+/// the stack frame of the specified index. This is the default implementation
+/// which is likely incorrect for the target.
+int MRegisterInfo::getFrameIndexOffset(MachineFunction &MF, unsigned FI) const {
   const TargetFrameInfo &TFI = *MF.getTarget().getFrameInfo();
   MachineFrameInfo *MFI = MF.getFrameInfo();
-  ML.set(getFrameRegister(MF),
-         MFI->getObjectOffset(Index) +
-         MFI->getStackSize() -
-         TFI.getOffsetOfLocalArea() +
-         MFI->getOffsetAdjustment());
+  return MFI->getObjectOffset(FI) + MFI->getStackSize() -
+    TFI.getOffsetOfLocalArea() + MFI->getOffsetAdjustment();
 }
 
 /// getInitialFrameState - Returns a list of machine moves that are assumed





More information about the llvm-commits mailing list