mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-04-12 07:37:34 +00:00
Expose base register for DwarfWriter. Refactor code accordingly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27225 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
bf7637d590
commit
a99791886d
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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);
|
||||
};
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user