mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
Don't crash when target has no itineraries.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80962 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -83,71 +83,75 @@ void ExactHazardRecognizer::dumpScoreboard() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ExactHazardRecognizer::HazardType ExactHazardRecognizer::getHazardType(SUnit *SU) {
|
ExactHazardRecognizer::HazardType ExactHazardRecognizer::getHazardType(SUnit *SU) {
|
||||||
unsigned cycle = 0;
|
if (!ItinData.isEmpty()) {
|
||||||
|
unsigned cycle = 0;
|
||||||
|
|
||||||
// Use the itinerary for the underlying instruction to check for
|
// Use the itinerary for the underlying instruction to check for
|
||||||
// free FU's in the scoreboard at the appropriate future cycles.
|
// free FU's in the scoreboard at the appropriate future cycles.
|
||||||
unsigned idx = SU->getInstr()->getDesc().getSchedClass();
|
unsigned idx = SU->getInstr()->getDesc().getSchedClass();
|
||||||
for (const InstrStage *IS = ItinData.beginStage(idx),
|
for (const InstrStage *IS = ItinData.beginStage(idx),
|
||||||
*E = ItinData.endStage(idx); IS != E; ++IS) {
|
*E = ItinData.endStage(idx); IS != E; ++IS) {
|
||||||
// We must find one of the stage's units free for every cycle the
|
// We must find one of the stage's units free for every cycle the
|
||||||
// stage is occupied. FIXME it would be more accurate to find the
|
// stage is occupied. FIXME it would be more accurate to find the
|
||||||
// same unit free in all the cycles.
|
// same unit free in all the cycles.
|
||||||
for (unsigned int i = 0; i < IS->getCycles(); ++i) {
|
for (unsigned int i = 0; i < IS->getCycles(); ++i) {
|
||||||
assert(((cycle + i) < ScoreboardDepth) &&
|
assert(((cycle + i) < ScoreboardDepth) &&
|
||||||
"Scoreboard depth exceeded!");
|
"Scoreboard depth exceeded!");
|
||||||
|
|
||||||
unsigned index = getFutureIndex(cycle + i);
|
unsigned index = getFutureIndex(cycle + i);
|
||||||
unsigned freeUnits = IS->getUnits() & ~Scoreboard[index];
|
unsigned freeUnits = IS->getUnits() & ~Scoreboard[index];
|
||||||
if (!freeUnits) {
|
if (!freeUnits) {
|
||||||
DEBUG(errs() << "*** Hazard in cycle " << (cycle + i) << ", ");
|
DEBUG(errs() << "*** Hazard in cycle " << (cycle + i) << ", ");
|
||||||
DEBUG(errs() << "SU(" << SU->NodeNum << "): ");
|
DEBUG(errs() << "SU(" << SU->NodeNum << "): ");
|
||||||
DEBUG(SU->getInstr()->dump());
|
DEBUG(SU->getInstr()->dump());
|
||||||
return Hazard;
|
return Hazard;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Advance the cycle to the next stage.
|
||||||
|
cycle += IS->getNextCycles();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Advance the cycle to the next stage.
|
|
||||||
cycle += IS->getNextCycles();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NoHazard;
|
return NoHazard;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExactHazardRecognizer::EmitInstruction(SUnit *SU) {
|
void ExactHazardRecognizer::EmitInstruction(SUnit *SU) {
|
||||||
unsigned cycle = 0;
|
if (!ItinData.isEmpty()) {
|
||||||
|
unsigned cycle = 0;
|
||||||
|
|
||||||
// Use the itinerary for the underlying instruction to reserve FU's
|
// Use the itinerary for the underlying instruction to reserve FU's
|
||||||
// in the scoreboard at the appropriate future cycles.
|
// in the scoreboard at the appropriate future cycles.
|
||||||
unsigned idx = SU->getInstr()->getDesc().getSchedClass();
|
unsigned idx = SU->getInstr()->getDesc().getSchedClass();
|
||||||
for (const InstrStage *IS = ItinData.beginStage(idx),
|
for (const InstrStage *IS = ItinData.beginStage(idx),
|
||||||
*E = ItinData.endStage(idx); IS != E; ++IS) {
|
*E = ItinData.endStage(idx); IS != E; ++IS) {
|
||||||
// We must reserve one of the stage's units for every cycle the
|
// We must reserve one of the stage's units for every cycle the
|
||||||
// stage is occupied. FIXME it would be more accurate to reserve
|
// stage is occupied. FIXME it would be more accurate to reserve
|
||||||
// the same unit free in all the cycles.
|
// the same unit free in all the cycles.
|
||||||
for (unsigned int i = 0; i < IS->getCycles(); ++i) {
|
for (unsigned int i = 0; i < IS->getCycles(); ++i) {
|
||||||
assert(((cycle + i) < ScoreboardDepth) &&
|
assert(((cycle + i) < ScoreboardDepth) &&
|
||||||
"Scoreboard depth exceeded!");
|
"Scoreboard depth exceeded!");
|
||||||
|
|
||||||
|
unsigned index = getFutureIndex(cycle + i);
|
||||||
|
unsigned freeUnits = IS->getUnits() & ~Scoreboard[index];
|
||||||
|
|
||||||
|
// reduce to a single unit
|
||||||
|
unsigned freeUnit = 0;
|
||||||
|
do {
|
||||||
|
freeUnit = freeUnits;
|
||||||
|
freeUnits = freeUnit & (freeUnit - 1);
|
||||||
|
} while (freeUnits);
|
||||||
|
|
||||||
|
assert(freeUnit && "No function unit available!");
|
||||||
|
Scoreboard[index] |= freeUnit;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned index = getFutureIndex(cycle + i);
|
// Advance the cycle to the next stage.
|
||||||
unsigned freeUnits = IS->getUnits() & ~Scoreboard[index];
|
cycle += IS->getNextCycles();
|
||||||
|
|
||||||
// reduce to a single unit
|
|
||||||
unsigned freeUnit = 0;
|
|
||||||
do {
|
|
||||||
freeUnit = freeUnits;
|
|
||||||
freeUnits = freeUnit & (freeUnit - 1);
|
|
||||||
} while (freeUnits);
|
|
||||||
|
|
||||||
assert(freeUnit && "No function unit available!");
|
|
||||||
Scoreboard[index] |= freeUnit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Advance the cycle to the next stage.
|
DEBUG(dumpScoreboard());
|
||||||
cycle += IS->getNextCycles();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(dumpScoreboard());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExactHazardRecognizer::AdvanceCycle() {
|
void ExactHazardRecognizer::AdvanceCycle() {
|
||||||
|
Reference in New Issue
Block a user