forked from OSchip/llvm-project
Add support to locate local variables in frames (early version.)
llvm-svn: 26994
This commit is contained in:
parent
8f64426f5c
commit
3c43609f1f
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -316,3 +316,9 @@ void SparcV9RegisterInfo::emitEpilogue(MachineFunction &MF,
|
|||
MachineBasicBlock &MBB) const {
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
void SparcV9RegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
|
||||
MachineLocation &ML) const {
|
||||
abort ();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue