diff --git a/include/llvm/Target/MRegisterInfo.h b/include/llvm/Target/MRegisterInfo.h index a7ce2dc1114..cbd6e0fa32f 100644 --- a/include/llvm/Target/MRegisterInfo.h +++ b/include/llvm/Target/MRegisterInfo.h @@ -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 diff --git a/lib/Target/Alpha/AlphaRegisterInfo.cpp b/lib/Target/Alpha/AlphaRegisterInfo.cpp index 31b20da3929..f5c6dd67f54 100644 --- a/lib/Target/Alpha/AlphaRegisterInfo.cpp +++ b/lib/Target/Alpha/AlphaRegisterInfo.cpp @@ -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) diff --git a/lib/Target/Alpha/AlphaRegisterInfo.h b/lib/Target/Alpha/AlphaRegisterInfo.h index 0ad04b44ea8..d07ee9006a9 100644 --- a/lib/Target/Alpha/AlphaRegisterInfo.h +++ b/lib/Target/Alpha/AlphaRegisterInfo.h @@ -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); }; diff --git a/lib/Target/IA64/IA64RegisterInfo.cpp b/lib/Target/IA64/IA64RegisterInfo.cpp index d612efc29d2..f6d9941f8e6 100644 --- a/lib/Target/IA64/IA64RegisterInfo.cpp +++ b/lib/Target/IA64/IA64RegisterInfo.cpp @@ -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" diff --git a/lib/Target/IA64/IA64RegisterInfo.h b/lib/Target/IA64/IA64RegisterInfo.h index f1b2222ce32..d33a9e6c1d3 100644 --- a/lib/Target/IA64/IA64RegisterInfo.h +++ b/lib/Target/IA64/IA64RegisterInfo.h @@ -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 diff --git a/lib/Target/PowerPC/PPCRegisterInfo.cpp b/lib/Target/PowerPC/PPCRegisterInfo.cpp index 2df31e81b6b..6b281bd2d8b 100644 --- a/lib/Target/PowerPC/PPCRegisterInfo.cpp +++ b/lib/Target/PowerPC/PPCRegisterInfo.cpp @@ -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" diff --git a/lib/Target/PowerPC/PPCRegisterInfo.h b/lib/Target/PowerPC/PPCRegisterInfo.h index e5a94f0ff6f..dce149bffce 100644 --- a/lib/Target/PowerPC/PPCRegisterInfo.h +++ b/lib/Target/PowerPC/PPCRegisterInfo.h @@ -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 diff --git a/lib/Target/Sparc/SparcRegisterInfo.cpp b/lib/Target/Sparc/SparcRegisterInfo.cpp index ff9c5a3ec3b..21a0cd85d89 100644 --- a/lib/Target/Sparc/SparcRegisterInfo.cpp +++ b/lib/Target/Sparc/SparcRegisterInfo.cpp @@ -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 @@ -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" diff --git a/lib/Target/Sparc/SparcRegisterInfo.h b/lib/Target/Sparc/SparcRegisterInfo.h index d26e5bd3766..53d3e6fdba0 100644 --- a/lib/Target/Sparc/SparcRegisterInfo.h +++ b/lib/Target/Sparc/SparcRegisterInfo.h @@ -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 diff --git a/lib/Target/SparcV9/SparcV9RegisterInfo.cpp b/lib/Target/SparcV9/SparcV9RegisterInfo.cpp index 0ef9d34365f..db0b9fd95c7 100644 --- a/lib/Target/SparcV9/SparcV9RegisterInfo.cpp +++ b/lib/Target/SparcV9/SparcV9RegisterInfo.cpp @@ -316,3 +316,9 @@ void SparcV9RegisterInfo::emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const { abort (); } + + +void SparcV9RegisterInfo::getLocation(MachineFunction &MF, unsigned Index, + MachineLocation &ML) const { + abort (); +} diff --git a/lib/Target/SparcV9/SparcV9RegisterInfo.h b/lib/Target/SparcV9/SparcV9RegisterInfo.h index a284898f6ab..4144b84dc57 100644 --- a/lib/Target/SparcV9/SparcV9RegisterInfo.h +++ b/lib/Target/SparcV9/SparcV9RegisterInfo.h @@ -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 diff --git a/lib/Target/X86/X86RegisterInfo.cpp b/lib/Target/X86/X86RegisterInfo.cpp index 66096b9845a..88aa0155d15 100644 --- a/lib/Target/X86/X86RegisterInfo.cpp +++ b/lib/Target/X86/X86RegisterInfo.cpp @@ -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" diff --git a/lib/Target/X86/X86RegisterInfo.h b/lib/Target/X86/X86RegisterInfo.h index 35654ca832f..db0fbbb3aa3 100644 --- a/lib/Target/X86/X86RegisterInfo.h +++ b/lib/Target/X86/X86RegisterInfo.h @@ -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