Expose base register for DwarfWriter. Refactor code accordingly.
authorJim Laskey <jlaskey@mac.com>
Tue, 28 Mar 2006 13:48:33 +0000 (13:48 +0000)
committerJim Laskey <jlaskey@mac.com>
Tue, 28 Mar 2006 13:48:33 +0000 (13:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27225 91177308-0d34-0410-b5e6-96231b3b80d8

14 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/MRegisterInfo.cpp
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 21fc41795a2f325756297a83e908e1a9759a647f..e69661b2282fa0365e3801f1f4bb6d8fe2745e36 100644 (file)
@@ -343,10 +343,20 @@ public:
   virtual void emitEpilogue(MachineFunction &MF,
                             MachineBasicBlock &MBB) const = 0;
                             
+  //===--------------------------------------------------------------------===//
+  /// Debug information queries.
+
+  /// getFrameRegister - This method should return the register used as a base
+  /// for values allocated in the current stack frame.  This value should be
+  /// returned as a dwarf register number (getDwarfRegNum.)
+  virtual unsigned getFrameRegister(MachineFunction &MF) 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 = 0;
+                           MachineLocation &ML) const;
 };
 
 // This is useful when building DenseMaps keyed on virtual registers
index fee062f84c106b5ae27ad50bedb527eed17cb359..d2a398465b0b5b045970dfa64a65d4d31ce3697b 100644 (file)
@@ -354,16 +354,8 @@ 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(getDwarfRegNum(FP ? Alpha::R15 : Alpha::R30),
-         MFI->getObjectOffset(Index) + MFI->getStackSize());
+unsigned AlphaRegisterInfo::getFrameRegister(MachineFunction &MF) const {
+  return getDwarfRegNum(hasFP(MF) ? Alpha::R15 : Alpha::R30);
 }
 
 #include "AlphaGenRegisterInfo.inc"
index d07ee9006a9776f048c9257dccfed5c44fc67626..161a8268568a1e6c87afa47327b6b77f2c88c090 100644 (file)
@@ -53,8 +53,8 @@ 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;
-
+   // Debug information queries.
+  unsigned getFrameRegister(MachineFunction &MF) const;
 
   static std::string getPrettyName(unsigned reg);
 };
index c8d6f0fdf5f4734515daedb4b6525c37034f1121..b1e681d9b432cf28feacc8b5d44ff9813ce57107 100644 (file)
@@ -329,18 +329,9 @@ 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(getDwarfRegNum(FP ? IA64::r5 : IA64::r12),
-         MFI->getObjectOffset(Index) + MFI->getStackSize());
+unsigned IA64RegisterInfo::getFrameRegister(MachineFunction &MF) const {
+  return getDwarfRegNum(hasFP(MF) ? IA64::r5 : IA64::r12);
 }
 
-
 #include "IA64GenRegisterInfo.inc"
 
index d33a9e6c1d31a2b0d83918708bf2b2e41fca2dfc..328b415573709179a95b53173993f6626718db53 100644 (file)
@@ -49,7 +49,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;
+  // Debug information queries.
+  unsigned getFrameRegister(MachineFunction &MF) const;
 };
 
 } // End llvm namespace
index 790f95f081bb88607ff76767f938e41da57580f6..558783aedc4780c9f35b4a2c9090efa5d28bd72d 100644 (file)
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Target/MRegisterInfo.h"
+
+#include "llvm/CodeGen/MachineFunction.h"
+#include "llvm/CodeGen/MachineFrameInfo.h"
+#include "llvm/CodeGen/MachineLocation.h"
+
 using namespace llvm;
 
 MRegisterInfo::MRegisterInfo(const TargetRegisterDesc *D, unsigned NR,
@@ -38,3 +43,14 @@ std::vector<bool> MRegisterInfo::getAllocatableSet(MachineFunction &MF) const {
   }
   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 {
+  MachineFrameInfo *MFI = MF.getFrameInfo();
+  ML.set(getFrameRegister(MF),
+         MFI->getObjectOffset(Index) + MFI->getStackSize());
+}
index 984d5e23fd89b28fde7027133eabbcacfba39c11..679b233bc684907ed8a1122a7a7726f9c4999679 100644 (file)
@@ -447,15 +447,8 @@ 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(getDwarfRegNum(FP ? PPC::R31 : PPC::R1),
-         MFI->getObjectOffset(Index) + MFI->getStackSize());
+unsigned PPCRegisterInfo::getFrameRegister(MachineFunction &MF) const {
+  return getDwarfRegNum(hasFP(MF) ? PPC::R31 : PPC::R1);
 }
 
 #include "PPCGenRegisterInfo.inc"
index dce149bffce752b4e8aaae0ffdc18c2b18e26a0e..d05bc70c11d04e0159aedf36bea319973281ec33 100644 (file)
@@ -56,8 +56,8 @@ public:
   void emitPrologue(MachineFunction &MF) const;
   void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
 
-  void getLocation(MachineFunction &MF, unsigned Index,
-                   MachineLocation &ML) const;
+  // Debug information queries.
+  unsigned getFrameRegister(MachineFunction &MF) const;
 };
 
 } // end namespace llvm
index cbeb87fa54e481b5bb36d6598e3096812ff6fe7d..44f3adce043372277e1dad47cb128cfd92930d65 100644 (file)
@@ -200,15 +200,8 @@ 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(getDwarfRegNum(SP::G1),
-         MFI->getObjectOffset(Index) + MFI->getStackSize());
+unsigned SparcRegisterInfo::getFrameRegister(MachineFunction &MF) const {
+  return getDwarfRegNum(SP::G1);
 }
 
 #include "SparcGenRegisterInfo.inc"
index 53d3e6fdba069f584457162d8a024a1b42ba71eb..d36b3c1eed099ec0ded57899ab9dfeae707d31a6 100644 (file)
@@ -57,8 +57,8 @@ 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;
+  // Debug information queries.
+  unsigned getFrameRegister(MachineFunction &MF) const;
 };
 
 } // end namespace llvm
index db0b9fd95c71f935e296703c6728ff8123774758..267d69a4f76d2ae56da0410bda26c43f5a956527 100644 (file)
@@ -318,7 +318,7 @@ void SparcV9RegisterInfo::emitEpilogue(MachineFunction &MF,
 }
 
 
-void SparcV9RegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
-                                      MachineLocation &ML) const {
+unsigned SparcV9RegisterInfo::getFrameRegister(MachineFunction &MF) const {
   abort ();
+  return 0;
 }
index 4144b84dc5725d858a4d1d21b00b567c16ed7261..6de47cbb6296fbcffc00061fdba70181c5c47936 100644 (file)
@@ -44,8 +44,9 @@ 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;
+  
+  // Debug information queries.
+  unsigned getFrameRegister(MachineFunction &MF) const;
 };
 
 } // End llvm namespace
index 99e36eb36908dcbb9638134ba3caff36ad19ac79..97d73cf05cf86c733c7f1b73d0dfd611bbb87d5a 100644 (file)
@@ -686,15 +686,8 @@ 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(getDwarfRegNum(FP ? X86::EBP : X86::ESP),
-         MFI->getObjectOffset(Index) + MFI->getStackSize());
+unsigned X86RegisterInfo::getFrameRegister(MachineFunction &MF) const {
+  return getDwarfRegNum(hasFP(MF) ? X86::EBP : X86::ESP);
 }
 
 #include "X86GenRegisterInfo.inc"
index db0fbbb3aa3858fd7f10be915c50e792e80e9315..998fb398d911fa4e345ee0e34981fdab49da51aa 100644 (file)
@@ -63,8 +63,8 @@ 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;
+  // Debug information queries.
+  unsigned getFrameRegister(MachineFunction &MF) const;
 };
 
 } // End llvm namespace