summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2010-12-08 20:04:29 +0000
committerAndrew Trick <atrick@apple.com>2010-12-08 20:04:29 +0000
commit6b1207267f01877ff9b351786c902cb2ecd354c0 (patch)
tree8a830ff262d3e13ca871ea01b172ff8e5583a238 /include
parentcd466f582aa83074294ab1a31b26eedd5a2fd025 (diff)
Generalize PostRAHazardRecognizer so it can be used in any pass for
both forward and backward scheduling. Rename it to ScoreboardHazardRecognizer (Scoreboard is one word). Remove integer division from the scoreboard's critical path. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121274 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/CodeGen/ScoreboardHazardRecognizer.h (renamed from include/llvm/CodeGen/PostRAHazardRecognizer.h)49
1 files changed, 30 insertions, 19 deletions
diff --git a/include/llvm/CodeGen/PostRAHazardRecognizer.h b/include/llvm/CodeGen/ScoreboardHazardRecognizer.h
index ec8d93deb7b..561bf0fecf6 100644
--- a/include/llvm/CodeGen/PostRAHazardRecognizer.h
+++ b/include/llvm/CodeGen/ScoreboardHazardRecognizer.h
@@ -1,4 +1,4 @@
-//=- llvm/CodeGen/PostRAHazardRecognizer.h - Scheduling Support -*- C++ -*-=//
+//=- llvm/CodeGen/ScoreboardHazardRecognizer.h - Schedule Support -*- C++ -*-=//
//
// The LLVM Compiler Infrastructure
//
@@ -7,14 +7,14 @@
//
//===----------------------------------------------------------------------===//
//
-// This file implements the PostRAHazardRecognizer class, which
-// implements hazard-avoidance heuristics for scheduling, based on the
+// This file defines the ScoreboardHazardRecognizer class, which
+// encapsulates hazard-avoidance heuristics for scheduling, based on the
// scheduling itineraries specified for the target.
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CODEGEN_EXACTHAZARDRECOGNIZER_H
-#define LLVM_CODEGEN_EXACTHAZARDRECOGNIZER_H
+#ifndef LLVM_CODEGEN_SCOREBOARDHAZARDRECOGNIZER_H
+#define LLVM_CODEGEN_SCOREBOARDHAZARDRECOGNIZER_H
#include "llvm/CodeGen/ScheduleHazardRecognizer.h"
#include "llvm/Support/DataTypes.h"
@@ -28,13 +28,17 @@ namespace llvm {
class InstrItineraryData;
class SUnit;
-class PostRAHazardRecognizer : public ScheduleHazardRecognizer {
- // ScoreBoard to track function unit usage. ScoreBoard[0] is a
+class ScoreboardHazardRecognizer : public ScheduleHazardRecognizer {
+ // Scoreboard to track function unit usage. Scoreboard[0] is a
// mask of the FUs in use in the cycle currently being
- // schedule. ScoreBoard[1] is a mask for the next cycle. The
- // ScoreBoard is used as a circular buffer with the current cycle
+ // schedule. Scoreboard[1] is a mask for the next cycle. The
+ // Scoreboard is used as a circular buffer with the current cycle
// indicated by Head.
- class ScoreBoard {
+ //
+ // Scoreboard always counts cycles in forward execution order. If used by a
+ // bottom-up scheduler, then the scoreboard cycles are the inverse of the
+ // scheduler's cycles.
+ class Scoreboard {
unsigned *Data;
// The maximum number of cycles monitored by the Scoreboard. This
@@ -44,16 +48,18 @@ class PostRAHazardRecognizer : public ScheduleHazardRecognizer {
// Indices into the Scoreboard that represent the current cycle.
size_t Head;
public:
- ScoreBoard():Data(NULL), Depth(0), Head(0) { }
- ~ScoreBoard() {
+ Scoreboard():Data(NULL), Depth(0), Head(0) { }
+ ~Scoreboard() {
delete[] Data;
}
size_t getDepth() const { return Depth; }
unsigned& operator[](size_t idx) const {
- assert(Depth && "ScoreBoard was not initialized properly!");
+ // Depth is expected to be a power-of-2.
+ assert(Depth && !(Depth & (Depth - 1)) &&
+ "Scoreboard was not initialized properly!");
- return Data[(Head + idx) % Depth];
+ return Data[(Head + idx) & (Depth-1)];
}
void reset(size_t d = 1) {
@@ -67,7 +73,11 @@ class PostRAHazardRecognizer : public ScheduleHazardRecognizer {
}
void advance() {
- Head = (Head + 1) % Depth;
+ Head = (Head + 1) & (Depth-1);
+ }
+
+ void recede() {
+ Head = (Head - 1) & (Depth-1);
}
// Print the scoreboard.
@@ -77,18 +87,19 @@ class PostRAHazardRecognizer : public ScheduleHazardRecognizer {
// Itinerary data for the target.
const InstrItineraryData *ItinData;
- ScoreBoard ReservedScoreboard;
- ScoreBoard RequiredScoreboard;
+ Scoreboard ReservedScoreboard;
+ Scoreboard RequiredScoreboard;
public:
- PostRAHazardRecognizer(const InstrItineraryData *ItinData);
+ ScoreboardHazardRecognizer(const InstrItineraryData *ItinData);
virtual HazardType getHazardType(SUnit *SU);
virtual void Reset();
virtual void EmitInstruction(SUnit *SU);
virtual void AdvanceCycle();
+ virtual void RecedeCycle();
};
}
-#endif
+#endif //!LLVM_CODEGEN_SCOREBOARDHAZARDRECOGNIZER_H