Added support for renumbering existing index list elements. Removed some junk from the initial numbering code in runOnMachineFunction.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86184 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Lang Hames 2009-11-05 22:20:57 +00:00
parent b1dc915a8d
commit fbb8fa247e

View File

@ -51,8 +51,6 @@ bool SlotIndexes::runOnMachineFunction(MachineFunction &fn) {
mf = &fn; mf = &fn;
initList(); initList();
const unsigned gap = 1;
// Check that the list contains only the sentinal. // Check that the list contains only the sentinal.
assert(indexListHead->getNext() == 0 && assert(indexListHead->getNext() == 0 &&
"Index list non-empty at initial numbering?"); "Index list non-empty at initial numbering?");
@ -64,14 +62,6 @@ bool SlotIndexes::runOnMachineFunction(MachineFunction &fn) {
"MachineInstr -> Index mapping non-empty at initial numbering?"); "MachineInstr -> Index mapping non-empty at initial numbering?");
functionSize = 0; functionSize = 0;
/*
for (unsigned s = 0; s < SlotIndex::NUM; ++s) {
indexList.push_back(createEntry(0, s));
}
unsigned index = gap * SlotIndex::NUM;
*/
unsigned index = 0; unsigned index = 0;
// Iterate over the the function. // Iterate over the the function.
@ -83,7 +73,7 @@ bool SlotIndexes::runOnMachineFunction(MachineFunction &fn) {
push_back(createEntry(0, index)); push_back(createEntry(0, index));
SlotIndex blockStartIndex(back(), SlotIndex::LOAD); SlotIndex blockStartIndex(back(), SlotIndex::LOAD);
index += gap * SlotIndex::NUM; index += SlotIndex::NUM;
for (MachineBasicBlock::iterator miItr = mbb->begin(), miEnd = mbb->end(); for (MachineBasicBlock::iterator miItr = mbb->begin(), miEnd = mbb->end();
miItr != miEnd; ++miItr) { miItr != miEnd; ++miItr) {
@ -93,7 +83,7 @@ bool SlotIndexes::runOnMachineFunction(MachineFunction &fn) {
push_back(createEntry(0, index)); push_back(createEntry(0, index));
terminatorGaps.insert( terminatorGaps.insert(
std::make_pair(mbb, SlotIndex(back(), SlotIndex::PHI_BIT))); std::make_pair(mbb, SlotIndex(back(), SlotIndex::PHI_BIT)));
index += gap * SlotIndex::NUM; index += SlotIndex::NUM;
} }
// Insert a store index for the instr. // Insert a store index for the instr.
@ -109,14 +99,14 @@ bool SlotIndexes::runOnMachineFunction(MachineFunction &fn) {
if (Slots == 0) if (Slots == 0)
Slots = 1; Slots = 1;
index += (Slots + 1) * gap * SlotIndex::NUM; index += (Slots + 1) * SlotIndex::NUM;
} }
if (mbb->getFirstTerminator() == mbb->end()) { if (mbb->getFirstTerminator() == mbb->end()) {
push_back(createEntry(0, index)); push_back(createEntry(0, index));
terminatorGaps.insert( terminatorGaps.insert(
std::make_pair(mbb, SlotIndex(back(), SlotIndex::PHI_BIT))); std::make_pair(mbb, SlotIndex(back(), SlotIndex::PHI_BIT)));
index += gap * SlotIndex::NUM; index += SlotIndex::NUM;
} }
SlotIndex blockEndIndex(back(), SlotIndex::STORE); SlotIndex blockEndIndex(back(), SlotIndex::STORE);
@ -139,20 +129,36 @@ bool SlotIndexes::runOnMachineFunction(MachineFunction &fn) {
} }
void SlotIndexes::renumber() { void SlotIndexes::renumber() {
assert(false && "SlotIndexes::runmuber is not fully implemented yet.");
// Compute numbering as follows: // Renumber updates the index of every element of the index list.
// Grab an iterator to the start of the index list. // If all instrs in the function have been allocated an index (which has been
// Iterate over all MBBs, and within each MBB all MIs, keeping the MI // placed in the index list in the order of instruction iteration) then the
// iterator in lock-step (though skipping it over indexes which have // resulting numbering will match what would have been generated by the
// null pointers in the instruction field). // pass during the initial numbering of the function if the new instructions
// At each iteration assert that the instruction pointed to in the index // had been present.
// is the same one pointed to by the MI iterator. This
// FIXME: This can be simplified. The mi2iMap_, Idx2MBBMap, etc. should functionSize = 0;
// only need to be set up once - when the first numbering is computed. unsigned index = 0;
assert(false && "Renumbering not supported yet."); for (IndexListEntry *curEntry = front(); curEntry != getTail();
curEntry = curEntry->getNext()) {
curEntry->setIndex(index);
if (curEntry->getInstr() == 0) {
// MBB start entry or terminator gap. Just step index by 1.
index += SlotIndex::NUM;
}
else {
++functionSize;
unsigned Slots = curEntry->getInstr()->getDesc().getNumDefs();
if (Slots == 0)
Slots = 1;
index += (Slots + 1) * SlotIndex::NUM;
}
}
} }
void SlotIndexes::dump() const { void SlotIndexes::dump() const {