[llvm-commits] CVS: llvm/lib/CodeGen/RegAllocLinearScan.cpp
Alkis Evlogimenos
alkis at cs.uiuc.edu
Wed Dec 3 21:58:02 PST 2003
Changes in directory llvm/lib/CodeGen:
RegAllocLinearScan.cpp updated: 1.4 -> 1.5
---
Log message:
Improve debugging output and clean up some code.
---
Diffs of the changes: (+14 -17)
Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp
diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.4 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.5
--- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.4 Sun Nov 30 17:40:39 2003
+++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Wed Dec 3 21:57:28 2003
@@ -150,10 +150,9 @@
/// stack slot
void assignVirt2StackSlot(unsigned virtReg);
- /// findOrCreateStackSlot - returns the offset of the
- /// specified register on the stack allocating space if
- /// necessary
- int findOrCreateStackSlot(unsigned virtReg);
+ /// getStackSlot - returns the offset of the specified
+ /// register on the stack
+ int getStackSlot(unsigned virtReg);
/// spillVirtReg - spills the virtual register
void spillVirtReg(unsigned virtReg);
@@ -749,29 +748,27 @@
if (v2pMap_.find(virtReg) != v2pMap_.end()) {
clearVirtReg(virtReg);
}
+ else {
+ v2pMap_[virtReg] = 0; // this marks that this virtual register
+ // lives on the stack
+ }
}
-int RA::findOrCreateStackSlot(unsigned virtReg)
+int RA::getStackSlot(unsigned virtReg)
{
// use lower_bound so that we can do a possibly O(1) insert later
// if necessary
- Virt2StackSlotMap::iterator it = v2ssMap_.lower_bound(virtReg);
- if (it != v2ssMap_.end() && it->first == virtReg) {
- return it->second;
- }
- const TargetRegisterClass* rc = mf_->getSSARegMap()->getRegClass(virtReg);
- int frameIndex = mf_->getFrameInfo()->CreateStackObject(rc);
-
- v2ssMap_.insert(it, std::make_pair(virtReg, frameIndex));
-
- return frameIndex;
+ Virt2StackSlotMap::iterator it = v2ssMap_.find(virtReg);
+ assert(it != v2ssMap_.end() &&
+ "attempt to get stack slot on register that does not live on the stack");
+ return it->second;
}
void RA::spillVirtReg(unsigned virtReg)
{
DEBUG(std::cerr << "\t\t\tspilling register: " << virtReg);
const TargetRegisterClass* rc = mf_->getSSARegMap()->getRegClass(virtReg);
- int frameIndex = findOrCreateStackSlot(virtReg);
+ int frameIndex = getStackSlot(virtReg);
DEBUG(std::cerr << " to stack slot #" << frameIndex << '\n');
++numSpilled;
instrAdded_ += mri_->storeRegToStackSlot(*currentMbb_, currentInstr_,
@@ -783,7 +780,7 @@
{
DEBUG(std::cerr << "\t\t\tloading register: " << virtReg);
const TargetRegisterClass* rc = mf_->getSSARegMap()->getRegClass(virtReg);
- int frameIndex = findOrCreateStackSlot(virtReg);
+ int frameIndex = getStackSlot(virtReg);
DEBUG(std::cerr << " from stack slot #" << frameIndex << '\n');
instrAdded_ += mri_->loadRegFromStackSlot(*currentMbb_, currentInstr_,
physReg, frameIndex, rc);
More information about the llvm-commits
mailing list