xref: /freebsd/contrib/llvm-project/clang/lib/Driver/ToolChains/Flang.h (revision 297eecfb02bb25902531dbb5c3b9a88caf8adf29)
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 
595f757f3fSDimitry Andric   /// Add specific options for AArch64 target.
605f757f3fSDimitry Andric   ///
615f757f3fSDimitry Andric   /// \param [in] Args The list of input driver arguments
625f757f3fSDimitry Andric   /// \param [out] CmdArgs The list of output command arguments
635f757f3fSDimitry Andric   void AddAArch64TargetArgs(const llvm::opt::ArgList &Args,
645f757f3fSDimitry Andric                             llvm::opt::ArgStringList &CmdArgs) const;
655f757f3fSDimitry Andric 
665f757f3fSDimitry Andric   /// Add specific options for AMDGPU target.
675f757f3fSDimitry Andric   ///
685f757f3fSDimitry Andric   /// \param [in] Args The list of input driver arguments
695f757f3fSDimitry Andric   /// \param [out] CmdArgs The list of output command arguments
705f757f3fSDimitry Andric   void AddAMDGPUTargetArgs(const llvm::opt::ArgList &Args,
715f757f3fSDimitry Andric                            llvm::opt::ArgStringList &CmdArgs) const;
725f757f3fSDimitry Andric 
73*297eecfbSDimitry Andric   /// Add specific options for RISC-V target.
74*297eecfbSDimitry Andric   ///
75*297eecfbSDimitry Andric   /// \param [in] Args The list of input driver arguments
76*297eecfbSDimitry Andric   /// \param [out] CmdArgs The list of output command arguments
77*297eecfbSDimitry Andric   void AddRISCVTargetArgs(const llvm::opt::ArgList &Args,
78*297eecfbSDimitry Andric                           llvm::opt::ArgStringList &CmdArgs) const;
79*297eecfbSDimitry Andric 
8006c3fb27SDimitry Andric   /// Extract offload options from the driver arguments and add them to
8106c3fb27SDimitry Andric   /// the command arguments.
8206c3fb27SDimitry Andric   /// \param [in] C The current compilation for the driver invocation
8306c3fb27SDimitry Andric   /// \param [in] Inputs The input infomration on the current file inputs
8406c3fb27SDimitry Andric   /// \param [in] JA The job action
8506c3fb27SDimitry Andric   /// \param [in] Args The list of input driver arguments
8606c3fb27SDimitry Andric   /// \param [out] CmdArgs The list of output command arguments
8706c3fb27SDimitry Andric   void addOffloadOptions(Compilation &C, const InputInfoList &Inputs,
8806c3fb27SDimitry Andric                          const JobAction &JA, const llvm::opt::ArgList &Args,
8906c3fb27SDimitry Andric                          llvm::opt::ArgStringList &CmdArgs) const;
9006c3fb27SDimitry Andric 
9106c3fb27SDimitry Andric   /// Extract options for code generation from the driver arguments and add them
9206c3fb27SDimitry Andric   /// to the command arguments.
9306c3fb27SDimitry Andric   ///
9406c3fb27SDimitry Andric   /// \param [in] Args The list of input driver arguments
9506c3fb27SDimitry Andric   /// \param [out] CmdArgs The list of output command arguments
9606c3fb27SDimitry Andric   void addCodegenOptions(const llvm::opt::ArgList &Args,
9706c3fb27SDimitry Andric                          llvm::opt::ArgStringList &CmdArgs) const;
9806c3fb27SDimitry Andric 
99fe6060f1SDimitry Andric   /// Extract other compilation options from the driver arguments and add them
100fe6060f1SDimitry Andric   /// to the command arguments.
101fe6060f1SDimitry Andric   ///
102fe6060f1SDimitry Andric   /// \param [in] Args The list of input driver arguments
103fe6060f1SDimitry Andric   /// \param [out] CmdArgs The list of output command arguments
104bdd1243dSDimitry Andric   void addOtherOptions(const llvm::opt::ArgList &Args,
105fe6060f1SDimitry Andric                        llvm::opt::ArgStringList &CmdArgs) const;
106e8d8bef9SDimitry Andric 
107480093f4SDimitry Andric public:
108480093f4SDimitry Andric   Flang(const ToolChain &TC);
109480093f4SDimitry Andric   ~Flang() override;
110480093f4SDimitry Andric 
111480093f4SDimitry Andric   bool hasGoodDiagnostics() const override { return true; }
112480093f4SDimitry Andric   bool hasIntegratedAssembler() const override { return true; }
113480093f4SDimitry Andric   bool hasIntegratedCPP() const override { return true; }
114480093f4SDimitry Andric   bool canEmitIR() const override { return true; }
115480093f4SDimitry Andric 
116480093f4SDimitry Andric   void ConstructJob(Compilation &C, const JobAction &JA,
117480093f4SDimitry Andric                     const InputInfo &Output, const InputInfoList &Inputs,
118480093f4SDimitry Andric                     const llvm::opt::ArgList &TCArgs,
119480093f4SDimitry Andric                     const char *LinkingOutput) const override;
120480093f4SDimitry Andric };
121480093f4SDimitry Andric 
122480093f4SDimitry Andric } // end namespace tools
123480093f4SDimitry Andric 
124480093f4SDimitry Andric } // end namespace driver
125480093f4SDimitry Andric } // end namespace clang
126480093f4SDimitry Andric 
127480093f4SDimitry Andric #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_FLANG_H
128