blob: d0f942a6ddef5bbccea7b6f3f7dfb942f2391d71 [file] [log] [blame]
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +00001//===-- llvm-mca.cpp - Machine Code Analyzer -------------------*- 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// This utility is a simple driver that allows static performance analysis on
11// machine code similarly to how IACA (Intel Architecture Code Analyzer) works.
12//
13// llvm-mca [options] <file-name>
14// -march <type>
15// -mcpu <cpu>
16// -o <file>
17//
18// The target defaults to the host target.
Andrea Di Biagio93c49d52018-04-25 10:18:25 +000019// The cpu defaults to the 'native' host cpu.
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +000020// The output defaults to standard output.
21//
22//===----------------------------------------------------------------------===//
23
Andrea Di Biagio53e6ade2018-03-09 12:50:42 +000024#include "BackendPrinter.h"
Andrea Di Biagioc6590122018-04-09 16:39:52 +000025#include "CodeRegion.h"
Andrea Di Biagio821f6502018-04-10 14:55:14 +000026#include "DispatchStatistics.h"
Andrea Di Biagiodf5d9482018-03-23 19:40:04 +000027#include "InstructionInfoView.h"
Andrea Di Biagiod1569292018-03-26 12:04:53 +000028#include "InstructionTables.h"
Andrea Di Biagio8dabf4f2018-04-03 16:46:23 +000029#include "RegisterFileStatistics.h"
Andrea Di Biagio53e6ade2018-03-09 12:50:42 +000030#include "ResourcePressureView.h"
Andrea Di Biagiof41ad5c2018-04-11 12:12:53 +000031#include "RetireControlUnitStatistics.h"
Andrea Di Biagio1cc29c02018-04-11 11:37:46 +000032#include "SchedulerStatistics.h"
Andrea Di Biagio0cc66c72018-03-09 13:52:03 +000033#include "SummaryView.h"
Andrea Di Biagio53e6ade2018-03-09 12:50:42 +000034#include "TimelineView.h"
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +000035#include "llvm/MC/MCAsmInfo.h"
36#include "llvm/MC/MCContext.h"
37#include "llvm/MC/MCObjectFileInfo.h"
38#include "llvm/MC/MCParser/MCTargetAsmParser.h"
39#include "llvm/MC/MCRegisterInfo.h"
40#include "llvm/MC/MCStreamer.h"
41#include "llvm/Support/CommandLine.h"
Andrea Di Biagio8af3fe82018-03-08 16:08:43 +000042#include "llvm/Support/ErrorOr.h"
43#include "llvm/Support/FileSystem.h"
Andrea Di Biagio641cca32018-04-25 10:27:30 +000044#include "llvm/Support/Host.h"
Rui Ueyama197194b2018-04-13 18:26:06 +000045#include "llvm/Support/InitLLVM.h"
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +000046#include "llvm/Support/MemoryBuffer.h"
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +000047#include "llvm/Support/SourceMgr.h"
48#include "llvm/Support/TargetRegistry.h"
49#include "llvm/Support/TargetSelect.h"
Andrea Di Biagio8af3fe82018-03-08 16:08:43 +000050#include "llvm/Support/ToolOutputFile.h"
Jonas Devlieghere6adef092018-04-18 15:26:51 +000051#include "llvm/Support/WithColor.h"
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +000052
53using namespace llvm;
54
55static cl::opt<std::string>
56 InputFilename(cl::Positional, cl::desc("<input file>"), cl::init("-"));
57
58static cl::opt<std::string> OutputFilename("o", cl::desc("Output filename"),
59 cl::init("-"),
60 cl::value_desc("filename"));
61
62static cl::opt<std::string>
63 ArchName("march", cl::desc("Target arch to assemble for, "
64 "see -version for available targets"));
65
66static cl::opt<std::string>
67 TripleName("mtriple", cl::desc("Target triple to assemble for, "
Andrea Di Biagio8af3fe82018-03-08 16:08:43 +000068 "see -version for available targets"));
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +000069
70static cl::opt<std::string>
71 MCPU("mcpu",
72 cl::desc("Target a specific cpu type (-mcpu=help for details)"),
Andrea Di Biagio93c49d52018-04-25 10:18:25 +000073 cl::value_desc("cpu-name"), cl::init("native"));
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +000074
Andrea Di Biagio06268642018-04-24 16:19:08 +000075static cl::opt<int>
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +000076 OutputAsmVariant("output-asm-variant",
Andrea Di Biagio06268642018-04-24 16:19:08 +000077 cl::desc("Syntax variant to use for output printing"),
78 cl::init(-1));
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +000079
80static cl::opt<unsigned> Iterations("iterations",
81 cl::desc("Number of iterations to run"),
82 cl::init(0));
83
84static cl::opt<unsigned> DispatchWidth(
85 "dispatch",
86 cl::desc("Dispatch Width. By default it is set equal to IssueWidth"),
87 cl::init(0));
88
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +000089static cl::opt<unsigned>
90 RegisterFileSize("register-file-size",
91 cl::desc("Maximum number of temporary registers which can "
92 "be used for register mappings"),
93 cl::init(0));
94
Andrea Di Biagio29538c62018-03-23 11:33:09 +000095static cl::opt<bool>
Andrea Di Biagio8dabf4f2018-04-03 16:46:23 +000096 PrintRegisterFileStats("register-file-stats",
97 cl::desc("Print register file statistics"),
98 cl::init(false));
99
Andrea Di Biagio641cca32018-04-25 10:27:30 +0000100static cl::opt<bool> PrintDispatchStats("dispatch-stats",
101 cl::desc("Print dispatch statistics"),
102 cl::init(false));
Andrea Di Biagio821f6502018-04-10 14:55:14 +0000103
Andrea Di Biagio641cca32018-04-25 10:27:30 +0000104static cl::opt<bool> PrintSchedulerStats("scheduler-stats",
105 cl::desc("Print scheduler statistics"),
106 cl::init(false));
Andrea Di Biagio1cc29c02018-04-11 11:37:46 +0000107
108static cl::opt<bool>
Andrea Di Biagiof41ad5c2018-04-11 12:12:53 +0000109 PrintRetireStats("retire-stats",
Andrea Di Biagio641cca32018-04-25 10:27:30 +0000110 cl::desc("Print retire control unit statistics"),
111 cl::init(false));
Andrea Di Biagiof41ad5c2018-04-11 12:12:53 +0000112
113static cl::opt<bool>
Andrea Di Biagio29538c62018-03-23 11:33:09 +0000114 PrintResourcePressureView("resource-pressure",
115 cl::desc("Print the resource pressure view"),
116 cl::init(true));
117
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +0000118static cl::opt<bool> PrintTimelineView("timeline",
119 cl::desc("Print the timeline view"),
120 cl::init(false));
121
122static cl::opt<unsigned> TimelineMaxIterations(
123 "timeline-max-iterations",
124 cl::desc("Maximum number of iterations to print in timeline view"),
125 cl::init(0));
126
127static cl::opt<unsigned> TimelineMaxCycles(
128 "timeline-max-cycles",
129 cl::desc(
130 "Maximum number of cycles in the timeline view. Defaults to 80 cycles"),
131 cl::init(80));
132
Andrea Di Biagio8af3fe82018-03-08 16:08:43 +0000133static cl::opt<bool> AssumeNoAlias(
134 "noalias",
135 cl::desc("If set, it assumes that loads and stores do not alias"),
136 cl::init(true));
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +0000137
138static cl::opt<unsigned>
139 LoadQueueSize("lqueue", cl::desc("Size of the load queue"), cl::init(0));
Andrea Di Biagiod1569292018-03-26 12:04:53 +0000140
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +0000141static cl::opt<unsigned>
142 StoreQueueSize("squeue", cl::desc("Size of the store queue"), cl::init(0));
143
Andrea Di Biagiod1569292018-03-26 12:04:53 +0000144static cl::opt<bool>
145 PrintInstructionTables("instruction-tables",
146 cl::desc("Print instruction tables"),
147 cl::init(false));
148
Andrea Di Biagioff9c1092018-03-26 13:44:54 +0000149static cl::opt<bool>
150 PrintInstructionInfoView("instruction-info",
151 cl::desc("Print the instruction info view"),
152 cl::init(true));
153
Andrea Di Biagio5c469442018-04-08 15:10:19 +0000154namespace {
155
156const Target *getTarget(const char *ProgName) {
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +0000157 TripleName = Triple::normalize(TripleName);
158 if (TripleName.empty())
159 TripleName = Triple::normalize(sys::getDefaultTargetTriple());
160 Triple TheTriple(TripleName);
161
162 // Get the target specific parser.
163 std::string Error;
164 const Target *TheTarget =
165 TargetRegistry::lookupTarget(ArchName, TheTriple, Error);
166 if (!TheTarget) {
167 errs() << ProgName << ": " << Error;
168 return nullptr;
169 }
170
171 // Return the found target.
172 return TheTarget;
173}
174
Andrea Di Biagioc6590122018-04-09 16:39:52 +0000175// A comment consumer that parses strings.
176// The only valid tokens are strings.
177class MCACommentConsumer : public AsmCommentConsumer {
178public:
179 mca::CodeRegions &Regions;
180
181 MCACommentConsumer(mca::CodeRegions &R) : Regions(R) {}
182 void HandleComment(SMLoc Loc, StringRef CommentText) override {
183 // Skip empty comments.
184 StringRef Comment(CommentText);
185 if (Comment.empty())
186 return;
187
188 // Skip spaces and tabs
189 unsigned Position = Comment.find_first_not_of(" \t");
190 if (Position >= Comment.size())
191 // we reached the end of the comment. Bail out.
192 return;
193
194 Comment = Comment.drop_front(Position);
195 if (Comment.consume_front("LLVM-MCA-END")) {
196 Regions.endRegion(Loc);
197 return;
198 }
199
200 // Now try to parse string LLVM-MCA-BEGIN
201 if (!Comment.consume_front("LLVM-MCA-BEGIN"))
202 return;
203
204 // Skip spaces and tabs
205 Position = Comment.find_first_not_of(" \t");
206 if (Position < Comment.size())
Fangrui Songbb082572018-04-09 17:06:57 +0000207 Comment = Comment.drop_front(Position);
Andrea Di Biagioc6590122018-04-09 16:39:52 +0000208 // Use the rest of the string as a descriptor for this code snippet.
209 Regions.beginRegion(Comment, Loc);
210 }
211};
212
Andrea Di Biagio5c469442018-04-08 15:10:19 +0000213int AssembleInput(const char *ProgName, MCAsmParser &Parser,
214 const Target *TheTarget, MCSubtargetInfo &STI,
215 MCInstrInfo &MCII, MCTargetOptions &MCOptions) {
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +0000216 std::unique_ptr<MCTargetAsmParser> TAP(
Andrea Di Biagio5c469442018-04-08 15:10:19 +0000217 TheTarget->createMCAsmParser(STI, Parser, MCII, MCOptions));
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +0000218
219 if (!TAP) {
220 errs() << ProgName
221 << ": error: this target does not support assembly parsing.\n";
222 return 1;
223 }
224
Andrea Di Biagio5c469442018-04-08 15:10:19 +0000225 Parser.setTargetParser(*TAP);
226 return Parser.Run(false);
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +0000227}
228
Andrea Di Biagio5c469442018-04-08 15:10:19 +0000229ErrorOr<std::unique_ptr<ToolOutputFile>> getOutputStream() {
Andrea Di Biagio8af3fe82018-03-08 16:08:43 +0000230 if (OutputFilename == "")
231 OutputFilename = "-";
232 std::error_code EC;
233 auto Out =
234 llvm::make_unique<ToolOutputFile>(OutputFilename, EC, sys::fs::F_None);
235 if (!EC)
236 return std::move(Out);
237 return EC;
238}
239
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +0000240class MCStreamerWrapper final : public MCStreamer {
Andrea Di Biagioc6590122018-04-09 16:39:52 +0000241 mca::CodeRegions &Regions;
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +0000242
243public:
Andrea Di Biagioc6590122018-04-09 16:39:52 +0000244 MCStreamerWrapper(MCContext &Context, mca::CodeRegions &R)
245 : MCStreamer(Context), Regions(R) {}
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +0000246
247 // We only want to intercept the emission of new instructions.
248 virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI,
249 bool /* unused */) override {
Andrea Di Biagioc6590122018-04-09 16:39:52 +0000250 Regions.addInstruction(llvm::make_unique<const MCInst>(Inst));
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +0000251 }
252
253 bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override {
254 return true;
255 }
256
257 void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
258 unsigned ByteAlignment) override {}
259 void EmitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr,
260 uint64_t Size = 0, unsigned ByteAlignment = 0) override {}
261 void EmitGPRel32Value(const MCExpr *Value) override {}
262 void BeginCOFFSymbolDef(const MCSymbol *Symbol) override {}
263 void EmitCOFFSymbolStorageClass(int StorageClass) override {}
264 void EmitCOFFSymbolType(int Type) override {}
265 void EndCOFFSymbolDef() override {}
266
Andrea Di Biagioc6590122018-04-09 16:39:52 +0000267 const std::vector<std::unique_ptr<const MCInst>> &
268 GetInstructionSequence(unsigned Index) const {
269 return Regions.getInstructionSequence(Index);
270 }
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +0000271};
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +0000272} // end of anonymous namespace
273
274int main(int argc, char **argv) {
Rui Ueyama197194b2018-04-13 18:26:06 +0000275 InitLLVM X(argc, argv);
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +0000276
277 // Initialize targets and assembly parsers.
278 llvm::InitializeAllTargetInfos();
279 llvm::InitializeAllTargetMCs();
280 llvm::InitializeAllAsmParsers();
281
282 // Enable printing of available targets when flag --version is specified.
283 cl::AddExtraVersionPrinter(TargetRegistry::printRegisteredTargetsForVersion);
284
285 // Parse flags and initialize target options.
286 cl::ParseCommandLineOptions(argc, argv,
287 "llvm machine code performance analyzer.\n");
288 MCTargetOptions MCOptions;
289 MCOptions.PreserveAsmComments = false;
290
291 // Get the target from the triple. If a triple is not specified, then select
292 // the default triple for the host. If the triple doesn't correspond to any
293 // registered target, then exit with an error message.
294 const char *ProgName = argv[0];
295 const Target *TheTarget = getTarget(ProgName);
296 if (!TheTarget)
297 return 1;
298
299 // GetTarget() may replaced TripleName with a default triple.
300 // For safety, reconstruct the Triple object.
301 Triple TheTriple(TripleName);
302
303 ErrorOr<std::unique_ptr<MemoryBuffer>> BufferPtr =
304 MemoryBuffer::getFileOrSTDIN(InputFilename);
305 if (std::error_code EC = BufferPtr.getError()) {
Jonas Devlieghere6adef092018-04-18 15:26:51 +0000306 WithColor::error() << InputFilename << ": " << EC.message() << '\n';
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +0000307 return 1;
308 }
309
310 SourceMgr SrcMgr;
311
312 // Tell SrcMgr about this buffer, which is what the parser will pick up.
313 SrcMgr.AddNewSourceBuffer(std::move(*BufferPtr), SMLoc());
314
315 std::unique_ptr<MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TripleName));
316 assert(MRI && "Unable to create target register info!");
317
318 std::unique_ptr<MCAsmInfo> MAI(TheTarget->createMCAsmInfo(*MRI, TripleName));
319 assert(MAI && "Unable to create target asm info!");
320
321 MCObjectFileInfo MOFI;
322 MCContext Ctx(MAI.get(), MRI.get(), &MOFI, &SrcMgr);
323 MOFI.InitMCObjectFileInfo(TheTriple, /* PIC= */ false, Ctx);
324
325 std::unique_ptr<buffer_ostream> BOS;
Andrea Di Biagiod1569292018-03-26 12:04:53 +0000326
Andrea Di Biagioc6590122018-04-09 16:39:52 +0000327 mca::CodeRegions Regions(SrcMgr);
328 MCStreamerWrapper Str(Ctx, Regions);
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +0000329
330 std::unique_ptr<MCInstrInfo> MCII(TheTarget->createMCInstrInfo());
Andrea Di Biagio93c49d52018-04-25 10:18:25 +0000331
332 if (!MCPU.compare("native"))
333 MCPU = llvm::sys::getHostCPUName();
334
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +0000335 std::unique_ptr<MCSubtargetInfo> STI(
336 TheTarget->createMCSubtargetInfo(TripleName, MCPU, /* FeaturesStr */ ""));
337 if (!STI->isCPUStringValid(MCPU))
338 return 1;
339
340 if (!STI->getSchedModel().isOutOfOrder()) {
Jonas Devlieghere6adef092018-04-18 15:26:51 +0000341 WithColor::error() << "please specify an out-of-order cpu. '" << MCPU
342 << "' is an in-order cpu.\n";
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +0000343 return 1;
344 }
345
346 if (!STI->getSchedModel().hasInstrSchedModel()) {
Jonas Devlieghere6adef092018-04-18 15:26:51 +0000347 WithColor::error()
348 << "unable to find instruction-level scheduling information for"
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +0000349 << " target triple '" << TheTriple.normalize() << "' and cpu '" << MCPU
350 << "'.\n";
351
352 if (STI->getSchedModel().InstrItineraries)
Jonas Devlieghere6adef092018-04-18 15:26:51 +0000353 WithColor::note()
354 << "cpu '" << MCPU << "' provides itineraries. However, "
355 << "instruction itineraries are currently unsupported.\n";
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +0000356 return 1;
357 }
358
Andrea Di Biagio5c469442018-04-08 15:10:19 +0000359 std::unique_ptr<MCAsmParser> P(createMCAsmParser(SrcMgr, Ctx, Str, *MAI));
Andrea Di Biagioc6590122018-04-09 16:39:52 +0000360 MCAsmLexer &Lexer = P->getLexer();
361 MCACommentConsumer CC(Regions);
362 Lexer.setCommentConsumer(&CC);
363
Andrea Di Biagio5c469442018-04-08 15:10:19 +0000364 if (AssembleInput(ProgName, *P, TheTarget, *STI, *MCII, MCOptions))
365 return 1;
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +0000366
Andrea Di Biagioc6590122018-04-09 16:39:52 +0000367 if (Regions.empty()) {
Jonas Devlieghere6adef092018-04-18 15:26:51 +0000368 WithColor::error() << "no assembly instructions found.\n";
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +0000369 return 1;
370 }
371
Andrea Di Biagio8af3fe82018-03-08 16:08:43 +0000372 // Now initialize the output file.
373 auto OF = getOutputStream();
374 if (std::error_code EC = OF.getError()) {
Jonas Devlieghere6adef092018-04-18 15:26:51 +0000375 WithColor::error() << EC.message() << '\n';
Andrea Di Biagio8af3fe82018-03-08 16:08:43 +0000376 return 1;
377 }
378
Andrea Di Biagio06268642018-04-24 16:19:08 +0000379 unsigned AssemblerDialect = P->getAssemblerDialect();
380 if (OutputAsmVariant >= 0)
381 AssemblerDialect = static_cast<unsigned>(OutputAsmVariant);
382 std::unique_ptr<MCInstPrinter> IP(TheTarget->createMCInstPrinter(
383 Triple(TripleName), AssemblerDialect, *MAI, *MCII, *MRI));
384 if (!IP) {
385 WithColor::error()
386 << "unable to create instruction printer for target triple '"
387 << TheTriple.normalize() << "' with assembly variant "
388 << AssemblerDialect << ".\n";
389 return 1;
390 }
391
Andrea Di Biagio8af3fe82018-03-08 16:08:43 +0000392 std::unique_ptr<llvm::ToolOutputFile> TOF = std::move(*OF);
393
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +0000394 const MCSchedModel &SM = STI->getSchedModel();
395
396 unsigned Width = SM.IssueWidth;
397 if (DispatchWidth)
398 Width = DispatchWidth;
399
Andrea Di Biagiob5088da2018-03-23 11:50:43 +0000400 // Create an instruction builder.
Andrea Di Biagio5c469442018-04-08 15:10:19 +0000401 mca::InstrBuilder IB(*STI, *MCII);
Andrea Di Biagiob5088da2018-03-23 11:50:43 +0000402
Andrea Di Biagioc6590122018-04-09 16:39:52 +0000403 // Number each region in the sequence.
404 unsigned RegionIdx = 0;
405 for (const std::unique_ptr<mca::CodeRegion> &Region : Regions) {
406 // Skip empty code regions.
407 if (Region->empty())
408 continue;
Andrea Di Biagioff9c1092018-03-26 13:44:54 +0000409
Andrea Di Biagioc6590122018-04-09 16:39:52 +0000410 // Don't print the header of this region if it is the default region, and
411 // it doesn't have an end location.
412 if (Region->startLoc().isValid() || Region->endLoc().isValid()) {
413 TOF->os() << "\n[" << RegionIdx++ << "] Code Region";
414 StringRef Desc = Region->getDescription();
415 if (!Desc.empty())
416 TOF->os() << " - " << Desc;
417 TOF->os() << "\n\n";
Andrea Di Biagioff9c1092018-03-26 13:44:54 +0000418 }
419
Andrea Di Biagioc6590122018-04-09 16:39:52 +0000420 mca::SourceMgr S(Region->getInstructions(),
421 PrintInstructionTables ? 1 : Iterations);
422
423 if (PrintInstructionTables) {
424 mca::InstructionTables IT(STI->getSchedModel(), IB, S);
425
426 if (PrintInstructionInfoView) {
427 IT.addView(
428 llvm::make_unique<mca::InstructionInfoView>(*STI, *MCII, S, *IP));
429 }
430
431 IT.addView(llvm::make_unique<mca::ResourcePressureView>(*STI, *IP, S));
432 IT.run();
433 IT.printReport(TOF->os());
434 continue;
435 }
436
437 mca::Backend B(*STI, *MRI, IB, S, Width, RegisterFileSize, LoadQueueSize,
438 StoreQueueSize, AssumeNoAlias);
439 mca::BackendPrinter Printer(B);
440
441 Printer.addView(llvm::make_unique<mca::SummaryView>(S, Width));
442 if (PrintInstructionInfoView)
443 Printer.addView(
444 llvm::make_unique<mca::InstructionInfoView>(*STI, *MCII, S, *IP));
445
Andrea Di Biagio821f6502018-04-10 14:55:14 +0000446 if (PrintDispatchStats)
Andrea Di Biagio074ff7c2018-04-11 12:31:44 +0000447 Printer.addView(llvm::make_unique<mca::DispatchStatistics>());
Andrea Di Biagio821f6502018-04-10 14:55:14 +0000448
Andrea Di Biagiof41ad5c2018-04-11 12:12:53 +0000449 if (PrintSchedulerStats)
Andrea Di Biagio1cc29c02018-04-11 11:37:46 +0000450 Printer.addView(llvm::make_unique<mca::SchedulerStatistics>(*STI));
451
Andrea Di Biagiof41ad5c2018-04-11 12:12:53 +0000452 if (PrintRetireStats)
453 Printer.addView(llvm::make_unique<mca::RetireControlUnitStatistics>());
Andrea Di Biagioc6590122018-04-09 16:39:52 +0000454
455 if (PrintRegisterFileStats)
456 Printer.addView(llvm::make_unique<mca::RegisterFileStatistics>(*STI));
457
458 if (PrintResourcePressureView)
459 Printer.addView(
460 llvm::make_unique<mca::ResourcePressureView>(*STI, *IP, S));
461
462 if (PrintTimelineView) {
463 Printer.addView(llvm::make_unique<mca::TimelineView>(
464 *STI, *IP, S, TimelineMaxIterations, TimelineMaxCycles));
465 }
466
467 B.run();
468 Printer.printReport(TOF->os());
Andrea Di Biagiod1569292018-03-26 12:04:53 +0000469 }
470
Andrea Di Biagio8af3fe82018-03-08 16:08:43 +0000471 TOF->keep();
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +0000472 return 0;
473}