Jlm
Command.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Nico Reißmann <nico.reissmann@gmail.com>
3  * See COPYING for terms of redistribution.
4  */
5 
8 #include <jlm/llvm/DotWriter.hpp>
25 #include <jlm/llvm/opt/pull.hpp>
26 #include <jlm/llvm/opt/push.hpp>
30 #include <jlm/llvm/opt/unroll.hpp>
31 #include <jlm/rvsdg/view.hpp>
32 #include <jlm/tooling/Command.hpp>
33 #include <jlm/tooling/CommandPaths.hpp>
34 
35 #include <llvm/IR/Module.h>
36 
37 #ifdef ENABLE_MLIR
40 #endif
41 
42 #include <llvm/IR/LLVMContext.h>
43 #include <llvm/IRReader/IRReader.h>
44 #include <llvm/Support/raw_os_ostream.h>
45 #include <llvm/Support/SourceMgr.h>
46 
47 #include <sys/stat.h>
48 
49 #include <fstream>
50 #include <unordered_map>
51 
52 namespace jlm::tooling
53 {
54 
55 Command::~Command() = default;
56 
57 void
58 Command::Run() const
59 {
60  const auto command = ToString();
61  const auto returnCode = system(command.c_str());
62  if (returnCode != EXIT_SUCCESS)
63  {
64  throw util::Error(
65  util::strfmt("Subcommand failed with status code ", returnCode, ": ", command));
66  }
67 }
68 
70 
71 std::string
73 {
74  return "PrintCommands";
75 }
76 
77 void
79 {
81  {
82  if (node != &CommandGraph_->GetEntryNode() && node != &CommandGraph_->GetExitNode())
83  std::cout << node->GetCommand().ToString() << "\n";
84  }
85 }
86 
87 std::unique_ptr<CommandGraph>
88 PrintCommandsCommand::Create(std::unique_ptr<CommandGraph> commandGraph)
89 {
90  std::unique_ptr<CommandGraph> newCommandGraph(new CommandGraph());
91  auto & printCommandsNode =
92  PrintCommandsCommand::Create(*newCommandGraph, std::move(commandGraph));
93  newCommandGraph->GetEntryNode().AddEdge(printCommandsNode);
94  printCommandsNode.AddEdge(newCommandGraph->GetExitNode());
95  return newCommandGraph;
96 }
97 
98 ClangCommand::~ClangCommand() = default;
99 
100 std::string
102 {
103  std::string inputFiles;
104  for (auto & inputFile : InputFiles_)
105  inputFiles += inputFile.to_str() + " ";
106 
107  std::string libraryPaths;
108  for (auto & libraryPath : LibraryPaths_)
109  libraryPaths += "-L" + libraryPath + " ";
110 
111  std::string libraries;
112  for (const auto & library : Libraries_)
113  libraries += "-l" + library + " ";
114 
115  std::string includePaths;
116  for (auto & includePath : IncludePaths_)
117  includePaths += "-I" + includePath + " ";
118 
119  std::string macroDefinitions;
120  for (auto & macroDefinition : MacroDefinitions_)
121  macroDefinitions += "-D" + macroDefinition + " ";
122 
123  std::string warnings;
124  for (auto & warning : Warnings_)
125  warnings += "-W" + warning + " ";
126 
127  std::string flags;
128  for (auto & flag : Flags_)
129  flags += "-f" + flag + " ";
130 
131  std::string arguments;
132  if (UsePthreads_)
133  arguments += "-pthread ";
134 
135  if (Verbose_)
136  arguments += "-v ";
137 
138  if (Rdynamic_)
139  arguments += "-rdynamic ";
140 
141  if (Suppress_)
142  arguments += "-w ";
143 
144  if (Md_)
145  {
146  arguments += "-MD ";
147  arguments += "-MF " + DependencyFile_.to_str() + " ";
148  arguments += "-MT " + Mt_ + " ";
149  }
150 
151  std::string languageStandardArgument = LanguageStandard_ != LanguageStandard::Unspecified
152  ? "-std=" + ToString(LanguageStandard_) + " "
153  : "";
154 
155  std::string clangArguments;
156  if (!ClangArguments_.empty())
157  {
158  for (auto & clangArgument : ClangArguments_)
159  clangArguments += "-Xclang " + ToString(clangArgument) + " ";
160  }
161 
162  /*
163  * TODO: Remove LinkerCommand_ attribute and merge both paths into a single strfmt() call.
164  */
165  if (LinkerCommand_)
166  {
167  return util::strfmt(
168  clangpath.to_str() + " ",
169  "-no-pie -O0 ",
170  arguments,
171  inputFiles,
172  "-o ",
174  " ",
175  libraryPaths,
176  libraries);
177  }
178  else
179  {
180  return util::strfmt(
181  clangpath.to_str() + " ",
182  arguments,
183  " ",
184  warnings,
185  " ",
186  flags,
187  " ",
188  languageStandardArgument,
189  ReplaceAll(macroDefinitions, std::string("\""), std::string("\\\"")),
190  " ",
191  includePaths,
192  " ",
193  "-S -emit-llvm ",
194  clangArguments,
195  "-o ",
197  " ",
198  inputFiles);
199  }
200 }
201 
202 std::string
203 ClangCommand::ToString(const LanguageStandard & languageStandard)
204 {
205  static std::unordered_map<LanguageStandard, const char *> map(
207  { LanguageStandard::Gnu89, "gnu89" },
208  { LanguageStandard::Gnu99, "gnu99" },
209  { LanguageStandard::C89, "c89" },
210  { LanguageStandard::C99, "c99" },
211  { LanguageStandard::C11, "c11" },
212  { LanguageStandard::Cpp98, "c++98" },
213  { LanguageStandard::Cpp03, "c++03" },
214  { LanguageStandard::Cpp11, "c++11" },
215  { LanguageStandard::Cpp14, "c++14" } });
216 
217  JLM_ASSERT(map.find(languageStandard) != map.end());
218  return map[languageStandard];
219 }
220 
221 std::string
222 ClangCommand::ToString(const ClangArgument & clangArgument)
223 {
224  static std::unordered_map<ClangArgument, const char *> map({
225  { ClangArgument::DisableO0OptNone, "-disable-O0-optnone" },
226  });
227 
228  JLM_ASSERT(map.find(clangArgument) != map.end());
229  return map[clangArgument];
230 }
231 
232 std::string
233 ClangCommand::ReplaceAll(std::string str, const std::string & from, const std::string & to)
234 {
235  size_t start_pos = 0;
236  while ((start_pos = str.find(from, start_pos)) != std::string::npos)
237  {
238  str.replace(start_pos, from.length(), to);
239  start_pos += to.length();
240  }
241  return str;
242 }
243 
244 LlcCommand::~LlcCommand() = default;
245 
246 std::string
248 {
249  return util::strfmt(
250  llcpath.to_str() + " ",
251  "-",
253  " ",
254  "--relocation-model=",
256  " ",
257  "-filetype=obj ",
258  "-o ",
260  " ",
261  InputFile_.to_str());
262 }
263 
264 std::string
265 LlcCommand::ToString(const OptimizationLevel & optimizationLevel)
266 {
267  static std::unordered_map<OptimizationLevel, const char *> map(
268  { { OptimizationLevel::O0, "O0" },
269  { OptimizationLevel::O1, "O1" },
270  { OptimizationLevel::O2, "O2" },
271  { OptimizationLevel::O3, "O3" } });
272 
273  JLM_ASSERT(map.find(optimizationLevel) != map.end());
274  return map[optimizationLevel];
275 }
276 
277 std::string
278 LlcCommand::ToString(const RelocationModel & relocationModel)
279 {
280  static std::unordered_map<RelocationModel, const char *> map({
281  { RelocationModel::Static, "static" },
282  { RelocationModel::Pic, "pic" },
283  });
284 
285  JLM_ASSERT(map.find(relocationModel) != map.end());
286  return map[relocationModel];
287 }
288 
290 
292  std::string programName,
293  const jlm::tooling::JlmOptCommandLineOptions & commandLineOptions)
294  : ProgramName_(std::move(programName)),
295  CommandLineOptions_(std::move(commandLineOptions))
296 {}
297 
298 std::string
300 {
301  std::string optimizationArguments;
302  for (auto & optimization : CommandLineOptions_.GetOptimizationIds())
303  optimizationArguments +=
304  "--" + std::string(JlmOptCommandLineOptions::ToCommandLineArgument(optimization)) + " ";
305 
306  auto inputFormatArgument = "--input-format="
309  + " ";
310 
311  auto outputFormatArgument = "--output-format="
314  + " ";
315 
316  auto outputFileArgument = !CommandLineOptions_.GetOutputFile().to_str().empty()
317  ? "-o " + CommandLineOptions_.GetOutputFile().to_str() + " "
318  : "";
319 
320  std::string statisticsArguments;
321  auto & demandedStatistics =
323  for (auto & statisticsId : demandedStatistics.Items())
324  {
325  statisticsArguments +=
326  "--" + std::string(JlmOptCommandLineOptions::ToCommandLineArgument(statisticsId)) + " ";
327  }
328 
329  std::string statisticsDirArgument =
331  + " ";
332 
333  return util::strfmt(
334  ProgramName_,
335  " ",
336  inputFormatArgument,
337  outputFormatArgument,
338  optimizationArguments,
339  statisticsDirArgument,
340  statisticsArguments,
341  outputFileArgument,
343 }
344 
345 void
347 {
348  jlm::util::StatisticsCollector statisticsCollector(
350 
351  auto rvsdgModule = ParseInputFile(
354  statisticsCollector);
355 
356  llvm::LlvmDotWriter dotWriter;
358  *rvsdgModule,
359  statisticsCollector,
361  dotWriter,
363 
365  *rvsdgModule,
368  statisticsCollector);
369 
370  statisticsCollector.PrintStatistics();
371 }
372 
373 std::vector<std::shared_ptr<rvsdg::Transformation>>
375 {
376  std::unordered_map<
378  std::shared_ptr<rvsdg::Transformation>>
379  transformations;
380 
381  std::vector<std::shared_ptr<rvsdg::Transformation>> transformationSequence;
382  for (auto optimizationId : CommandLineOptions_.GetOptimizationIds())
383  {
384  if (auto it = transformations.find(optimizationId); it != transformations.end())
385  {
386  transformationSequence.push_back(it->second);
387  }
388  else
389  {
390  auto transformation = CreateTransformation(optimizationId);
391  transformationSequence.push_back(transformation);
392  transformations[optimizationId] = transformation;
393  }
394  }
395 
396  return transformationSequence;
397 }
398 
399 std::shared_ptr<rvsdg::Transformation>
401 {
402  using Andersen = llvm::aa::Andersen;
403  using AgnosticMrs = llvm::aa::AgnosticModRefSummarizer;
404  using RegionAwareMrs = llvm::aa::RegionAwareModRefSummarizer;
405 
406  switch (optimizationId)
407  {
409  return std::make_shared<llvm::aa::PointsToAnalysisStateEncoder<Andersen, AgnosticMrs>>();
411  return std::make_shared<llvm::aa::PointsToAnalysisStateEncoder<Andersen, RegionAwareMrs>>();
413  return std::make_shared<llvm::CommonNodeElimination>();
415  return std::make_shared<llvm::DeadNodeElimination>();
417  return std::make_shared<llvm::FunctionInlining>();
419  return std::make_shared<llvm::IfConversion>();
421  return std::make_shared<llvm::InvariantValueRedirection>();
423  return std::make_shared<llvm::LoadChainSeparation>();
425  return std::make_shared<llvm::LoopUnrolling>(4);
427  return std::make_shared<llvm::LoopUnswitching>();
429  return std::make_shared<llvm::NodeSinking>();
431  return std::make_shared<llvm::NodeHoisting>();
433  return std::make_shared<llvm::NodeReduction>();
435  return std::make_shared<llvm::PredicateCorrelation>();
437  return std::make_shared<llvm::RvsdgTreePrinter>(
440  return std::make_shared<llvm::ScalarEvolution>();
441  default:
442  JLM_UNREACHABLE("Unhandled optimization id.");
443  }
444 }
445 
446 std::unique_ptr<llvm::LlvmRvsdgModule>
448  const util::FilePath & llvmIrFile,
449  util::StatisticsCollector & statisticsCollector) const
450 {
451  ::llvm::LLVMContext llvmContext;
452  ::llvm::SMDiagnostic diagnostic;
453  auto llvmModule = ::llvm::parseIRFile(llvmIrFile.to_str(), diagnostic, llvmContext);
454 
455  if (llvmModule == nullptr)
456  {
457  std::string errors;
458  ::llvm::raw_string_ostream os(errors);
459  diagnostic.print(ProgramName_.c_str(), os);
460  throw util::Error(errors);
461  }
462 
463  auto interProceduralGraphModule = llvm::ConvertLlvmModule(*llvmModule);
464 
465  // Dispose of Llvm module. It is no longer needed.
466  llvmModule.reset();
467 
468  auto rvsdgModule =
469  llvm::ConvertInterProceduralGraphModule(*interProceduralGraphModule, statisticsCollector);
470 
471  return rvsdgModule;
472 }
473 
474 std::unique_ptr<llvm::LlvmRvsdgModule>
476 {
477 #ifdef ENABLE_MLIR
479  return rvsdggen.ReadAndConvertMlir(mlirIrFile);
480 #else
482  "This version of jlm-opt has not been compiled with support for the MLIR backend\n");
483 #endif
484 }
485 
486 std::unique_ptr<llvm::LlvmRvsdgModule>
488  const util::FilePath & inputFile,
489  const JlmOptCommandLineOptions::InputFormat & inputFormat,
490  util::StatisticsCollector & statisticsCollector) const
491 {
493  {
494  return ParseLlvmIrFile(inputFile, statisticsCollector);
495  }
497  {
498  return ParseMlirIrFile(inputFile, statisticsCollector);
499  }
500  else
501  {
502  JLM_UNREACHABLE("Unhandled input format.");
503  }
504 }
505 
506 void
508  const llvm::LlvmRvsdgModule & rvsdgModule,
509  const util::FilePath & outputFile,
511 {
512  auto ascii = view(&rvsdgModule.Rvsdg().GetRootRegion());
513 
514  if (outputFile == "")
515  {
516  std::cout << ascii << std::flush;
517  }
518  else
519  {
520  std::ofstream fileStream(outputFile.to_str());
521  fileStream << ascii;
522  fileStream.close();
523  }
524 }
525 
526 void
528  const llvm::LlvmRvsdgModule & rvsdgModule,
529  const util::FilePath & outputFile,
531 {
532  auto fd = outputFile == "" ? stdout : fopen(outputFile.to_str().c_str(), "w");
533 
534  view_xml(&rvsdgModule.Rvsdg().GetRootRegion(), fd);
535 
536  if (fd != stdout)
537  fclose(fd);
538 }
539 
540 void
542  llvm::LlvmRvsdgModule & rvsdgModule,
543  const util::FilePath & outputFile,
544  util::StatisticsCollector & statisticsCollector)
545 {
546  auto jlm_module =
547  llvm::RvsdgToIpGraphConverter::CreateAndConvertModule(rvsdgModule, statisticsCollector);
548 
549  ::llvm::LLVMContext ctx;
550  auto llvm_module = llvm::IpGraphToLlvmConverter::CreateAndConvertModule(*jlm_module, ctx);
551 
552  if (outputFile == "")
553  {
554  ::llvm::raw_os_ostream os(std::cout);
555  llvm_module->print(os, nullptr);
556  }
557  else
558  {
559  std::error_code ec;
560  ::llvm::raw_fd_ostream os(outputFile.to_str(), ec);
561  llvm_module->print(os, nullptr);
562  }
563 }
564 
565 void
567  const llvm::LlvmRvsdgModule & rvsdgModule,
568  const util::FilePath & outputFile,
570 {
571 #ifdef ENABLE_MLIR
573  auto omega = mlirgen.ConvertModule(rvsdgModule);
574  mlirgen.Print(omega, outputFile);
575 #else
576  throw util::Error(
577  "This version of jlm-opt has not been compiled with support for the MLIR backend\n");
578 #endif
579 }
580 
581 void
583  const llvm::LlvmRvsdgModule & rvsdgModule,
584  const util::FilePath & outputFile,
586 {
587  auto & rootRegion = rvsdgModule.Rvsdg().GetRootRegion();
588  auto tree = rvsdg::Region::ToTree(rootRegion);
589 
590  if (outputFile == "")
591  {
592  std::cout << tree << std::flush;
593  }
594  else
595  {
596  std::ofstream fs;
597  fs.open(outputFile.to_str());
598  fs << tree;
599  fs.close();
600  }
601 }
602 
603 void
605  const llvm::LlvmRvsdgModule & rvsdgModule,
606  const util::FilePath & outputFile,
608 {
609  auto & rootRegion = rvsdgModule.Rvsdg().GetRootRegion();
610 
611  util::graph::Writer writer;
612  llvm::LlvmDotWriter dotWriter;
613  dotWriter.WriteGraphs(writer, rootRegion, true);
614 
615  if (outputFile == "")
616  {
618  }
619  else
620  {
621  std::ofstream fs;
622  fs.open(outputFile.to_str());
624  fs.close();
625  }
626 }
627 
628 void
630  llvm::LlvmRvsdgModule & rvsdgModule,
631  const util::FilePath & outputFile,
632  const JlmOptCommandLineOptions::OutputFormat & outputFormat,
633  util::StatisticsCollector & statisticsCollector)
634 {
636  {
637  PrintAsAscii(rvsdgModule, outputFile, statisticsCollector);
638  }
640  {
641  PrintAsXml(rvsdgModule, outputFile, statisticsCollector);
642  }
644  {
645  PrintAsLlvm(rvsdgModule, outputFile, statisticsCollector);
646  }
648  {
649  PrintAsMlir(rvsdgModule, outputFile, statisticsCollector);
650  }
652  {
653  PrintAsRvsdgTree(rvsdgModule, outputFile, statisticsCollector);
654  }
656  {
657  PrintAsDot(rvsdgModule, outputFile, statisticsCollector);
658  }
659  else
660  {
661  JLM_UNREACHABLE("Unhandled output format.");
662  }
663 }
664 
665 MkdirCommand::~MkdirCommand() noexcept = default;
666 
667 std::string
669 {
670  return util::strfmt("mkdir ", Path_.to_str());
671 }
672 
673 void
675 {
676  if (mkdir(Path_.to_str().c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0)
677  throw util::Error("mkdir failed: " + Path_.to_str());
678 }
679 
680 LlvmOptCommand::~LlvmOptCommand() noexcept = default;
681 
682 std::string
684 {
685  std::string optimizationArguments;
686  if (!Optimizations_.empty())
687  {
688  optimizationArguments = "-passes=";
689  bool first = true;
690  for (auto & optimization : Optimizations_)
691  {
692  if (first)
693  {
694  optimizationArguments += ToString(optimization) + " ";
695  first = false;
696  }
697  else
698  {
699  optimizationArguments += "," + ToString(optimization) + " ";
700  }
701  }
702  }
703 
704  return util::strfmt(
705  clangpath.Dirname().Join("opt").to_str(),
706  " ",
707  optimizationArguments,
708  WriteLlvmAssembly_ ? "-S " : "",
709  "-o ",
710  OutputFile().to_str(),
711  " ",
712  InputFile_.to_str());
713 }
714 
715 std::string
717 {
718  static std::unordered_map<Optimization, const char *> map({
719  { Optimization::Mem2Reg, "mem2reg" },
720  });
721 
722  JLM_ASSERT(map.find(optimization) != map.end());
723  return map[optimization];
724 }
725 
726 LlvmLinkCommand::~LlvmLinkCommand() noexcept = default;
727 
728 std::string
730 {
731  std::string inputFilesArgument;
732  for (auto & inputFile : InputFiles_)
733  inputFilesArgument += inputFile.to_str() + " ";
734 
735  return util::strfmt(
736  clangpath.Dirname().Join("llvm-link").to_str(),
737  " ",
738  WriteLlvmAssembly_ ? "-S " : "",
739  Verbose_ ? "-v " : "",
740  "-o ",
741  OutputFile_.to_str(),
742  " ",
743  inputFilesArgument);
744 }
745 
746 JlmHlsCommand::~JlmHlsCommand() noexcept = default;
747 
748 std::string
750 {
751  std::string options;
752  for (auto & o : Options)
753  {
754  options += o + " ";
755  }
756  return util::strfmt("jlm-hls ", options, "-o ", OutputFolder_.to_str(), " ", InputFile_.to_str());
757 }
758 
760 
761 std::string
763 {
764  return util::strfmt(
765  "jlm-hls ",
766  "--extract ",
767  "--hls-function ",
768  HlsFunctionName(),
769  " ",
770  " -o ",
771  OutputFolder_.to_str(),
772  " ",
773  InputFile().to_str());
774 }
775 
776 }
static std::unique_ptr<::llvm::Module > CreateAndConvertModule(InterProceduralGraphModule &ipGraphModule, ::llvm::LLVMContext &ctx)
static std::unique_ptr< InterProceduralGraphModule > CreateAndConvertModule(LlvmRvsdgModule &rvsdgModule, util::StatisticsCollector &statisticsCollector)
static void Print(::mlir::rvsdg::OmegaNode &omega, const util::FilePath &filePath)
::mlir::rvsdg::OmegaNode ConvertModule(const llvm::LlvmRvsdgModule &rvsdgModule)
std::unique_ptr< llvm::LlvmRvsdgModule > ReadAndConvertMlir(const util::FilePath &filePath)
util::graph::Graph & WriteGraphs(util::graph::Writer &writer, const Region &region, bool emitTypeGraph)
Definition: DotWriter.cpp:198
Region & GetRootRegion() const noexcept
Definition: graph.hpp:99
static std::string ToTree(const rvsdg::Region &region, const util::AnnotationMap &annotationMap) noexcept
Definition: region.cpp:471
Graph & Rvsdg() noexcept
Definition: RvsdgModule.hpp:57
static void CreateAndRun(RvsdgModule &rvsdgModule, util::StatisticsCollector &statisticsCollector, std::vector< std::shared_ptr< Transformation >> transformations, DotWriter &dotWriter, const bool dumpRvsdgDotGraphs)
Creates a transformation sequence and invokes its Run() method.
std::string ToString() const override
Definition: Command.cpp:101
std::vector< util::FilePath > InputFiles_
Definition: Command.hpp:241
std::vector< std::string > Libraries_
Definition: Command.hpp:249
std::vector< std::string > MacroDefinitions_
Definition: Command.hpp:246
std::vector< std::string > Warnings_
Definition: Command.hpp:247
std::vector< std::string > LibraryPaths_
Definition: Command.hpp:250
LanguageStandard LanguageStandard_
Definition: Command.hpp:259
util::FilePath OutputFile_
Definition: Command.hpp:242
std::vector< ClangArgument > ClangArguments_
Definition: Command.hpp:260
std::vector< std::string > Flags_
Definition: Command.hpp:248
static std::string ReplaceAll(std::string str, const std::string &from, const std::string &to)
Definition: Command.cpp:233
util::FilePath DependencyFile_
Definition: Command.hpp:243
std::vector< std::string > IncludePaths_
Definition: Command.hpp:245
static std::vector< CommandGraph::Node * > SortNodesTopological(const CommandGraph &commandGraph)
virtual void Run() const
Definition: Command.cpp:58
virtual std::string ToString() const =0
~JlmHlsCommand() noexcept override
~JlmHlsExtractCommand() noexcept override
bool DumpRvsdgDotGraphs() const noexcept
const util::FilePath & GetOutputFile() const noexcept
const llvm::RvsdgTreePrinter::Configuration & GetRvsdgTreePrinterConfiguration() const noexcept
static std::string_view ToCommandLineArgument(OptimizationId optimizationId)
const util::FilePath & GetInputFile() const noexcept
InputFormat GetInputFormat() const noexcept
OutputFormat GetOutputFormat() const noexcept
const std::vector< OptimizationId > & GetOptimizationIds() const noexcept
const util::StatisticsCollectorSettings & GetStatisticsCollectorSettings() const noexcept
std::unique_ptr< llvm::LlvmRvsdgModule > ParseMlirIrFile(const util::FilePath &inputFile, util::StatisticsCollector &statisticsCollector) const
Definition: Command.cpp:475
JlmOptCommand(std::string programName, const JlmOptCommandLineOptions &commandLineOptions)
Definition: Command.cpp:291
static void PrintAsDot(const llvm::LlvmRvsdgModule &rvsdgModule, const util::FilePath &outputFile, util::StatisticsCollector &statisticsCollector)
Definition: Command.cpp:604
static void PrintRvsdgModule(llvm::LlvmRvsdgModule &rvsdgModule, const util::FilePath &outputFile, const JlmOptCommandLineOptions::OutputFormat &outputFormat, util::StatisticsCollector &statisticsCollector)
Definition: Command.cpp:629
static void PrintAsXml(const llvm::LlvmRvsdgModule &rvsdgModule, const util::FilePath &outputFile, util::StatisticsCollector &statisticsCollector)
Definition: Command.cpp:527
static void PrintAsLlvm(llvm::LlvmRvsdgModule &rvsdgModule, const util::FilePath &outputFile, util::StatisticsCollector &statisticsCollector)
Definition: Command.cpp:541
static void PrintAsAscii(const llvm::LlvmRvsdgModule &rvsdgModule, const util::FilePath &outputFile, util::StatisticsCollector &statisticsCollector)
Definition: Command.cpp:507
std::unique_ptr< llvm::LlvmRvsdgModule > ParseLlvmIrFile(const util::FilePath &inputFile, util::StatisticsCollector &statisticsCollector) const
Definition: Command.cpp:447
static void PrintAsRvsdgTree(const llvm::LlvmRvsdgModule &rvsdgModule, const util::FilePath &outputFile, util::StatisticsCollector &statisticsCollector)
Definition: Command.cpp:582
std::shared_ptr< rvsdg::Transformation > CreateTransformation(JlmOptCommandLineOptions::OptimizationId optimizationId) const
Definition: Command.cpp:400
void Run() const override
Definition: Command.cpp:346
JlmOptCommandLineOptions CommandLineOptions_
Definition: Command.hpp:431
std::string ToString() const override
Definition: Command.cpp:299
static void PrintAsMlir(const llvm::LlvmRvsdgModule &rvsdgModule, const util::FilePath &outputFile, util::StatisticsCollector &statisticsCollector)
Definition: Command.cpp:566
std::unique_ptr< llvm::LlvmRvsdgModule > ParseInputFile(const util::FilePath &inputFile, const JlmOptCommandLineOptions::InputFormat &inputFormat, util::StatisticsCollector &statisticsCollector) const
Definition: Command.cpp:487
std::vector< std::shared_ptr< rvsdg::Transformation > > GetTransformations() const
Definition: Command.cpp:374
RelocationModel RelocationModel_
Definition: Command.hpp:328
util::FilePath InputFile_
Definition: Command.hpp:329
std::string ToString() const override
Definition: Command.cpp:247
OptimizationLevel OptimizationLevel_
Definition: Command.hpp:327
util::FilePath OutputFile_
Definition: Command.hpp:330
~LlvmLinkCommand() noexcept override
~LlvmOptCommand() noexcept override
std::string ToString() const override
Definition: Command.cpp:683
~MkdirCommand() noexcept override
util::FilePath Path_
Definition: Command.hpp:460
void Run() const override
Definition: Command.cpp:674
std::unique_ptr< CommandGraph > CommandGraph_
Definition: Command.hpp:80
std::string ToString() const override
Definition: Command.cpp:72
void Run() const override
Definition: Command.cpp:78
static std::unique_ptr< CommandGraph > Create(std::unique_ptr< CommandGraph > commandGraph)
Definition: Command.cpp:88
const std::string & to_str() const noexcept
Definition: file.hpp:275
const HashSet< Statistics::Id > & GetDemandedStatistics() const noexcept
Definition: Statistics.hpp:323
const FilePath & GetOutputDirectory() const noexcept
Definition: Statistics.hpp:353
void PrintStatistics()
Print collected statistics to file. If no statistics have been collected, this is a no-op.
Definition: Statistics.cpp:164
void outputAllGraphs(std::ostream &out, OutputFormat format)
#define JLM_ASSERT(x)
Definition: common.hpp:16
#define JLM_UNREACHABLE(msg)
Definition: common.hpp:43
std::unique_ptr< InterProceduralGraphModule > ConvertLlvmModule(::llvm::Module &llvmModule)
static std::unique_ptr< LlvmRvsdgModule > ConvertInterProceduralGraphModule(InterProceduralGraphModule &interProceduralGraphModule, InterProceduralGraphToRvsdgStatisticsCollector &statisticsCollector)
std::string to_str(const InterProceduralGraph &clg)
Definition: print.cpp:80
static std::string ToString(const std::vector< MemoryNodeId > &memoryNodeIds)
std::string view(const rvsdg::Region *region)
Definition: view.cpp:142
void view_xml(const rvsdg::Region *region, FILE *out)
Definition: view.cpp:369
static std::string strfmt(Args... args)
Definition: strfmt.hpp:35