aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/ExactHazardRecognizer.cpp
diff options
context:
space:
mode:
authorDavid Goodwin <david_goodwin@apple.com>2009-09-22 16:47:52 +0000
committerDavid Goodwin <david_goodwin@apple.com>2009-09-22 16:47:52 +0000
commit047ae2f2ad2161d37996c26a5e5ac2b79f09eee5 (patch)
tree6451a8d2da1bb58e4eafac9db67321a139ba48b1 /lib/CodeGen/ExactHazardRecognizer.cpp
parentb759865495441386c58e3c56ec31c53121f45834 (diff)
downloadexternal_llvm-047ae2f2ad2161d37996c26a5e5ac2b79f09eee5.zip
external_llvm-047ae2f2ad2161d37996c26a5e5ac2b79f09eee5.tar.gz
external_llvm-047ae2f2ad2161d37996c26a5e5ac2b79f09eee5.tar.bz2
Use early returns.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82554 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/ExactHazardRecognizer.cpp')
-rw-r--r--lib/CodeGen/ExactHazardRecognizer.cpp120
1 files changed, 61 insertions, 59 deletions
diff --git a/lib/CodeGen/ExactHazardRecognizer.cpp b/lib/CodeGen/ExactHazardRecognizer.cpp
index 057d7ef..85bf43e 100644
--- a/lib/CodeGen/ExactHazardRecognizer.cpp
+++ b/lib/CodeGen/ExactHazardRecognizer.cpp
@@ -83,75 +83,77 @@ void ExactHazardRecognizer::dumpScoreboard() {
}
ExactHazardRecognizer::HazardType ExactHazardRecognizer::getHazardType(SUnit *SU) {
- if (!ItinData.isEmpty()) {
- unsigned cycle = 0;
-
- // Use the itinerary for the underlying instruction to check for
- // free FU's in the scoreboard at the appropriate future cycles.
- unsigned idx = SU->getInstr()->getDesc().getSchedClass();
- for (const InstrStage *IS = ItinData.beginStage(idx),
- *E = ItinData.endStage(idx); IS != E; ++IS) {
- // 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
- // same unit free in all the cycles.
- for (unsigned int i = 0; i < IS->getCycles(); ++i) {
- assert(((cycle + i) < ScoreboardDepth) &&
- "Scoreboard depth exceeded!");
-
- unsigned index = getFutureIndex(cycle + i);
- unsigned freeUnits = IS->getUnits() & ~Scoreboard[index];
- if (!freeUnits) {
- DEBUG(errs() << "*** Hazard in cycle " << (cycle + i) << ", ");
- DEBUG(errs() << "SU(" << SU->NodeNum << "): ");
- DEBUG(SU->getInstr()->dump());
- return Hazard;
- }
- }
+ if (ItinData.isEmpty())
+ return NoHazard;
+
+ unsigned cycle = 0;
+
+ // Use the itinerary for the underlying instruction to check for
+ // free FU's in the scoreboard at the appropriate future cycles.
+ unsigned idx = SU->getInstr()->getDesc().getSchedClass();
+ for (const InstrStage *IS = ItinData.beginStage(idx),
+ *E = ItinData.endStage(idx); IS != E; ++IS) {
+ // 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
+ // same unit free in all the cycles.
+ for (unsigned int i = 0; i < IS->getCycles(); ++i) {
+ assert(((cycle + i) < ScoreboardDepth) &&
+ "Scoreboard depth exceeded!");
- // Advance the cycle to the next stage.
- cycle += IS->getNextCycles();
+ unsigned index = getFutureIndex(cycle + i);
+ unsigned freeUnits = IS->getUnits() & ~Scoreboard[index];
+ if (!freeUnits) {
+ DEBUG(errs() << "*** Hazard in cycle " << (cycle + i) << ", ");
+ DEBUG(errs() << "SU(" << SU->NodeNum << "): ");
+ DEBUG(SU->getInstr()->dump());
+ return Hazard;
+ }
}
+
+ // Advance the cycle to the next stage.
+ cycle += IS->getNextCycles();
}
return NoHazard;
}
void ExactHazardRecognizer::EmitInstruction(SUnit *SU) {
- if (!ItinData.isEmpty()) {
- unsigned cycle = 0;
-
- // Use the itinerary for the underlying instruction to reserve FU's
- // in the scoreboard at the appropriate future cycles.
- unsigned idx = SU->getInstr()->getDesc().getSchedClass();
- for (const InstrStage *IS = ItinData.beginStage(idx),
- *E = ItinData.endStage(idx); IS != E; ++IS) {
- // We must reserve one of the stage's units for every cycle the
- // stage is occupied. FIXME it would be more accurate to reserve
- // the same unit free in all the cycles.
- for (unsigned int i = 0; i < IS->getCycles(); ++i) {
- assert(((cycle + i) < ScoreboardDepth) &&
- "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;
- }
-
- // Advance the cycle to the next stage.
- cycle += IS->getNextCycles();
+ if (ItinData.isEmpty())
+ return;
+
+ unsigned cycle = 0;
+
+ // Use the itinerary for the underlying instruction to reserve FU's
+ // in the scoreboard at the appropriate future cycles.
+ unsigned idx = SU->getInstr()->getDesc().getSchedClass();
+ for (const InstrStage *IS = ItinData.beginStage(idx),
+ *E = ItinData.endStage(idx); IS != E; ++IS) {
+ // We must reserve one of the stage's units for every cycle the
+ // stage is occupied. FIXME it would be more accurate to reserve
+ // the same unit free in all the cycles.
+ for (unsigned int i = 0; i < IS->getCycles(); ++i) {
+ assert(((cycle + i) < ScoreboardDepth) &&
+ "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;
}
-
- DEBUG(dumpScoreboard());
+
+ // Advance the cycle to the next stage.
+ cycle += IS->getNextCycles();
}
+
+ DEBUG(dumpScoreboard());
}
void ExactHazardRecognizer::AdvanceCycle() {