blob: 64de23c2478da1f7d660b06bfe940cf6adad5702 [file] [log] [blame]
Clement Courbet37f0ca02018-05-15 12:08:00 +00001//===-- 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 Courbet6d6c1a92018-05-16 08:47:21 +000019#include "llvm/MC/MCInstrInfo.h"
Clement Courbet37f0ca02018-05-15 12:08:00 +000020#include "llvm/MC/MCSubtargetInfo.h"
Clement Courbet6d6c1a92018-05-16 08:47:21 +000021#include "llvm/Support/TargetRegistry.h"
Clement Courbet37f0ca02018-05-15 12:08:00 +000022#include "llvm/Support/Error.h"
23#include "llvm/Support/raw_ostream.h"
Clement Courbet6d6c1a92018-05-16 08:47:21 +000024#include <string>
25#include <unordered_map>
Clement Courbet37f0ca02018-05-15 12:08:00 +000026
27namespace exegesis {
28
Clement Courbet6d6c1a92018-05-16 08:47:21 +000029// A helper class to analyze benchmark results for a target.
30class Analysis {
31public:
32 Analysis(const llvm::Target& Target, const InstructionBenchmarkClustering &Clustering);
33
34 // Prints a csv of instructions for each cluster.
35 llvm::Error printClusters(llvm::raw_ostream &OS) const;
36
37 private:
38 void printInstructionRow(size_t ClusterId, size_t PointId,
39 llvm::raw_ostream &OS) const;
40
41 const InstructionBenchmarkClustering & Clustering_;
42 std::unique_ptr<llvm::MCSubtargetInfo> SubtargetInfo_;
43 std::unique_ptr<llvm::MCInstrInfo> InstrInfo_;
44 std::unordered_map<std::string, unsigned> MnemonicToOpcode_;
45};
Clement Courbet37f0ca02018-05-15 12:08:00 +000046
47} // namespace exegesis
48
49#endif // LLVM_TOOLS_LLVM_EXEGESIS_CLUSTERING_H