@@ -251,12 +251,16 @@ Fetch::FetchStatGroup::FetchStatGroup(CPU *cpu, Fetch *fetch)
251251 statistics::units::Count, statistics::units::Cycle>::get(),
252252 "Frontend Bandwidth Bound",
253253 frontendBound - frontendLatencyBound),
254- ADD_STAT(resolveQueueFullCycles, statistics::units::Count::get(),
255- "Number of cycles the resolve queue is full"),
256254 ADD_STAT(resolveQueueFullEvents, statistics::units::Count::get(),
257255 "Number of events the resolve queue becomes full"),
258256 ADD_STAT(resolveEnqueueFailEvent, statistics::units::Count::get(),
259- "Number of times an entry could not be enqueued to the resolve queue")
257+ "Number of times an entry could not be enqueued to the resolve queue"),
258+ ADD_STAT(resolveDequeueCount, statistics::units::Count::get(),
259+ "Number of times an entry is dequeued from the resolve queue"),
260+ ADD_STAT(resolveEnqueueCount, statistics::units::Count::get(),
261+ "Number of times an entry is enqueued to the resolve queue"),
262+ ADD_STAT(resolveQueueOccupancy, statistics::units::Count::get(),
263+ "Number of entries in the resolve queue")
260264{
261265 icacheStallCycles
262266 .prereq (icacheStallCycles);
@@ -326,6 +330,10 @@ Fetch::FetchStatGroup::FetchStatGroup(CPU *cpu, Fetch *fetch)
326330 .flags (statistics::total);
327331 frontendBandwidthBound
328332 .flags (statistics::total);
333+ resolveEnqueueCount
334+ .init (1 , 8 , 1 );
335+ resolveQueueOccupancy
336+ .init (0 , 32 , 1 );
329337}
330338void
331339Fetch::setTimeBuffer (TimeBuffer<TimeStruct> *time_buffer)
@@ -1502,32 +1510,39 @@ Fetch::handleIEWSignals()
15021510 }
15031511
15041512 auto &incoming = fromIEW->iewInfo ->resolvedCFIs ;
1513+ uint8_t enqueueSize = fromIEW->iewInfo ->resolvedCFIs .size ();
1514+ uint8_t enqueueCount = 0 ;
15051515
1506- for (const auto &resolved : incoming) {
1507- bool merged = false ;
1508- for (auto &queued : resolveQueue) {
1509- if (queued.resolvedFSQId == resolved.fsqId ) {
1510- queued.resolvedInstPC .push_back (resolved.pc );
1511- merged = true ;
1512- break ;
1516+ if (resolveQueueSize && resolveQueue.size () > resolveQueueSize - 4 ) {
1517+ fetchStats.resolveQueueFullEvents ++;
1518+ fetchStats.resolveEnqueueFailEvent += enqueueSize;
1519+ } else {
1520+
1521+ for (const auto &resolved : incoming) {
1522+ bool merged = false ;
1523+ for (auto &queued : resolveQueue) {
1524+ if (queued.resolvedFSQId == resolved.fsqId ) {
1525+ queued.resolvedInstPC .push_back (resolved.pc );
1526+ merged = true ;
1527+ break ;
1528+ }
15131529 }
1514- }
15151530
1516- if (merged) {
1517- continue ;
1518- }
1531+ if (merged) {
1532+ continue ;
1533+ }
15191534
1520- if (resolveQueueSize && resolveQueue.size () >= resolveQueueSize) {
1521- fetchStats.resolveQueueFullEvents ++;
1522- continue ;
1535+ ResolveQueueEntry new_entry;
1536+ new_entry.resolvedFSQId = resolved.fsqId ;
1537+ new_entry.resolvedInstPC .push_back (resolved.pc );
1538+ resolveQueue.push_back (std::move (new_entry));
1539+ enqueueCount++;
15231540 }
1524-
1525- ResolveQueueEntry new_entry;
1526- new_entry.resolvedFSQId = resolved.fsqId ;
1527- new_entry.resolvedInstPC .push_back (resolved.pc );
1528- resolveQueue.push_back (std::move (new_entry));
1541+ fetchStats.resolveEnqueueCount .sample (enqueueCount);
15291542 }
15301543
1544+ fetchStats.resolveQueueOccupancy .sample (resolveQueue.size ());
1545+
15311546 if (!resolveQueue.empty ()) {
15321547 auto &entry = resolveQueue.front ();
15331548 unsigned int stream_id = entry.resolvedFSQId ;
@@ -1539,6 +1554,7 @@ Fetch::handleIEWSignals()
15391554 if (success) {
15401555 dbpbtb->notifyResolveSuccess ();
15411556 resolveQueue.pop_front ();
1557+ fetchStats.resolveDequeueCount ++;
15421558 } else {
15431559 dbpbtb->notifyResolveFailure ();
15441560 }
0 commit comments