Jlm
Loading...
Searching...
No Matches
CommandGraphGenerator.hpp
Go to the documentation of this file.
1/*
2 * Copyright 2022 Nico Reißmann <nico.reissmann@gmail.com>
3 * See COPYING for terms of redistribution.
4 */
5
6#ifndef JLM_TOOLING_COMMANDGRAPHGENERATOR_HPP
7#define JLM_TOOLING_COMMANDGRAPHGENERATOR_HPP
8
11
12#include <memory>
13
14namespace jlm::tooling
15{
16
17class CommandGraph;
18
22template<class T>
24{
25 static_assert(
26 std::is_base_of<CommandLineOptions, T>::value,
27 "T is not derived from CommandLineOptions.");
28
29public:
30 virtual ~CommandGraphGenerator() noexcept = default;
31
38 [[nodiscard]] virtual std::unique_ptr<CommandGraph>
39 GenerateCommandGraph(const T & commandLineOptions) = 0;
40};
41
46{
47public:
48 ~JlcCommandGraphGenerator() noexcept override;
49
51
52 [[nodiscard]] std::unique_ptr<CommandGraph>
53 GenerateCommandGraph(const JlcCommandLineOptions & commandLineOptions) override;
54
55 [[nodiscard]] static std::unique_ptr<CommandGraph>
56 Generate(const JlcCommandLineOptions & commandLineOptions)
57 {
58 JlcCommandGraphGenerator commandLineGenerator;
59 return commandLineGenerator.GenerateCommandGraph(commandLineOptions);
60 }
61
62private:
63 static util::FilePath
64 CreateJlmOptCommandOutputFile(const util::FilePath & inputFile);
65
66 static util::FilePath
67 CreateParserCommandOutputFile(const util::FilePath & inputFile);
68
70 ConvertLanguageStandard(const JlcCommandLineOptions::LanguageStandard & languageStandard);
71
73 ConvertOptimizationLevel(const JlcCommandLineOptions::OptimizationLevel & optimizationLevel);
74
75 static CommandGraph::Node &
76 CreateParserCommand(
77 CommandGraph & commandGraph,
78 const util::FilePath & outputFile,
79 const JlcCommandLineOptions::Compilation & compilation,
80 const JlcCommandLineOptions & commandLineOptions);
81};
82
86class JhlsCommandGraphGenerator final : public CommandGraphGenerator<JhlsCommandLineOptions>
87{
88public:
89 ~JhlsCommandGraphGenerator() noexcept override;
90
92
93 [[nodiscard]] std::unique_ptr<CommandGraph>
94 GenerateCommandGraph(const JhlsCommandLineOptions & commandLineOptions) override;
95
96 [[nodiscard]] static std::unique_ptr<CommandGraph>
97 Generate(const JhlsCommandLineOptions & commandLineOptions)
98 {
99 JhlsCommandGraphGenerator commandLineGenerator;
100 return commandLineGenerator.GenerateCommandGraph(commandLineOptions);
101 }
102
103private:
104 static util::FilePath
105 CreateParserCommandOutputFile(
106 const util::FilePath & tmpDirectory,
107 const util::FilePath & inputFile);
108
109 static util::FilePath
110 CreateJlmOptCommandOutputFile(
111 const util::FilePath & tmpDirectory,
112 const util::FilePath & inputFile);
113
115 ConvertLanguageStandard(const JhlsCommandLineOptions::LanguageStandard & languageStandard);
116
118 ConvertOptimizationLevel(const JhlsCommandLineOptions::OptimizationLevel & optimizationLevel);
119};
120
121}
122
123#endif // JLM_TOOLING_COMMANDGRAPHGENERATOR_HPP
virtual std::unique_ptr< CommandGraph > GenerateCommandGraph(const T &commandLineOptions)=0
virtual ~CommandGraphGenerator() noexcept=default
~JhlsCommandGraphGenerator() noexcept override
std::unique_ptr< CommandGraph > GenerateCommandGraph(const JhlsCommandLineOptions &commandLineOptions) override
std::unique_ptr< CommandGraph > GenerateCommandGraph(const JlcCommandLineOptions &commandLineOptions) override
~JlcCommandGraphGenerator() noexcept override