aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Target/MRegisterInfo.h12
-rw-r--r--lib/Target/Alpha/AlphaRegisterInfo.cpp12
-rw-r--r--lib/Target/Alpha/AlphaRegisterInfo.h4
-rw-r--r--lib/Target/IA64/IA64RegisterInfo.cpp13
-rw-r--r--lib/Target/IA64/IA64RegisterInfo.h3
-rw-r--r--lib/Target/MRegisterInfo.cpp16
-rw-r--r--lib/Target/PowerPC/PPCRegisterInfo.cpp11
-rw-r--r--lib/Target/PowerPC/PPCRegisterInfo.h4
-rw-r--r--lib/Target/Sparc/SparcRegisterInfo.cpp11
-rw-r--r--lib/Target/Sparc/SparcRegisterInfo.h4
-rw-r--r--lib/Target/SparcV9/SparcV9RegisterInfo.cpp4
-rw-r--r--lib/Target/SparcV9/SparcV9RegisterInfo.h5
-rw-r--r--lib/Target/X86/X86RegisterInfo.cpp11
-rw-r--r--lib/Target/X86/X86RegisterInfo.h4
14 files changed, 52 insertions, 62 deletions
diff --git a/include/llvm/Target/MRegisterInfo.h b/include/llvm/Target/MRegisterInfo.h
index 21fc41795a..e69661b228 100644
--- a/include/llvm/Target/MRegisterInfo.h
+++ b/include/llvm/Target/MRegisterInfo.h
@@ -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
diff --git a/lib/Target/Alpha/AlphaRegisterInfo.cpp b/lib/Target/Alpha/AlphaRegisterInfo.cpp
index fee062f84c..d2a398465b 100644
--- a/lib/Target/Alpha/AlphaRegisterInfo.cpp
+++ b/lib/Target/Alpha/AlphaRegisterInfo.cpp
@@ -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"
diff --git a/lib/Target/Alpha/AlphaRegisterInfo.h b/lib/Target/Alpha/AlphaRegisterInfo.h
index d07ee9006a..161a826856 100644
--- a/lib/Target/Alpha/AlphaRegisterInfo.h
+++ b/lib/Target/Alpha/AlphaRegisterInfo.h
@@ -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);
};
diff --git a/lib/Target/IA64/IA64RegisterInfo.cpp b/lib/Target/IA64/IA64RegisterInfo.cpp
index c8d6f0fdf5..b1e681d9b4 100644
--- a/lib/Target/IA64/IA64RegisterInfo.cpp
+++ b/lib/Target/IA64/IA64RegisterInfo.cpp
@@ -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"
diff --git a/lib/Target/IA64/IA64RegisterInfo.h b/lib/Target/IA64/IA64RegisterInfo.h
index d33a9e6c1d..328b415573 100644
--- a/lib/Target/IA64/IA64RegisterInfo.h
+++ b/lib/Target/IA64/IA64RegisterInfo.h
@@ -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
diff --git a/lib/Target/MRegisterInfo.cpp b/lib/Target/MRegisterInfo.cpp
index 790f95f081..558783aedc 100644
--- a/lib/Target/MRegisterInfo.cpp
+++ b/lib/Target/MRegisterInfo.cpp
@@ -12,6 +12,11 @@
//===----------------------------------------------------------------------===//
#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());
+}
diff --git a/lib/Target/PowerPC/PPCRegisterInfo.cpp b/lib/Target/PowerPC/PPCRegisterInfo.cpp
index 984d5e23fd..679b233bc6 100644
--- a/lib/Target/PowerPC/PPCRegisterInfo.cpp
+++ b/lib/Target/PowerPC/PPCRegisterInfo.cpp
@@ -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"
diff --git a/lib/Target/PowerPC/PPCRegisterInfo.h b/lib/Target/PowerPC/PPCRegisterInfo.h
index dce149bffc..d05bc70c11 100644
--- a/lib/Target/PowerPC/PPCRegisterInfo.h
+++ b/lib/Target/PowerPC/PPCRegisterInfo.h
@@ -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
diff --git a/lib/Target/Sparc/SparcRegisterInfo.cpp b/lib/Target/Sparc/SparcRegisterInfo.cpp
index cbeb87fa54..44f3adce04 100644
--- a/lib/Target/Sparc/SparcRegisterInfo.cpp
+++ b/lib/Target/Sparc/SparcRegisterInfo.cpp
@@ -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"
diff --git a/lib/Target/Sparc/SparcRegisterInfo.h b/lib/Target/Sparc/SparcRegisterInfo.h
index 53d3e6fdba..d36b3c1eed 100644
--- a/lib/Target/Sparc/SparcRegisterInfo.h
+++ b/lib/Target/Sparc/SparcRegisterInfo.h
@@ -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
diff --git a/lib/Target/SparcV9/SparcV9RegisterInfo.cpp b/lib/Target/SparcV9/SparcV9RegisterInfo.cpp
index db0b9fd95c..267d69a4f7 100644
--- a/lib/Target/SparcV9/SparcV9RegisterInfo.cpp
+++ b/lib/Target/SparcV9/SparcV9RegisterInfo.cpp
@@ -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;
}
diff --git a/lib/Target/SparcV9/SparcV9RegisterInfo.h b/lib/Target/SparcV9/SparcV9RegisterInfo.h
index 4144b84dc5..6de47cbb62 100644
--- a/lib/Target/SparcV9/SparcV9RegisterInfo.h
+++ b/lib/Target/SparcV9/SparcV9RegisterInfo.h
@@ -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
diff --git a/lib/Target/X86/X86RegisterInfo.cpp b/lib/Target/X86/X86RegisterInfo.cpp
index 99e36eb369..97d73cf05c 100644
--- a/lib/Target/X86/X86RegisterInfo.cpp
+++ b/lib/Target/X86/X86RegisterInfo.cpp
@@ -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"
diff --git a/lib/Target/X86/X86RegisterInfo.h b/lib/Target/X86/X86RegisterInfo.h
index db0fbbb3aa..998fb398d9 100644
--- a/lib/Target/X86/X86RegisterInfo.h
+++ b/lib/Target/X86/X86RegisterInfo.h
@@ -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