12 #include <unordered_map>
26 inputFile.
base() +
"-",
35 inputFile.
base() +
"-",
43 static std::unordered_map<JlcCommandLineOptions::LanguageStandard, ClangCommand::LanguageStandard>
62 JLM_ASSERT(map.find(languageStandard) != map.end());
63 return map[languageStandard];
70 static std::unordered_map<JlcCommandLineOptions::OptimizationLevel, LlcCommand::OptimizationLevel>
76 JLM_ASSERT(map.find(optimizationLevel) != map.end());
77 return map[optimizationLevel];
100 commandLineOptions.
Md_,
106 std::unique_ptr<CommandGraph>
111 std::vector<CommandGraph::Node *> leafNodes;
114 auto lastNode = &commandGraph->GetEntryNode();
116 if (compilation.RequiresParsing())
124 lastNode->AddEdge(parserCommandNode);
125 lastNode = &parserCommandNode;
128 if (compilation.RequiresOptimization())
130 auto clangCommand = util::assertedCast<ClangCommand>(&lastNode->GetCommand());
135 compilation.InputFile().
base());
138 clangCommand->OutputFile(),
142 std::move(statisticsCollectorSettings),
147 auto & jlmOptCommandNode =
149 lastNode->AddEdge(jlmOptCommandNode);
150 lastNode = &jlmOptCommandNode;
153 if (compilation.RequiresAssembly())
155 auto jlmOptCommand = util::assertedCast<JlmOptCommand>(&lastNode->GetCommand());
158 jlmOptCommand->GetCommandLineOptions().GetOutputFile(),
159 compilation.OutputFile(),
162 lastNode->AddEdge(llvmLlcCommandNode);
163 lastNode = &llvmLlcCommandNode;
166 leafNodes.push_back(lastNode);
169 std::vector<util::FilePath> linkerInputFiles;
172 if (compilation.RequiresLinking())
173 linkerInputFiles.push_back(compilation.OutputFile());
176 if (!linkerInputFiles.empty())
186 for (
const auto & leafNode : leafNodes)
187 leafNode->AddEdge(linkerCommandNode);
190 leafNodes.push_back(&linkerCommandNode);
193 for (
auto & leafNode : leafNodes)
194 leafNode->AddEdge(commandGraph->GetExitNode());
206 const util::FilePath & tmpDirectory,
207 const util::FilePath & inputFile)
224 static std::unordered_map<
245 JLM_ASSERT(map.find(languageStandard) != map.end());
246 return map[languageStandard];
253 static std::unordered_map<
261 JLM_ASSERT(map.find(optimizationLevel) != map.end());
262 return map[optimizationLevel];
265 std::unique_ptr<CommandGraph>
268 std::unique_ptr<CommandGraph> commandGraph(
new CommandGraph());
270 std::vector<CommandGraph::Node *> leaves;
271 std::vector<CommandGraph::Node *> llir;
272 std::vector<util::FilePath> llir_files;
275 std::string tmp_identifier =
"jhls-";
276 for (
const auto & compilation : commandLineOptions.
Compilations_)
278 tmp_identifier += compilation.InputFile().name() +
"-";
279 if (tmp_identifier.length() > 30)
283 const auto tmp_folder =
286 commandGraph->GetEntryNode().AddEdge(mkdir);
288 for (
const auto & compilation : commandLineOptions.
Compilations_)
292 if (compilation.RequiresParsing())
296 compilation.InputFile(),
298 compilation.DependencyFile(),
302 commandLineOptions.
Flags_,
307 commandLineOptions.
Md_,
310 { ClangCommand::ClangArgument::DisableO0OptNone });
317 llir.push_back(&parserNode);
321 leaves.push_back(last);
328 for (
const auto & ll : llir)
330 ll->AddEdge(ll_link);
347 m2r1.AddEdge(extract);
354 { LlvmOptCommand::Optimization::Mem2Reg });
355 extract.AddEdge(m2r2);
376 llvmLink.AddEdge(compileMerged);
378 for (
const auto & leave : leaves)
379 leave->AddEdge(commandGraph->GetExitNode());
static FilePath createUniqueFileName(const FilePath &directory, const std::string &fileNamePrefix, const std::string &fileNameSuffix)
Generates a unique file in a given directory with a prefix and suffix.
static FilePath TempDirectoryPath()
const std::string & to_str() const noexcept
std::string base() const noexcept
Returns the base name of the file without the path.