Add support to locate local variables in frames (early version.)
authorJim Laskey <jlaskey@mac.com>
Thu, 23 Mar 2006 18:12:57 +0000 (18:12 +0000)
committerJim Laskey <jlaskey@mac.com>
Thu, 23 Mar 2006 18:12:57 +0000 (18:12 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26994 91177308-0d34-0410-b5e6-96231b3b80d8

13 files changed:
include/llvm/Target/MRegisterInfo.h
lib/Target/Alpha/AlphaRegisterInfo.cpp
lib/Target/Alpha/AlphaRegisterInfo.h
lib/Target/IA64/IA64RegisterInfo.cpp
lib/Target/IA64/IA64RegisterInfo.h
lib/Target/PowerPC/PPCRegisterInfo.cpp
lib/Target/PowerPC/PPCRegisterInfo.h
lib/Target/Sparc/SparcRegisterInfo.cpp
lib/Target/Sparc/SparcRegisterInfo.h
lib/Target/SparcV9/SparcV9RegisterInfo.cpp
lib/Target/SparcV9/SparcV9RegisterInfo.h
lib/Target/X86/X86RegisterInfo.cpp
lib/Target/X86/X86RegisterInfo.h

index a7ce2dc111486eaa3fefc28f70313acadf6cc13a..cbd6e0fa32f329394f5af8d14716fc31bdba8048 100644 (file)
@@ -26,6 +26,7 @@ namespace llvm {
 class Type;
 class MachineFunction;
 class MachineInstr;
+class MachineLocation;
 class TargetRegisterClass;
 
 /// TargetRegisterDesc - This record contains all of the information known about
@@ -341,6 +342,11 @@ public:
   virtual void emitPrologue(MachineFunction &MF) const = 0;
   virtual void emitEpilogue(MachineFunction &MF,
                             MachineBasicBlock &MBB) const = 0;
+                            
+  /// getLocation - This method should return the actual location of a frame
+  /// variable given the frame index.
+  virtual void getLocation(MachineFunction &MF, unsigned Index,
+                          MachineLocation &ML) const = 0;
 };
 
 // This is useful when building DenseMaps keyed on virtual registers
index 31b20da39296bc2df4f2e81584d71884fb041ecb..f5c6dd67f54a9681614259551828c562dc5d30af 100644 (file)
@@ -21,6 +21,7 @@
 #include "llvm/CodeGen/MachineInstrBuilder.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
+#include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/Target/TargetFrameInfo.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetOptions.h"
@@ -353,6 +354,18 @@ void AlphaRegisterInfo::emitEpilogue(MachineFunction &MF,
      }
 }
 
+void AlphaRegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
+                                    MachineLocation &ML) const {
+  assert(0 && "Needs to be defined for target");
+  MachineFrameInfo *MFI = MF.getFrameInfo();
+  bool FP = hasFP(MF);
+  
+  // FIXME - Needs to handle register variables.
+  // FIXME - Faking that llvm number is same as gcc numbering.
+  ML.set((FP ? Alpha::R15 : Alpha::R30) - Alpha::R0,
+         MFI->getObjectOffset(Index) + MFI->getStackSize());
+}
+
 #include "AlphaGenRegisterInfo.inc"
 
 std::string AlphaRegisterInfo::getPrettyName(unsigned reg)
index 0ad04b44ea88013c5f2d16e7c92c52c9c1b3657a..d07ee9006a9776f048c9257dccfed5c44fc67626 100644 (file)
@@ -53,6 +53,9 @@ struct AlphaRegisterInfo : public AlphaGenRegisterInfo {
   void emitPrologue(MachineFunction &MF) const;
   void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
 
+  void getLocation(MachineFunction &MF, unsigned Index, MachineLocation &ML) const;
+
+
   static std::string getPrettyName(unsigned reg);
 };
 
index d612efc29d2f9ff30496ffb424a6bc422c309764..f6d9941f8e6d8893006345084a60233fc4bef692 100644 (file)
@@ -22,6 +22,7 @@
 #include "llvm/CodeGen/MachineInstrBuilder.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
+#include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/Target/TargetFrameInfo.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetOptions.h"
@@ -328,5 +329,18 @@ void IA64RegisterInfo::emitEpilogue(MachineFunction &MF,
 
 }
 
+void IA64RegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
+                                   MachineLocation &ML) const {
+  assert(0 && "Needs to be defined for target");
+  MachineFrameInfo *MFI = MF.getFrameInfo();
+  bool FP = hasFP(MF);
+  
+  // FIXME - Needs to handle register variables.
+  // FIXME - Faking that llvm number is same as gcc numbering.
+  ML.set((FP ? IA64::r5 : IA64::r12) - IA64::r0,
+         MFI->getObjectOffset(Index) + MFI->getStackSize());
+}
+
+
 #include "IA64GenRegisterInfo.inc"
 
index f1b2222ce327525aab736f628b71599050a2f55f..d33a9e6c1d31a2b0d83918708bf2b2e41fca2dfc 100644 (file)
@@ -48,6 +48,8 @@ struct IA64RegisterInfo : public IA64GenRegisterInfo {
 
   void emitPrologue(MachineFunction &MF) const;
   void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
+
+  void getLocation(MachineFunction &MF, unsigned Index, MachineLocation &ML) const;
 };
 
 } // End llvm namespace
index 2df31e81b6b807267161227ae3fd23ecf8450457..6b281bd2d8be3db2f8e426fcf52522fbc3b2a6ac 100644 (file)
@@ -21,6 +21,7 @@
 #include "llvm/CodeGen/MachineInstrBuilder.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
