Clement Courbet | 37f0ca0 | 2018-05-15 12:08:00 +0000 | [diff] [blame] | 1 | //===-- Analysis.h ----------------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | /// |
| 10 | /// \file |
| 11 | /// Analysis output for benchmark results. |
| 12 | /// |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef LLVM_TOOLS_LLVM_EXEGESIS_ANALYSIS_H |
| 16 | #define LLVM_TOOLS_LLVM_EXEGESIS_ANALYSIS_H |
| 17 | |
| 18 | #include "Clustering.h" |
Clement Courbet | 6d6c1a9 | 2018-05-16 08:47:21 +0000 | [diff] [blame] | 19 | #include "llvm/MC/MCInstrInfo.h" |
Clement Courbet | 37f0ca0 | 2018-05-15 12:08:00 +0000 | [diff] [blame] | 20 | #include "llvm/MC/MCSubtargetInfo.h" |
| 21 | #include "llvm/Support/Error.h" |
Clement Courbet | 448550d | 2018-05-17 12:25:18 +0000 | [diff] [blame] | 22 | #include "llvm/Support/TargetRegistry.h" |
Clement Courbet | 37f0ca0 | 2018-05-15 12:08:00 +0000 | [diff] [blame] | 23 | #include "llvm/Support/raw_ostream.h" |
Clement Courbet | 6d6c1a9 | 2018-05-16 08:47:21 +0000 | [diff] [blame] | 24 | #include <string> |
| 25 | #include <unordered_map> |
Clement Courbet | 37f0ca0 | 2018-05-15 12:08:00 +0000 | [diff] [blame] | 26 | |
| 27 | namespace exegesis { |
| 28 | |
Clement Courbet | 6d6c1a9 | 2018-05-16 08:47:21 +0000 | [diff] [blame] | 29 | // A helper class to analyze benchmark results for a target. |
| 30 | class Analysis { |
| 31 | public: |
Clement Courbet | 448550d | 2018-05-17 12:25:18 +0000 | [diff] [blame] | 32 | Analysis(const llvm::Target &Target, |
| 33 | const InstructionBenchmarkClustering &Clustering); |
Clement Courbet | 6d6c1a9 | 2018-05-16 08:47:21 +0000 | [diff] [blame] | 34 | |
| 35 | // Prints a csv of instructions for each cluster. |
| 36 | llvm::Error printClusters(llvm::raw_ostream &OS) const; |
| 37 | |
Clement Courbet | 448550d | 2018-05-17 12:25:18 +0000 | [diff] [blame] | 38 | // Find potential errors in the scheduling information given measurements. |
| 39 | llvm::Error printSchedClassInconsistencies(llvm::raw_ostream &OS) const; |
Clement Courbet | 6d6c1a9 | 2018-05-16 08:47:21 +0000 | [diff] [blame] | 40 | |
Clement Courbet | 448550d | 2018-05-17 12:25:18 +0000 | [diff] [blame] | 41 | private: |
| 42 | void printInstructionRow(bool PrintSchedClass, size_t PointId, |
| 43 | llvm::raw_ostream &OS) const; |
| 44 | |
| 45 | // Builds a map of Sched Class -> indices of points that belong to the sched |
| 46 | // class. |
| 47 | std::unordered_map<unsigned, std::vector<size_t>> |
| 48 | makePointsPerSchedClass() const; |
| 49 | |
| 50 | const InstructionBenchmarkClustering &Clustering_; |
| 51 | std::unique_ptr<llvm::MCSubtargetInfo> SubtargetInfo_; |
| 52 | std::unique_ptr<llvm::MCInstrInfo> InstrInfo_; |
| 53 | std::unordered_map<std::string, unsigned> MnemonicToOpcode_; |
Clement Courbet | 6d6c1a9 | 2018-05-16 08:47:21 +0000 | [diff] [blame] | 54 | }; |
Clement Courbet | 37f0ca0 | 2018-05-15 12:08:00 +0000 | [diff] [blame] | 55 | |
| 56 | } // namespace exegesis |
| 57 | |
| 58 | #endif // LLVM_TOOLS_LLVM_EXEGESIS_CLUSTERING_H |