summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-mca/BackendStatistics.cpp
diff options
context:
space:
mode:
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>2018-03-21 18:11:05 +0000
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>2018-03-21 18:11:05 +0000
commit12ef5260ea2fada35c830266e926441c671cf5a5 (patch)
tree31bbebb837ec96827d4be3898cfaa302a56bb9cc /llvm/tools/llvm-mca/BackendStatistics.cpp
parent949437e8829d93e5110ab1c68fbe7359d3a5f34c (diff)
downloadbcm5719-llvm-12ef5260ea2fada35c830266e926441c671cf5a5.tar.gz
bcm5719-llvm-12ef5260ea2fada35c830266e926441c671cf5a5.zip
[llvm-mca] Move the logic that computes the register file usage to the BackendStatistics view.
With this patch, the "instruction dispatched" event now provides information related to the number of microarchitectural registers used in each register file. Similarly, the "instruction retired" event is now able to tell how may registers are freed in each register file. Currently, the BackendStatistics view is the only consumer of register usage/pressure information. BackendStatistics uses that info to print out a few general statistics (i.e. max number of mappings used; total mapping created). Before this patch, the BackendStatistics was forced to query the Backend to obtain the register pressure information. This helps removes that dependency. Now views are completely independent from the Backend. As a consequence, it should be easier to address PR36663 and further modularize the pipeline. Added a couple of test cases in the BtVer2 specific directory. llvm-svn: 328129
Diffstat (limited to 'llvm/tools/llvm-mca/BackendStatistics.cpp')
-rw-r--r--llvm/tools/llvm-mca/BackendStatistics.cpp43
1 files changed, 31 insertions, 12 deletions
diff --git a/llvm/tools/llvm-mca/BackendStatistics.cpp b/llvm/tools/llvm-mca/BackendStatistics.cpp
index 64b8be11e4d..c5425509064 100644
--- a/llvm/tools/llvm-mca/BackendStatistics.cpp
+++ b/llvm/tools/llvm-mca/BackendStatistics.cpp
@@ -22,17 +22,32 @@ namespace mca {
void BackendStatistics::onInstructionEvent(const HWInstructionEvent &Event) {
switch (Event.Type) {
- case HWInstructionEvent::Retired:
+ default:
+ break;
+ case HWInstructionEvent::Retired: {
+ const auto &RE = static_cast<const HWInstructionRetiredEvent &>(Event);
+ for (unsigned I = 0, E = RegisterFiles.size(); I < E; ++I)
+ RegisterFiles[I].CurrentlyUsedMappings -= RE.FreedPhysRegs[I];
+
++NumRetired;
break;
+ }
case HWInstructionEvent::Issued:
++NumIssued;
break;
- case HWInstructionEvent::Dispatched:
+ case HWInstructionEvent::Dispatched: {
+ const auto &DE = static_cast<const HWInstructionDispatchedEvent &>(Event);
+ for (unsigned I = 0, E = RegisterFiles.size(); I < E; ++I) {
+ RegisterFileUsage &RFU = RegisterFiles[I];
+ unsigned NumUsedPhysRegs = DE.UsedPhysRegs[I];
+ RFU.CurrentlyUsedMappings += NumUsedPhysRegs;
+ RFU.TotalMappings += NumUsedPhysRegs;
+ RFU.MaxUsedMappings =
+ std::max(RFU.MaxUsedMappings, RFU.CurrentlyUsedMappings);
+ }
+
++NumDispatched;
- break;
- default:
- break;
+ }
}
}
@@ -115,15 +130,19 @@ void BackendStatistics::printSchedulerStatistics(llvm::raw_ostream &OS) const {
OS << Buffer;
}
-void BackendStatistics::printRATStatistics(raw_ostream &OS,
- unsigned TotalMappings,
- unsigned MaxUsedMappings) const {
+void BackendStatistics::printRATStatistics(raw_ostream &OS) const {
std::string Buffer;
raw_string_ostream TempStream(Buffer);
- TempStream << "\n\nRegister Alias Table:";
- TempStream << "\nTotal number of mappings created: " << TotalMappings;
- TempStream << "\nMax number of mappings used: " << MaxUsedMappings
- << '\n';
+
+ TempStream << "\n\nRegister File statistics.";
+ for (unsigned I = 0, E = RegisterFiles.size(); I < E; ++I) {
+ const RegisterFileUsage &RFU = RegisterFiles[I];
+ TempStream << "\nRegister File #" << I;
+ TempStream << "\n Total number of mappings created: " << RFU.TotalMappings;
+ TempStream << "\n Max number of mappings used: "
+ << RFU.MaxUsedMappings;
+ }
+
TempStream.flush();
OS << Buffer;
}
OpenPOWER on IntegriCloud