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