+#include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/Target/TargetFrameInfo.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetOptions.h"
@@ -446,5 +447,16 @@ void PPCRegisterInfo::emitEpilogue(MachineFunction &MF,
   }
 }
 
+void PPCRegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
+                                  MachineLocation &ML) const {
+  MachineFrameInfo *MFI = MF.getFrameInfo();
+  bool FP = hasFP(MF);
+  
+  // FIXME - Needs to handle register variables.
+  // FIXME - Faking that llvm number is same as gcc numbering.
+  ML.set((FP ? PPC::R31 : PPC::R1) - PPC::R0,
+         MFI->getObjectOffset(Index) + MFI->getStackSize());
+}
+
 #include "PPCGenRegisterInfo.inc"
 
index e5a94f0ff6f9c6f350712178e9ccfd198e65d951..dce149bffce752b4e8aaae0ffdc18c2b18e26a0e 100644 (file)
@@ -55,6 +55,9 @@ public:
 
   void emitPrologue(MachineFunction &MF) const;
   void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
+
+  void getLocation(MachineFunction &MF, unsigned Index,
+                   MachineLocation &ML) const;
 };
 
 } // end namespace llvm
index ff9c5a3ec3bdf22cf6333244c23671cdcdac6c6f..21a0cd85d8954cc2dd093b1dfd5ab9b05efbb9dc 100644 (file)
@@ -17,6 +17,7 @@
 #include "llvm/CodeGen/MachineInstrBuilder.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
+#include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/Type.h"
 #include "llvm/ADT/STLExtras.h"
 #include <iostream>
@@ -199,5 +200,16 @@ void SparcRegisterInfo::emitEpilogue(MachineFunction &MF,
   BuildMI(MBB, MBBI, SP::RESTORErr, 2, SP::G0).addReg(SP::G0).addReg(SP::G0);
 }
 
+void SparcRegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
+                                  MachineLocation &ML) const {
+  assert(0 && "Needs to be defined for target");
+  MachineFrameInfo *MFI = MF.getFrameInfo();
+  
+  // FIXME - Needs to handle register variables.
+  // FIXME - Faking that llvm number is same as gcc numbering.
+  ML.set(SP::G1 - SP::G0,
+         MFI->getObjectOffset(Index) + MFI->getStackSize());
+}
+
 #include "SparcGenRegisterInfo.inc"
 
index d26e5bd37662a9944033e05f3d36386d94da6946..53d3e6fdba069f584457162d8a024a1b42ba71eb 100644 (file)
@@ -56,6 +56,9 @@ struct SparcRegisterInfo : public SparcGenRegisterInfo {
 
   void emitPrologue(MachineFunction &MF) const;
   void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
+  
+  void getLocation(MachineFunction &MF, unsigned Index,
+                   MachineLocation &ML) const;
 };
 
 } // end namespace llvm
index 0ef9d34365f1863aae7971a612f0f9cfaca0a223..db0b9fd95c71f935e296703c6728ff8123774758 100644 (file)
@@ -316,3 +316,9 @@ void SparcV9RegisterInfo::emitEpilogue(MachineFunction &MF,
                                        MachineBasicBlock &MBB) const {
   abort ();
 }
+
+
+void SparcV9RegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
+                                      MachineLocation &ML) const {
+  abort ();
+}
index a284898f6abab2864633c6cc995ed7913447a273..4144b84dc5725d858a4d1d21b00b567c16ed7261 100644 (file)
@@ -44,6 +44,8 @@ struct SparcV9RegisterInfo : public MRegisterInfo {
   void eliminateFrameIndex (MachineBasicBlock::iterator MI) const;
   void emitPrologue (MachineFunction &MF) const;
   void emitEpilogue (MachineFunction &MF, MachineBasicBlock &MBB) const;
+  void getLocation(MachineFunction &MF, unsigned Index,
+                   MachineLocation &ML) const;
 };
 
 } // End llvm namespace
index 66096b9845a5d3c9fa81c741f9f92950cd4e44de..88aa0155d1563d7f9474db9de0b01ceee0019cb0 100644 (file)
@@ -21,6 +21,7 @@
 #include "llvm/CodeGen/MachineInstrBuilder.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
+#include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/Target/TargetFrameInfo.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetOptions.h"
@@ -685,5 +686,16 @@ void X86RegisterInfo::emitEpilogue(MachineFunction &MF,
   }
 }
 
+void X86RegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
+                                  MachineLocation &ML) const {
+  MachineFrameInfo *MFI = MF.getFrameInfo();
+  bool FP = hasFP(MF);
+  
+  // FIXME - Needs to handle register variables.
+  // FIXME - Hardcoding gcc numbering.
+  ML.set(FP ? 6 : 7,
+         MFI->getObjectOffset(Index) + MFI->getStackSize());
+}
+
 #include "X86GenRegisterInfo.inc"
 
index 35654ca832f71c5182c93a0732a628abcae11a32..db0fbbb3aa3858fd7f10be915c50e792e80e9315 100644 (file)
@@ -62,6 +62,9 @@ struct X86RegisterInfo : public X86GenRegisterInfo {
 
   void emitPrologue(MachineFunction &MF) const;
   void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
+
+  void getLocation(MachineFunction &MF, unsigned Index,
+                   MachineLocation &ML) const;
 };
 
 } // End llvm namespace