HWEventListener.cpp
InstrBuilder.cpp
Instruction.cpp
+ InstructionInfoView.cpp
LSUnit.cpp
llvm-mca.cpp
ResourcePressureView.cpp
--- /dev/null
+//===--------------------- InstructionInfoView.cpp -------------------*- C++
+//-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+/// \file
+///
+/// This file implements the InstructionView API.
+///
+//===----------------------------------------------------------------------===//
+
+#include "InstructionInfoView.h"
+
+namespace mca {
+
+using namespace llvm;
+
+void InstructionInfoView::printView(raw_ostream &OS) const {
+ std::string Buffer;
+ raw_string_ostream TempStream(Buffer);
+ const MCSchedModel &SM = STI.getSchedModel();
+ unsigned Instructions = Source.size();
+
+ TempStream << "\n\nInstruction Info:\n";
+ TempStream << "[1]: #uOps\n[2]: Latency\n[3]: RThroughput\n"
+ << "[4]: MayLoad\n[5]: MayStore\n[6]: HasSideEffects\n\n";
+
+ TempStream << "[1] [2] [3] [4] [5] [6]\tInstructions:\n";
+ for (unsigned I = 0, E = Instructions; I < E; ++I) {
+ const MCInst &Inst = Source.getMCInstFromIndex(I);
+ const MCInstrDesc &MCDesc = MCII.get(Inst.getOpcode());
+ const MCSchedClassDesc &SCDesc =
+ *SM.getSchedClassDesc(MCDesc.getSchedClass());
+
+ unsigned NumMicroOpcodes = SCDesc.NumMicroOps;
+ unsigned Latency = MCSchedModel::computeInstrLatency(STI, SCDesc);
+ Optional<double> RThroughput =
+ MCSchedModel::getReciprocalThroughput(STI, SCDesc);
+
+ TempStream << ' ' << NumMicroOpcodes << " ";
+ if (NumMicroOpcodes < 10)
+ TempStream << " ";
+ else if (NumMicroOpcodes < 100)
+ TempStream << ' ';
+ TempStream << Latency << " ";
+ if (Latency < 10)
+ TempStream << " ";
+ else if (Latency < 100)
+ TempStream << ' ';
+
+ if (RThroughput.hasValue()) {
+ double RT = RThroughput.getValue();
+ TempStream << format("%.2f", RT) << ' ';
+ if (RT < 10.0)
+ TempStream << " ";
+ else if (RT < 100.0)
+ TempStream << ' ';
+ } else {
+ TempStream << " - ";
+ }
+ TempStream << (MCDesc.mayLoad() ? " * " : " ");
+ TempStream << (MCDesc.mayStore() ? " * " : " ");
+ TempStream << (MCDesc.hasUnmodeledSideEffects() ? " * " : " ");
+ MCIP.printInst(&Inst, TempStream, "", STI);
+ TempStream << '\n';
+ }
+
+ TempStream.flush();
+ OS << Buffer;
+}
+} // namespace mca.
--- /dev/null
+//===--------------------- InstructionInfoView.h ----------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+/// \file
+///
+/// This file implements the instruction info view.
+///
+/// The goal fo the instruction info view is to print the latency and reciprocal
+/// throughput information for every instruction in the input sequence.
+/// This section also reports extra information related to the number of micro
+/// opcodes, and opcode properties (i.e. 'MayLoad', 'MayStore', 'HasSideEffects)
+///
+/// Example:
+///
+/// Instruction Info:
+/// [1]: #uOps
+/// [2]: Latency
+/// [3]: RThroughput
+/// [4]: MayLoad
+/// [5]: MayStore
+/// [6]: HasSideEffects
+///
+/// [1] [2] [3] [4] [5] [6] Instructions:
+/// 1 2 1.00 vmulps %xmm0, %xmm1, %xmm2
+/// 1 3 1.00 vhaddps %xmm2, %xmm2, %xmm3
+/// 1 3 1.00 vhaddps %xmm3, %xmm3, %xmm4
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TOOLS_LLVM_MCA_INSTRUCTIONINFOVIEW_H
+#define LLVM_TOOLS_LLVM_MCA_INSTRUCTIONINFOVIEW_H
+
+#include "SourceMgr.h"
+#include "View.h"
+#include "llvm/MC/MCInstPrinter.h"
+#include "llvm/MC/MCInstrInfo.h"
+#include "llvm/MC/MCSubtargetInfo.h"
+#include "llvm/Support/raw_ostream.h"
+
+#define DEBUG_TYPE "llvm-mca"
+
+namespace mca {
+
+/// \brief A view that prints out generic instruction information.
+class InstructionInfoView : public View {
+ const llvm::MCSubtargetInfo &STI;
+ const llvm::MCInstrInfo &MCII;
+ const SourceMgr &Source;
+ llvm::MCInstPrinter &MCIP;
+
+public:
+ InstructionInfoView(const llvm::MCSubtargetInfo &sti,
+ const llvm::MCInstrInfo &mcii, const SourceMgr &S,
+ llvm::MCInstPrinter &IP)
+ : STI(sti), MCII(mcii), Source(S), MCIP(IP) {}
+
+ void printView(llvm::raw_ostream &OS) const override;
+};
+} // namespace mca
+
+#endif
//===----------------------------------------------------------------------===//
#include "SummaryView.h"
-#include "llvm/CodeGen/TargetSchedule.h"
+#include "llvm/Support/Format.h"
namespace mca {
+#define DEBUG_TYPE "llvm-mca"
+
using namespace llvm;
-void SummaryView::printSummary(raw_ostream &OS) const {
+void SummaryView::printView(raw_ostream &OS) const {
unsigned Iterations = Source.getNumIterations();
unsigned Instructions = Source.size();
unsigned TotalInstructions = Instructions * Iterations;
OS << Buffer;
}
-void SummaryView::printInstructionInfo(raw_ostream &OS) const {
- std::string Buffer;
- raw_string_ostream TempStream(Buffer);
- const MCSchedModel &SM = STI.getSchedModel();
- unsigned Instructions = Source.size();
-
- TempStream << "\n\nInstruction Info:\n";
- TempStream << "[1]: #uOps\n[2]: Latency\n[3]: RThroughput\n"
- << "[4]: MayLoad\n[5]: MayStore\n[6]: HasSideEffects\n\n";
-
- TempStream << "[1] [2] [3] [4] [5] [6]\tInstructions:\n";
- for (unsigned I = 0, E = Instructions; I < E; ++I) {
- const MCInst &Inst = Source.getMCInstFromIndex(I);
- const MCInstrDesc &MCDesc = MCII.get(Inst.getOpcode());
- const MCSchedClassDesc &SCDesc =
- *SM.getSchedClassDesc(MCDesc.getSchedClass());
-
- unsigned NumMicroOpcodes = SCDesc.NumMicroOps;
- unsigned Latency = MCSchedModel::computeInstrLatency(STI, SCDesc);
- Optional<double> RThroughput =
- MCSchedModel::getReciprocalThroughput(STI, SCDesc);
-
- TempStream << ' ' << NumMicroOpcodes << " ";
- if (NumMicroOpcodes < 10)
- TempStream << " ";
- else if (NumMicroOpcodes < 100)
- TempStream << ' ';
- TempStream << Latency << " ";
- if (Latency < 10)
- TempStream << " ";
- else if (Latency < 100)
- TempStream << ' ';
-
- if (RThroughput.hasValue()) {
- double RT = RThroughput.getValue();
- TempStream << format("%.2f", RT) << ' ';
- if (RT < 10.0)
- TempStream << " ";
- else if (RT < 100.0)
- TempStream << ' ';
- } else {
- TempStream << " - ";
- }
- TempStream << (MCDesc.mayLoad() ? " * " : " ");
- TempStream << (MCDesc.mayStore() ? " * " : " ");
- TempStream << (MCDesc.hasUnmodeledSideEffects() ? " * " : " ");
- MCIP.printInst(&Inst, TempStream, "", STI);
- TempStream << '\n';
- }
-
- TempStream.flush();
- OS << Buffer;
-}
-
} // namespace mca.
/// IPC: 1.48
///
///
-/// Instruction Info:
-/// [1]: #uOps
-/// [2]: Latency
-/// [3]: RThroughput
-/// [4]: MayLoad
-/// [5]: MayStore
-/// [6]: HasSideEffects
-///
-/// [1] [2] [3] [4] [5] [6] Instructions:
-/// 1 2 1.00 vmulps %xmm0, %xmm1, %xmm2
-/// 1 3 1.00 vhaddps %xmm2, %xmm2, %xmm3
-/// 1 3 1.00 vhaddps %xmm3, %xmm3, %xmm4
-///
-/// The summary view is structured in two sections.
-///
-/// The first section collects a a few performance numbers. The two main
+/// The summary view collects a few performance numbers. The two main
/// performance indicators are 'Total Cycles' and IPC (Instructions Per Cycle).
///
-/// The second section shows the latency and reciprocal throughput of every
-/// instruction in the sequence. This section also reports extra informaton
-/// related to the number of micro opcodes, and opcode properties (i.e.
-/// 'MayLoad', 'MayStore', 'HasSideEffects)
-///
//===----------------------------------------------------------------------===//
#ifndef LLVM_TOOLS_LLVM_MCA_SUMMARYVIEW_H
#include "SourceMgr.h"
#include "View.h"
-#include "llvm/MC/MCInstPrinter.h"
-#include "llvm/MC/MCSubtargetInfo.h"
-#include "llvm/MC/MCInstrInfo.h"
#include "llvm/Support/raw_ostream.h"
-#define DEBUG_TYPE "llvm-mca"
-
namespace mca {
-/// \brief A printer class that knows how to collects statistics on the
-/// code analyzed by the llvm-mca tool.
-///
-/// This class knows how to print out the analysis information collected
-/// during the execution of the code. Internally, it delegates to other
-/// classes the task of printing out timeline information as well as
-/// resource pressure.
+/// \brief A view that collects and prints a few performance numbers.
class SummaryView : public View {
- const llvm::MCSubtargetInfo &STI;
- const llvm::MCInstrInfo &MCII;
const SourceMgr &Source;
- llvm::MCInstPrinter &MCIP;
-
const unsigned DispatchWidth;
unsigned TotalCycles;
- void printSummary(llvm::raw_ostream &OS) const;
- void printInstructionInfo(llvm::raw_ostream &OS) const;
-
public:
- SummaryView(const llvm::MCSubtargetInfo &sti, const llvm::MCInstrInfo &mcii,
- const SourceMgr &S, llvm::MCInstPrinter &IP, unsigned Width)
- : STI(sti), MCII(mcii), Source(S), MCIP(IP), DispatchWidth(Width),
- TotalCycles(0) {}
+ SummaryView(const SourceMgr &S, unsigned Width)
+ : Source(S), DispatchWidth(Width), TotalCycles(0) {}
void onCycleEnd(unsigned /* unused */) override { ++TotalCycles; }
- void printView(llvm::raw_ostream &OS) const override {
- printSummary(OS);
- printInstructionInfo(OS);
- }
+ void printView(llvm::raw_ostream &OS) const override;
};
-
} // namespace mca
#endif
#include "BackendPrinter.h"
#include "BackendStatistics.h"
+#include "InstructionInfoView.h"
#include "ResourcePressureView.h"
#include "SummaryView.h"
#include "TimelineView.h"
std::unique_ptr<mca::BackendPrinter> Printer =
llvm::make_unique<mca::BackendPrinter>(*B);
+ Printer->addView(llvm::make_unique<mca::SummaryView>(*S, Width));
+
Printer->addView(
- llvm::make_unique<mca::SummaryView>(*STI, *MCII, *S, *IP, Width));
+ llvm::make_unique<mca::InstructionInfoView>(*STI, *MCII, *S, *IP));
if (PrintModeVerbose)
Printer->addView(llvm::make_unique<mca::BackendStatistics>(*STI));