xref: /freebsd/contrib/llvm-project/clang/lib/Driver/ToolChains/Flang.h (revision 5f757f3ff9144b609b3c433dfd370cc6bdc191ad)
1480093f4SDimitry Andric //===--- Flang.h - Flang Tool and ToolChain Implementations ====-*- C++ -*-===//
2480093f4SDimitry Andric //
3480093f4SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4480093f4SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5480093f4SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6480093f4SDimitry Andric //
7480093f4SDimitry Andric //===----------------------------------------------------------------------===//
8480093f4SDimitry Andric 
9480093f4SDimitry Andric #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_FLANG_H
10480093f4SDimitry Andric #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_FLANG_H
11480093f4SDimitry Andric 
12480093f4SDimitry Andric #include "clang/Driver/Tool.h"
13480093f4SDimitry Andric #include "clang/Driver/Action.h"
14480093f4SDimitry Andric #include "clang/Driver/Compilation.h"
15480093f4SDimitry Andric #include "clang/Driver/ToolChain.h"
16480093f4SDimitry Andric #include "llvm/Option/ArgList.h"
17480093f4SDimitry Andric #include "llvm/Support/Compiler.h"
18480093f4SDimitry Andric 
19480093f4SDimitry Andric namespace clang {
20480093f4SDimitry Andric namespace driver {
21480093f4SDimitry Andric 
22480093f4SDimitry Andric namespace tools {
23480093f4SDimitry Andric 
24480093f4SDimitry Andric /// Flang compiler tool.
25480093f4SDimitry Andric class LLVM_LIBRARY_VISIBILITY Flang : public Tool {
26e8d8bef9SDimitry Andric private:
27fe6060f1SDimitry Andric   /// Extract fortran dialect options from the driver arguments and add them to
28fe6060f1SDimitry Andric   /// the list of arguments for the generated command/job.
29fe6060f1SDimitry Andric   ///
30fe6060f1SDimitry Andric   /// \param [in] Args The list of input driver arguments
31fe6060f1SDimitry Andric   /// \param [out] CmdArgs The list of output command arguments
32bdd1243dSDimitry Andric   void addFortranDialectOptions(const llvm::opt::ArgList &Args,
33fe6060f1SDimitry Andric                                 llvm::opt::ArgStringList &CmdArgs) const;
34fe6060f1SDimitry Andric 
35e8d8bef9SDimitry Andric   /// Extract preprocessing options from the driver arguments and add them to
36e8d8bef9SDimitry Andric   /// the preprocessor command arguments.
37e8d8bef9SDimitry Andric   ///
38e8d8bef9SDimitry Andric   /// \param [in] Args The list of input driver arguments
39e8d8bef9SDimitry Andric   /// \param [out] CmdArgs The list of output command arguments
40bdd1243dSDimitry Andric   void addPreprocessingOptions(const llvm::opt::ArgList &Args,
41e8d8bef9SDimitry Andric                                llvm::opt::ArgStringList &CmdArgs) const;
42bdd1243dSDimitry Andric 
43bdd1243dSDimitry Andric   /// Extract PIC options from the driver arguments and add them to
44bdd1243dSDimitry Andric   /// the command arguments.
45bdd1243dSDimitry Andric   ///
46bdd1243dSDimitry Andric   /// \param [in] Args The list of input driver arguments
47bdd1243dSDimitry Andric   /// \param [out] CmdArgs The list of output command arguments
48bdd1243dSDimitry Andric   void addPicOptions(const llvm::opt::ArgList &Args,
49bdd1243dSDimitry Andric                      llvm::opt::ArgStringList &CmdArgs) const;
50bdd1243dSDimitry Andric 
51bdd1243dSDimitry Andric   /// Extract target options from the driver arguments and add them to
52bdd1243dSDimitry Andric   /// the command arguments.
53bdd1243dSDimitry Andric   ///
54bdd1243dSDimitry Andric   /// \param [in] Args The list of input driver arguments
55bdd1243dSDimitry Andric   /// \param [out] CmdArgs The list of output command arguments
56bdd1243dSDimitry Andric   void addTargetOptions(const llvm::opt::ArgList &Args,
57bdd1243dSDimitry Andric                         llvm::opt::ArgStringList &CmdArgs) const;
58bdd1243dSDimitry Andric 
59*5f757f3fSDimitry Andric   /// Add specific options for AArch64 target.
60*5f757f3fSDimitry Andric   ///
61*5f757f3fSDimitry Andric   /// \param [in] Args The list of input driver arguments
62*5f757f3fSDimitry Andric   /// \param [out] CmdArgs The list of output command arguments
63*5f757f3fSDimitry Andric   void AddAArch64TargetArgs(const llvm::opt::ArgList &Args,
64*5f757f3fSDimitry Andric                             llvm::opt::ArgStringList &CmdArgs) const;
65*5f757f3fSDimitry Andric 
66*5f757f3fSDimitry Andric   /// Add specific options for AMDGPU target.
67*5f757f3fSDimitry Andric   ///
68*5f757f3fSDimitry Andric   /// \param [in] Args The list of input driver arguments
69*5f757f3fSDimitry Andric   /// \param [out] CmdArgs The list of output command arguments
70*5f757f3fSDimitry Andric   void AddAMDGPUTargetArgs(const llvm::opt::ArgList &Args,
71*5f757f3fSDimitry Andric                            llvm::opt::ArgStringList &CmdArgs) const;
72*5f757f3fSDimitry Andric 
7306c3fb27SDimitry Andric   /// Extract offload options from the driver arguments and add them to
7406c3fb27SDimitry Andric   /// the command arguments.
7506c3fb27SDimitry Andric   /// \param [in] C The current compilation for the driver invocation
7606c3fb27SDimitry Andric   /// \param [in] Inputs The input infomration on the current file inputs
7706c3fb27SDimitry Andric   /// \param [in] JA The job action
7806c3fb27SDimitry Andric   /// \param [in] Args The list of input driver arguments
7906c3fb27SDimitry Andric   /// \param [out] CmdArgs The list of output command arguments
8006c3fb27SDimitry Andric   void addOffloadOptions(Compilation &C, const InputInfoList &Inputs,
8106c3fb27SDimitry Andric                          const JobAction &JA, const llvm::opt::ArgList &Args,
8206c3fb27SDimitry Andric                          llvm::opt::ArgStringList &CmdArgs) const;
8306c3fb27SDimitry Andric 
8406c3fb27SDimitry Andric   /// Extract options for code generation from the driver arguments and add them
8506c3fb27SDimitry Andric   /// to the command arguments.
8606c3fb27SDimitry Andric   ///
8706c3fb27SDimitry Andric   /// \param [in] Args The list of input driver arguments
8806c3fb27SDimitry Andric   /// \param [out] CmdArgs The list of output command arguments
8906c3fb27SDimitry Andric   void addCodegenOptions(const llvm::opt::ArgList &Args,
9006c3fb27SDimitry Andric                          llvm::opt::ArgStringList &CmdArgs) const;
9106c3fb27SDimitry Andric 
92fe6060f1SDimitry Andric   /// Extract other compilation options from the driver arguments and add them
93fe6060f1SDimitry Andric   /// to the command arguments.
94fe6060f1SDimitry Andric   ///
95fe6060f1SDimitry Andric   /// \param [in] Args The list of input driver arguments
96fe6060f1SDimitry Andric   /// \param [out] CmdArgs The list of output command arguments
97bdd1243dSDimitry Andric   void addOtherOptions(const llvm::opt::ArgList &Args,
98fe6060f1SDimitry Andric                        llvm::opt::ArgStringList &CmdArgs) const;
99e8d8bef9SDimitry Andric 
100480093f4SDimitry Andric public:
101480093f4SDimitry Andric   Flang(const ToolChain &TC);
102480093f4SDimitry Andric   ~Flang() override;
103480093f4SDimitry Andric 
104480093f4SDimitry Andric   bool hasGoodDiagnostics() const override { return true; }
105480093f4SDimitry Andric   bool hasIntegratedAssembler() const override { return true; }
106480093f4SDimitry Andric   bool hasIntegratedCPP() const override { return true; }
107480093f4SDimitry Andric   bool canEmitIR() const override { return true; }
108480093f4SDimitry Andric 
109480093f4SDimitry Andric   void ConstructJob(Compilation &C, const JobAction &JA,
110480093f4SDimitry Andric                     const InputInfo &Output, const InputInfoList &Inputs,
111480093f4SDimitry Andric                     const llvm::opt::ArgList &TCArgs,
112480093f4SDimitry Andric                     const char *LinkingOutput) const override;
113480093f4SDimitry Andric };
114480093f4SDimitry Andric 
115480093f4SDimitry Andric } // end namespace tools
116480093f4SDimitry Andric 
117480093f4SDimitry Andric } // end namespace driver
118480093f4SDimitry Andric } // end namespace clang
119480093f4SDimitry Andric 
120480093f4SDimitry Andric #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_FLANG_H
121