Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 1 | //===-- 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. |
| 19 | // The cpu defaults to 'generic'. |
| 20 | // The output defaults to standard output. |
| 21 | // |
| 22 | //===----------------------------------------------------------------------===// |
| 23 | |
Andrea Di Biagio | 53e6ade | 2018-03-09 12:50:42 +0000 | [diff] [blame] | 24 | #include "BackendPrinter.h" |
| 25 | #include "BackendStatistics.h" |
Andrea Di Biagio | df5d948 | 2018-03-23 19:40:04 +0000 | [diff] [blame] | 26 | #include "InstructionInfoView.h" |
Andrea Di Biagio | d156929 | 2018-03-26 12:04:53 +0000 | [diff] [blame] | 27 | #include "InstructionTables.h" |
Andrea Di Biagio | 8dabf4f | 2018-04-03 16:46:23 +0000 | [diff] [blame] | 28 | #include "RegisterFileStatistics.h" |
Andrea Di Biagio | 53e6ade | 2018-03-09 12:50:42 +0000 | [diff] [blame] | 29 | #include "ResourcePressureView.h" |
Andrea Di Biagio | 0cc66c7 | 2018-03-09 13:52:03 +0000 | [diff] [blame] | 30 | #include "SummaryView.h" |
Andrea Di Biagio | 53e6ade | 2018-03-09 12:50:42 +0000 | [diff] [blame] | 31 | #include "TimelineView.h" |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 32 | #include "llvm/MC/MCAsmInfo.h" |
| 33 | #include "llvm/MC/MCContext.h" |
| 34 | #include "llvm/MC/MCObjectFileInfo.h" |
| 35 | #include "llvm/MC/MCParser/MCTargetAsmParser.h" |
| 36 | #include "llvm/MC/MCRegisterInfo.h" |
| 37 | #include "llvm/MC/MCStreamer.h" |
| 38 | #include "llvm/Support/CommandLine.h" |
Andrea Di Biagio | 8af3fe8 | 2018-03-08 16:08:43 +0000 | [diff] [blame] | 39 | #include "llvm/Support/ErrorOr.h" |
| 40 | #include "llvm/Support/FileSystem.h" |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 41 | #include "llvm/Support/MemoryBuffer.h" |
| 42 | #include "llvm/Support/PrettyStackTrace.h" |
| 43 | #include "llvm/Support/Signals.h" |
| 44 | #include "llvm/Support/SourceMgr.h" |
| 45 | #include "llvm/Support/TargetRegistry.h" |
| 46 | #include "llvm/Support/TargetSelect.h" |
Andrea Di Biagio | 8af3fe8 | 2018-03-08 16:08:43 +0000 | [diff] [blame] | 47 | #include "llvm/Support/ToolOutputFile.h" |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 48 | |
| 49 | using namespace llvm; |
| 50 | |
| 51 | static cl::opt<std::string> |
| 52 | InputFilename(cl::Positional, cl::desc("<input file>"), cl::init("-")); |
| 53 | |
| 54 | static cl::opt<std::string> OutputFilename("o", cl::desc("Output filename"), |
| 55 | cl::init("-"), |
| 56 | cl::value_desc("filename")); |
| 57 | |
| 58 | static cl::opt<std::string> |
| 59 | ArchName("march", cl::desc("Target arch to assemble for, " |
| 60 | "see -version for available targets")); |
| 61 | |
| 62 | static cl::opt<std::string> |
| 63 | TripleName("mtriple", cl::desc("Target triple to assemble for, " |
Andrea Di Biagio | 8af3fe8 | 2018-03-08 16:08:43 +0000 | [diff] [blame] | 64 | "see -version for available targets")); |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 65 | |
| 66 | static cl::opt<std::string> |
| 67 | MCPU("mcpu", |
| 68 | cl::desc("Target a specific cpu type (-mcpu=help for details)"), |
| 69 | cl::value_desc("cpu-name"), cl::init("generic")); |
| 70 | |
| 71 | static cl::opt<unsigned> |
| 72 | OutputAsmVariant("output-asm-variant", |
| 73 | cl::desc("Syntax variant to use for output printing")); |
| 74 | |
| 75 | static cl::opt<unsigned> Iterations("iterations", |
| 76 | cl::desc("Number of iterations to run"), |
| 77 | cl::init(0)); |
| 78 | |
| 79 | static cl::opt<unsigned> DispatchWidth( |
| 80 | "dispatch", |
| 81 | cl::desc("Dispatch Width. By default it is set equal to IssueWidth"), |
| 82 | cl::init(0)); |
| 83 | |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 84 | static cl::opt<unsigned> |
| 85 | RegisterFileSize("register-file-size", |
| 86 | cl::desc("Maximum number of temporary registers which can " |
| 87 | "be used for register mappings"), |
| 88 | cl::init(0)); |
| 89 | |
Andrea Di Biagio | 29538c6 | 2018-03-23 11:33:09 +0000 | [diff] [blame] | 90 | static cl::opt<bool> |
Andrea Di Biagio | 8dabf4f | 2018-04-03 16:46:23 +0000 | [diff] [blame] | 91 | PrintRegisterFileStats("register-file-stats", |
| 92 | cl::desc("Print register file statistics"), |
| 93 | cl::init(false)); |
| 94 | |
| 95 | static cl::opt<bool> |
Andrea Di Biagio | 29538c6 | 2018-03-23 11:33:09 +0000 | [diff] [blame] | 96 | PrintResourcePressureView("resource-pressure", |
| 97 | cl::desc("Print the resource pressure view"), |
| 98 | cl::init(true)); |
| 99 | |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 100 | static cl::opt<bool> PrintTimelineView("timeline", |
| 101 | cl::desc("Print the timeline view"), |
| 102 | cl::init(false)); |
| 103 | |
| 104 | static cl::opt<unsigned> TimelineMaxIterations( |
| 105 | "timeline-max-iterations", |
| 106 | cl::desc("Maximum number of iterations to print in timeline view"), |
| 107 | cl::init(0)); |
| 108 | |
| 109 | static cl::opt<unsigned> TimelineMaxCycles( |
| 110 | "timeline-max-cycles", |
| 111 | cl::desc( |
| 112 | "Maximum number of cycles in the timeline view. Defaults to 80 cycles"), |
| 113 | cl::init(80)); |
| 114 | |
| 115 | static cl::opt<bool> PrintModeVerbose("verbose", |
| 116 | cl::desc("Enable verbose output"), |
| 117 | cl::init(false)); |
| 118 | |
Andrea Di Biagio | 8af3fe8 | 2018-03-08 16:08:43 +0000 | [diff] [blame] | 119 | static cl::opt<bool> AssumeNoAlias( |
| 120 | "noalias", |
| 121 | cl::desc("If set, it assumes that loads and stores do not alias"), |
| 122 | cl::init(true)); |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 123 | |
| 124 | static cl::opt<unsigned> |
| 125 | LoadQueueSize("lqueue", cl::desc("Size of the load queue"), cl::init(0)); |
Andrea Di Biagio | d156929 | 2018-03-26 12:04:53 +0000 | [diff] [blame] | 126 | |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 127 | static cl::opt<unsigned> |
| 128 | StoreQueueSize("squeue", cl::desc("Size of the store queue"), cl::init(0)); |
| 129 | |
Andrea Di Biagio | d156929 | 2018-03-26 12:04:53 +0000 | [diff] [blame] | 130 | static cl::opt<bool> |
| 131 | PrintInstructionTables("instruction-tables", |
| 132 | cl::desc("Print instruction tables"), |
| 133 | cl::init(false)); |
| 134 | |
Andrea Di Biagio | ff9c109 | 2018-03-26 13:44:54 +0000 | [diff] [blame] | 135 | static cl::opt<bool> |
| 136 | PrintInstructionInfoView("instruction-info", |
| 137 | cl::desc("Print the instruction info view"), |
| 138 | cl::init(true)); |
| 139 | |
Andrea Di Biagio | 5c46944 | 2018-04-08 15:10:19 +0000 | [diff] [blame] | 140 | namespace { |
| 141 | |
| 142 | const Target *getTarget(const char *ProgName) { |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 143 | TripleName = Triple::normalize(TripleName); |
| 144 | if (TripleName.empty()) |
| 145 | TripleName = Triple::normalize(sys::getDefaultTargetTriple()); |
| 146 | Triple TheTriple(TripleName); |
| 147 | |
| 148 | // Get the target specific parser. |
| 149 | std::string Error; |
| 150 | const Target *TheTarget = |
| 151 | TargetRegistry::lookupTarget(ArchName, TheTriple, Error); |
| 152 | if (!TheTarget) { |
| 153 | errs() << ProgName << ": " << Error; |
| 154 | return nullptr; |
| 155 | } |
| 156 | |
| 157 | // Return the found target. |
| 158 | return TheTarget; |
| 159 | } |
| 160 | |
Andrea Di Biagio | 5c46944 | 2018-04-08 15:10:19 +0000 | [diff] [blame] | 161 | int AssembleInput(const char *ProgName, MCAsmParser &Parser, |
| 162 | const Target *TheTarget, MCSubtargetInfo &STI, |
| 163 | MCInstrInfo &MCII, MCTargetOptions &MCOptions) { |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 164 | std::unique_ptr<MCTargetAsmParser> TAP( |
Andrea Di Biagio | 5c46944 | 2018-04-08 15:10:19 +0000 | [diff] [blame] | 165 | TheTarget->createMCAsmParser(STI, Parser, MCII, MCOptions)); |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 166 | |
| 167 | if (!TAP) { |
| 168 | errs() << ProgName |
| 169 | << ": error: this target does not support assembly parsing.\n"; |
| 170 | return 1; |
| 171 | } |
| 172 | |
Andrea Di Biagio | 5c46944 | 2018-04-08 15:10:19 +0000 | [diff] [blame] | 173 | Parser.setTargetParser(*TAP); |
| 174 | return Parser.Run(false); |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 175 | } |
| 176 | |
Andrea Di Biagio | 5c46944 | 2018-04-08 15:10:19 +0000 | [diff] [blame] | 177 | ErrorOr<std::unique_ptr<ToolOutputFile>> getOutputStream() { |
Andrea Di Biagio | 8af3fe8 | 2018-03-08 16:08:43 +0000 | [diff] [blame] | 178 | if (OutputFilename == "") |
| 179 | OutputFilename = "-"; |
| 180 | std::error_code EC; |
| 181 | auto Out = |
| 182 | llvm::make_unique<ToolOutputFile>(OutputFilename, EC, sys::fs::F_None); |
| 183 | if (!EC) |
| 184 | return std::move(Out); |
| 185 | return EC; |
| 186 | } |
| 187 | |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 188 | class MCStreamerWrapper final : public MCStreamer { |
| 189 | using InstVec = std::vector<std::unique_ptr<const MCInst>>; |
| 190 | InstVec &Insts; |
| 191 | |
| 192 | public: |
| 193 | MCStreamerWrapper(MCContext &Context, InstVec &Vec) |
| 194 | : MCStreamer(Context), Insts(Vec) {} |
| 195 | |
| 196 | // We only want to intercept the emission of new instructions. |
| 197 | virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI, |
| 198 | bool /* unused */) override { |
| 199 | Insts.emplace_back(new MCInst(Inst)); |
| 200 | } |
| 201 | |
| 202 | bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override { |
| 203 | return true; |
| 204 | } |
| 205 | |
| 206 | void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, |
| 207 | unsigned ByteAlignment) override {} |
| 208 | void EmitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr, |
| 209 | uint64_t Size = 0, unsigned ByteAlignment = 0) override {} |
| 210 | void EmitGPRel32Value(const MCExpr *Value) override {} |
| 211 | void BeginCOFFSymbolDef(const MCSymbol *Symbol) override {} |
| 212 | void EmitCOFFSymbolStorageClass(int StorageClass) override {} |
| 213 | void EmitCOFFSymbolType(int Type) override {} |
| 214 | void EndCOFFSymbolDef() override {} |
| 215 | |
| 216 | const InstVec &GetInstructionSequence() const { return Insts; } |
| 217 | }; |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 218 | } // end of anonymous namespace |
| 219 | |
| 220 | int main(int argc, char **argv) { |
| 221 | sys::PrintStackTraceOnErrorSignal(argv[0]); |
| 222 | PrettyStackTraceProgram X(argc, argv); |
| 223 | llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. |
| 224 | |
| 225 | // Initialize targets and assembly parsers. |
| 226 | llvm::InitializeAllTargetInfos(); |
| 227 | llvm::InitializeAllTargetMCs(); |
| 228 | llvm::InitializeAllAsmParsers(); |
| 229 | |
| 230 | // Enable printing of available targets when flag --version is specified. |
| 231 | cl::AddExtraVersionPrinter(TargetRegistry::printRegisteredTargetsForVersion); |
| 232 | |
| 233 | // Parse flags and initialize target options. |
| 234 | cl::ParseCommandLineOptions(argc, argv, |
| 235 | "llvm machine code performance analyzer.\n"); |
| 236 | MCTargetOptions MCOptions; |
| 237 | MCOptions.PreserveAsmComments = false; |
| 238 | |
| 239 | // Get the target from the triple. If a triple is not specified, then select |
| 240 | // the default triple for the host. If the triple doesn't correspond to any |
| 241 | // registered target, then exit with an error message. |
| 242 | const char *ProgName = argv[0]; |
| 243 | const Target *TheTarget = getTarget(ProgName); |
| 244 | if (!TheTarget) |
| 245 | return 1; |
| 246 | |
| 247 | // GetTarget() may replaced TripleName with a default triple. |
| 248 | // For safety, reconstruct the Triple object. |
| 249 | Triple TheTriple(TripleName); |
| 250 | |
| 251 | ErrorOr<std::unique_ptr<MemoryBuffer>> BufferPtr = |
| 252 | MemoryBuffer::getFileOrSTDIN(InputFilename); |
| 253 | if (std::error_code EC = BufferPtr.getError()) { |
| 254 | errs() << InputFilename << ": " << EC.message() << '\n'; |
| 255 | return 1; |
| 256 | } |
| 257 | |
| 258 | SourceMgr SrcMgr; |
| 259 | |
| 260 | // Tell SrcMgr about this buffer, which is what the parser will pick up. |
| 261 | SrcMgr.AddNewSourceBuffer(std::move(*BufferPtr), SMLoc()); |
| 262 | |
| 263 | std::unique_ptr<MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TripleName)); |
| 264 | assert(MRI && "Unable to create target register info!"); |
| 265 | |
| 266 | std::unique_ptr<MCAsmInfo> MAI(TheTarget->createMCAsmInfo(*MRI, TripleName)); |
| 267 | assert(MAI && "Unable to create target asm info!"); |
| 268 | |
| 269 | MCObjectFileInfo MOFI; |
| 270 | MCContext Ctx(MAI.get(), MRI.get(), &MOFI, &SrcMgr); |
| 271 | MOFI.InitMCObjectFileInfo(TheTriple, /* PIC= */ false, Ctx); |
| 272 | |
| 273 | std::unique_ptr<buffer_ostream> BOS; |
Andrea Di Biagio | d156929 | 2018-03-26 12:04:53 +0000 | [diff] [blame] | 274 | |
Andrea Di Biagio | 5ffd2c3 | 2018-03-26 14:25:52 +0000 | [diff] [blame] | 275 | std::unique_ptr<mca::SourceMgr> S = llvm::make_unique<mca::SourceMgr>( |
| 276 | PrintInstructionTables ? 1 : Iterations); |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 277 | MCStreamerWrapper Str(Ctx, S->getSequence()); |
| 278 | |
| 279 | std::unique_ptr<MCInstrInfo> MCII(TheTarget->createMCInstrInfo()); |
| 280 | std::unique_ptr<MCSubtargetInfo> STI( |
| 281 | TheTarget->createMCSubtargetInfo(TripleName, MCPU, /* FeaturesStr */ "")); |
| 282 | if (!STI->isCPUStringValid(MCPU)) |
| 283 | return 1; |
| 284 | |
| 285 | if (!STI->getSchedModel().isOutOfOrder()) { |
| 286 | errs() << "error: please specify an out-of-order cpu. '" << MCPU |
| 287 | << "' is an in-order cpu.\n"; |
| 288 | return 1; |
| 289 | } |
| 290 | |
| 291 | if (!STI->getSchedModel().hasInstrSchedModel()) { |
| 292 | errs() |
| 293 | << "error: unable to find instruction-level scheduling information for" |
| 294 | << " target triple '" << TheTriple.normalize() << "' and cpu '" << MCPU |
| 295 | << "'.\n"; |
| 296 | |
| 297 | if (STI->getSchedModel().InstrItineraries) |
| 298 | errs() << "note: cpu '" << MCPU << "' provides itineraries. However, " |
| 299 | << "instruction itineraries are currently unsupported.\n"; |
| 300 | return 1; |
| 301 | } |
| 302 | |
| 303 | std::unique_ptr<MCInstPrinter> IP(TheTarget->createMCInstPrinter( |
| 304 | Triple(TripleName), OutputAsmVariant, *MAI, *MCII, *MRI)); |
| 305 | if (!IP) { |
| 306 | errs() << "error: unable to create instruction printer for target triple '" |
| 307 | << TheTriple.normalize() << "' with assembly variant " |
| 308 | << OutputAsmVariant << ".\n"; |
| 309 | return 1; |
| 310 | } |
| 311 | |
Andrea Di Biagio | 5c46944 | 2018-04-08 15:10:19 +0000 | [diff] [blame] | 312 | std::unique_ptr<MCAsmParser> P(createMCAsmParser(SrcMgr, Ctx, Str, *MAI)); |
| 313 | if (AssembleInput(ProgName, *P, TheTarget, *STI, *MCII, MCOptions)) |
| 314 | return 1; |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 315 | |
| 316 | if (S->isEmpty()) { |
| 317 | errs() << "error: no assembly instructions found.\n"; |
| 318 | return 1; |
| 319 | } |
| 320 | |
Andrea Di Biagio | 8af3fe8 | 2018-03-08 16:08:43 +0000 | [diff] [blame] | 321 | // Now initialize the output file. |
| 322 | auto OF = getOutputStream(); |
| 323 | if (std::error_code EC = OF.getError()) { |
| 324 | errs() << EC.message() << '\n'; |
| 325 | return 1; |
| 326 | } |
| 327 | |
| 328 | std::unique_ptr<llvm::ToolOutputFile> TOF = std::move(*OF); |
| 329 | |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 330 | const MCSchedModel &SM = STI->getSchedModel(); |
| 331 | |
| 332 | unsigned Width = SM.IssueWidth; |
| 333 | if (DispatchWidth) |
| 334 | Width = DispatchWidth; |
| 335 | |
Andrea Di Biagio | b5088da | 2018-03-23 11:50:43 +0000 | [diff] [blame] | 336 | // Create an instruction builder. |
Andrea Di Biagio | 5c46944 | 2018-04-08 15:10:19 +0000 | [diff] [blame] | 337 | mca::InstrBuilder IB(*STI, *MCII); |
Andrea Di Biagio | b5088da | 2018-03-23 11:50:43 +0000 | [diff] [blame] | 338 | |
Andrea Di Biagio | d156929 | 2018-03-26 12:04:53 +0000 | [diff] [blame] | 339 | if (PrintInstructionTables) { |
Andrea Di Biagio | 5c46944 | 2018-04-08 15:10:19 +0000 | [diff] [blame] | 340 | mca::InstructionTables IT(STI->getSchedModel(), IB, *S); |
Andrea Di Biagio | ff9c109 | 2018-03-26 13:44:54 +0000 | [diff] [blame] | 341 | |
| 342 | if (PrintInstructionInfoView) { |
Andrea Di Biagio | 5ffd2c3 | 2018-03-26 14:25:52 +0000 | [diff] [blame] | 343 | IT.addView( |
| 344 | llvm::make_unique<mca::InstructionInfoView>(*STI, *MCII, *S, *IP)); |
Andrea Di Biagio | ff9c109 | 2018-03-26 13:44:54 +0000 | [diff] [blame] | 345 | } |
| 346 | |
Andrea Di Biagio | 5ffd2c3 | 2018-03-26 14:25:52 +0000 | [diff] [blame] | 347 | IT.addView(llvm::make_unique<mca::ResourcePressureView>(*STI, *IP, *S)); |
Andrea Di Biagio | d156929 | 2018-03-26 12:04:53 +0000 | [diff] [blame] | 348 | IT.run(); |
Andrea Di Biagio | 5ffd2c3 | 2018-03-26 14:25:52 +0000 | [diff] [blame] | 349 | IT.printReport(TOF->os()); |
Andrea Di Biagio | d156929 | 2018-03-26 12:04:53 +0000 | [diff] [blame] | 350 | TOF->keep(); |
| 351 | return 0; |
| 352 | } |
| 353 | |
Andrea Di Biagio | 5c46944 | 2018-04-08 15:10:19 +0000 | [diff] [blame] | 354 | mca::Backend B(*STI, *MRI, IB, *S, Width, RegisterFileSize, LoadQueueSize, |
| 355 | StoreQueueSize, AssumeNoAlias); |
| 356 | mca::BackendPrinter Printer(B); |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 357 | |
Andrea Di Biagio | 5c46944 | 2018-04-08 15:10:19 +0000 | [diff] [blame] | 358 | Printer.addView(llvm::make_unique<mca::SummaryView>(*S, Width)); |
Andrea Di Biagio | df5d948 | 2018-03-23 19:40:04 +0000 | [diff] [blame] | 359 | |
Andrea Di Biagio | ff9c109 | 2018-03-26 13:44:54 +0000 | [diff] [blame] | 360 | if (PrintInstructionInfoView) |
Andrea Di Biagio | 5c46944 | 2018-04-08 15:10:19 +0000 | [diff] [blame] | 361 | Printer.addView( |
Andrea Di Biagio | ff9c109 | 2018-03-26 13:44:54 +0000 | [diff] [blame] | 362 | llvm::make_unique<mca::InstructionInfoView>(*STI, *MCII, *S, *IP)); |
Andrea Di Biagio | 8af3fe8 | 2018-03-08 16:08:43 +0000 | [diff] [blame] | 363 | |
Andrea Di Biagio | 3562248 | 2018-03-22 10:19:20 +0000 | [diff] [blame] | 364 | if (PrintModeVerbose) |
Andrea Di Biagio | 5c46944 | 2018-04-08 15:10:19 +0000 | [diff] [blame] | 365 | Printer.addView(llvm::make_unique<mca::BackendStatistics>(*STI)); |
Andrea Di Biagio | 8af3fe8 | 2018-03-08 16:08:43 +0000 | [diff] [blame] | 366 | |
Andrea Di Biagio | 8dabf4f | 2018-04-03 16:46:23 +0000 | [diff] [blame] | 367 | if (PrintRegisterFileStats) |
Andrea Di Biagio | 5c46944 | 2018-04-08 15:10:19 +0000 | [diff] [blame] | 368 | Printer.addView(llvm::make_unique<mca::RegisterFileStatistics>(*STI)); |
Andrea Di Biagio | 8dabf4f | 2018-04-03 16:46:23 +0000 | [diff] [blame] | 369 | |
Andrea Di Biagio | 29538c6 | 2018-03-23 11:33:09 +0000 | [diff] [blame] | 370 | if (PrintResourcePressureView) |
Andrea Di Biagio | 5c46944 | 2018-04-08 15:10:19 +0000 | [diff] [blame] | 371 | Printer.addView( |
Andrea Di Biagio | 94fafdf | 2018-03-24 16:05:36 +0000 | [diff] [blame] | 372 | llvm::make_unique<mca::ResourcePressureView>(*STI, *IP, *S)); |
Andrea Di Biagio | 8af3fe8 | 2018-03-08 16:08:43 +0000 | [diff] [blame] | 373 | |
| 374 | if (PrintTimelineView) { |
Andrea Di Biagio | 5c46944 | 2018-04-08 15:10:19 +0000 | [diff] [blame] | 375 | Printer.addView(llvm::make_unique<mca::TimelineView>( |
Andrea Di Biagio | 3562248 | 2018-03-22 10:19:20 +0000 | [diff] [blame] | 376 | *STI, *IP, *S, TimelineMaxIterations, TimelineMaxCycles)); |
Andrea Di Biagio | 8af3fe8 | 2018-03-08 16:08:43 +0000 | [diff] [blame] | 377 | } |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 378 | |
Andrea Di Biagio | 5c46944 | 2018-04-08 15:10:19 +0000 | [diff] [blame] | 379 | B.run(); |
| 380 | Printer.printReport(TOF->os()); |
Andrea Di Biagio | 8af3fe8 | 2018-03-08 16:08:43 +0000 | [diff] [blame] | 381 | TOF->keep(); |
| 382 | |
Andrea Di Biagio | 3a6b092 | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 383 | return 0; |
| 384 | } |