diff options
author | Chris Lattner <sabre@nondot.org> | 2002-12-15 19:07:34 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-12-15 19:07:34 +0000 |
commit | 9593fb1503067c16b4e21dd2b8af676d64ca0440 (patch) | |
tree | 141a39f9242946492d0d5baf3eda38fb0f1ec491 /lib/CodeGen/RegAllocSimple.cpp | |
parent | 439b76730d40e8a8a95f2231bce95ff211a95ead (diff) | |
download | external_llvm-9593fb1503067c16b4e21dd2b8af676d64ca0440.zip external_llvm-9593fb1503067c16b4e21dd2b8af676d64ca0440.tar.gz external_llvm-9593fb1503067c16b4e21dd2b8af676d64ca0440.tar.bz2 |
* Remove some unneccesary instance variables
* Make allocateStackSpaceFor only allocate the right amount of space
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5048 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/RegAllocSimple.cpp')
-rw-r--r-- | lib/CodeGen/RegAllocSimple.cpp | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/lib/CodeGen/RegAllocSimple.cpp b/lib/CodeGen/RegAllocSimple.cpp index 4745e11..978e927 100644 --- a/lib/CodeGen/RegAllocSimple.cpp +++ b/lib/CodeGen/RegAllocSimple.cpp @@ -38,11 +38,9 @@ public: namespace { struct RegAllocSimple : public FunctionPass { TargetMachine &TM; - MachineBasicBlock *CurrMBB; MachineFunction *MF; - unsigned maxOffset; const MRegisterInfo *RegInfo; - unsigned NumBytesAllocated, ByteAlignment; + unsigned NumBytesAllocated; // Maps SSA Regs => offsets on the stack where these values are stored std::map<unsigned, unsigned> VirtReg2OffsetMap; @@ -62,9 +60,8 @@ namespace { std::map<unsigned, unsigned> RegsUsed; std::map<const TargetRegisterClass*, unsigned> RegClassIdx; - RegAllocSimple(TargetMachine &tm) : TM(tm), CurrMBB(0), maxOffset(0), + RegAllocSimple(TargetMachine &tm) : TM(tm), RegInfo(tm.getRegisterInfo()), - ByteAlignment(4), PhysRegClasses(RegInfo) { RegsUsed[RegInfo->getFramePointer()] = 1; @@ -109,7 +106,7 @@ namespace { void cleanupAfterFunction() { VirtReg2OffsetMap.clear(); SSA2PhysRegMap.clear(); - NumBytesAllocated = ByteAlignment; + NumBytesAllocated = 4; /* FIXME: This is X86 specific */ } /// Moves value from memory into that register @@ -144,19 +141,19 @@ unsigned RegAllocSimple::allocateStackSpaceFor(unsigned VirtReg, const TargetRegisterClass *regClass) { if (VirtReg2OffsetMap.find(VirtReg) == VirtReg2OffsetMap.end()) { -#if 0 - unsigned size = regClass->getDataSize(); - unsigned over = NumBytesAllocated - (NumBytesAllocated % ByteAlignment); - if (size >= ByteAlignment - over) { - // need to pad by (ByteAlignment - over) - NumBytesAllocated += ByteAlignment - over; - } - VirtReg2OffsetMap[VirtReg] = NumBytesAllocated; - NumBytesAllocated += size; -#endif - // FIXME: forcing each arg to take 4 bytes on the stack + unsigned RegSize = regClass->getDataSize(); + + // Align NumBytesAllocated. We should be using TargetData alignment stuff + // to determine this, but we don't know the LLVM type associated with the + // virtual register. Instead, just align to a multiple of the size for now. + NumBytesAllocated += RegSize-1; + NumBytesAllocated = NumBytesAllocated/RegSize*RegSize; + + // Assign the slot... VirtReg2OffsetMap[VirtReg] = NumBytesAllocated; - NumBytesAllocated += ByteAlignment; + + // Reserve the space! + NumBytesAllocated += RegSize; } return VirtReg2OffsetMap[VirtReg]; } @@ -241,7 +238,7 @@ bool RegAllocSimple::runOnMachineFunction(MachineFunction &Fn) { for (MachineFunction::iterator MBB = Fn.begin(), MBBe = Fn.end(); MBB != MBBe; ++MBB) { - CurrMBB = &(*MBB); + MachineBasicBlock *CurrMBB = &(*MBB); // Handle PHI instructions specially: add moves to each pred block while (MBB->front()->getOpcode() == 0) { |