This repository was archived by the owner on Mar 28, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +25
-15
lines changed Expand file tree Collapse file tree 3 files changed +25
-15
lines changed Original file line number Diff line number Diff line change @@ -32,8 +32,10 @@ void ReadState::writeStartEvent(unsigned Cycles) {
32
32
--DependentWrites;
33
33
TotalCycles = std::max (TotalCycles, Cycles);
34
34
35
- if (!DependentWrites)
35
+ if (!DependentWrites) {
36
36
CyclesLeft = TotalCycles;
37
+ IsReady = !CyclesLeft;
38
+ }
37
39
}
38
40
39
41
void WriteState::onInstructionIssued () {
@@ -83,8 +85,10 @@ void ReadState::cycleEvent() {
83
85
if (CyclesLeft == UNKNOWN_CYCLES)
84
86
return ;
85
87
86
- if (CyclesLeft)
88
+ if (CyclesLeft) {
87
89
--CyclesLeft;
90
+ IsReady = !CyclesLeft;
91
+ }
88
92
}
89
93
90
94
#ifndef NDEBUG
@@ -119,9 +123,7 @@ void Instruction::execute() {
119
123
}
120
124
121
125
void Instruction::update () {
122
- if (!isDispatched ())
123
- return ;
124
-
126
+ assert (isDispatched () && " Unexpected instruction stage found!" );
125
127
if (llvm::all_of (Uses, [](const UniqueUse &Use) { return Use->isReady (); }))
126
128
Stage = IS_READY;
127
129
}
@@ -131,9 +133,14 @@ void Instruction::cycleEvent() {
131
133
return ;
132
134
133
135
if (isDispatched ()) {
134
- for (UniqueUse &Use : Uses)
136
+ bool IsReady = true ;
137
+ for (UniqueUse &Use : Uses) {
135
138
Use->cycleEvent ();
136
- update ();
139
+ IsReady &= Use->isReady ();
140
+ }
141
+
142
+ if (IsReady)
143
+ Stage = IS_READY;
137
144
return ;
138
145
}
139
146
Original file line number Diff line number Diff line change @@ -162,17 +162,16 @@ class ReadState {
162
162
// dependent writes (i.e. field DependentWrite) is zero, this value is
163
163
// propagated to field CyclesLeft.
164
164
unsigned TotalCycles;
165
+ // This field is set to true only if there are no dependent writes, and
166
+ // there are no `CyclesLeft' to wait.
167
+ bool IsReady;
165
168
166
169
public:
167
- bool isReady () const {
168
- if (DependentWrites)
169
- return false ;
170
- return (CyclesLeft == UNKNOWN_CYCLES || CyclesLeft == 0 );
171
- }
170
+ bool isReady () const { return IsReady; }
172
171
173
172
ReadState (const ReadDescriptor &Desc, unsigned RegID)
174
173
: RD(Desc), RegisterID(RegID), DependentWrites(0 ),
175
- CyclesLeft (UNKNOWN_CYCLES), TotalCycles(0 ) {}
174
+ CyclesLeft (UNKNOWN_CYCLES), TotalCycles(0 ), IsReady( true ) {}
176
175
ReadState (const ReadState &Other) = delete;
177
176
ReadState &operator =(const ReadState &Other) = delete ;
178
177
@@ -182,7 +181,10 @@ class ReadState {
182
181
183
182
void cycleEvent ();
184
183
void writeStartEvent (unsigned Cycles);
185
- void setDependentWrites (unsigned Writes) { DependentWrites = Writes; }
184
+ void setDependentWrites (unsigned Writes) {
185
+ DependentWrites = Writes;
186
+ IsReady = !Writes;
187
+ }
186
188
};
187
189
188
190
// / A sequence of cycles.
Original file line number Diff line number Diff line change @@ -293,7 +293,8 @@ void Scheduler::promoteToReadyQueue(SmallVectorImpl<InstRef> &Ready) {
293
293
294
294
// Check if this instruction is now ready. In case, force
295
295
// a transition in state using method 'update()'.
296
- IS->update ();
296
+ if (!IS->isReady ())
297
+ IS->update ();
297
298
298
299
const InstrDesc &Desc = IS->getDesc ();
299
300
bool IsMemOp = Desc.MayLoad || Desc.MayStore ;
You can’t perform that action at this time.
0 commit comments