mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-17 15:38:40 +00:00
Start allocating stack space at [ebp-4] to not overwrite the return address.
Also make all loads & stores 4-byte aligned for performance. ;) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4982 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
07e376bd0d
commit
cea2245f04
@ -50,13 +50,15 @@ namespace {
|
|||||||
|
|
||||||
RegAllocSimple(TargetMachine &tm) : TM(tm), CurrMBB(0), maxOffset(0),
|
RegAllocSimple(TargetMachine &tm) : TM(tm), CurrMBB(0), maxOffset(0),
|
||||||
RegInfo(tm.getRegisterInfo()),
|
RegInfo(tm.getRegisterInfo()),
|
||||||
NumBytesAllocated(0), ByteAlignment(4)
|
ByteAlignment(4)
|
||||||
{
|
{
|
||||||
// build reverse mapping for physReg -> register class
|
// build reverse mapping for physReg -> register class
|
||||||
RegInfo->buildReg2RegClassMap(PhysReg2RegClassMap);
|
RegInfo->buildReg2RegClassMap(PhysReg2RegClassMap);
|
||||||
|
|
||||||
RegsUsed[RegInfo->getFramePointer()] = 1;
|
RegsUsed[RegInfo->getFramePointer()] = 1;
|
||||||
RegsUsed[RegInfo->getStackPointer()] = 1;
|
RegsUsed[RegInfo->getStackPointer()] = 1;
|
||||||
|
|
||||||
|
cleanupAfterFunction();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isAvailableReg(unsigned Reg) {
|
bool isAvailableReg(unsigned Reg) {
|
||||||
@ -80,7 +82,7 @@ namespace {
|
|||||||
void cleanupAfterFunction() {
|
void cleanupAfterFunction() {
|
||||||
RegMap.clear();
|
RegMap.clear();
|
||||||
SSA2PhysRegMap.clear();
|
SSA2PhysRegMap.clear();
|
||||||
NumBytesAllocated = 0;
|
NumBytesAllocated = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Moves value from memory into that register
|
/// Moves value from memory into that register
|
||||||
@ -112,6 +114,7 @@ unsigned RegAllocSimple::allocateStackSpaceFor(unsigned VirtReg,
|
|||||||
const TargetRegisterClass *regClass)
|
const TargetRegisterClass *regClass)
|
||||||
{
|
{
|
||||||
if (RegMap.find(VirtReg) == RegMap.end()) {
|
if (RegMap.find(VirtReg) == RegMap.end()) {
|
||||||
|
#if 0
|
||||||
unsigned size = regClass->getDataSize();
|
unsigned size = regClass->getDataSize();
|
||||||
unsigned over = NumBytesAllocated - (NumBytesAllocated % ByteAlignment);
|
unsigned over = NumBytesAllocated - (NumBytesAllocated % ByteAlignment);
|
||||||
if (size >= ByteAlignment - over) {
|
if (size >= ByteAlignment - over) {
|
||||||
@ -120,6 +123,10 @@ unsigned RegAllocSimple::allocateStackSpaceFor(unsigned VirtReg,
|
|||||||
}
|
}
|
||||||
RegMap[VirtReg] = NumBytesAllocated;
|
RegMap[VirtReg] = NumBytesAllocated;
|
||||||
NumBytesAllocated += size;
|
NumBytesAllocated += size;
|
||||||
|
#endif
|
||||||
|
// FIXME: forcing each arg to take 4 bytes on the stack
|
||||||
|
RegMap[VirtReg] = NumBytesAllocated;
|
||||||
|
NumBytesAllocated += 4;
|
||||||
}
|
}
|
||||||
return RegMap[VirtReg];
|
return RegMap[VirtReg];
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user