1 //===--- Flang.h - Flang Tool and ToolChain Implementations ====-*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_FLANG_H
10 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_FLANG_H
12 #include "clang/Driver/Tool.h"
13 #include "clang/Driver/Action.h"
14 #include "clang/Driver/Compilation.h"
15 #include "clang/Driver/ToolChain.h"
16 #include "llvm/Option/ArgList.h"
17 #include "llvm/Support/Compiler.h"
24 /// Flang compiler tool.
25 class LLVM_LIBRARY_VISIBILITY Flang
: public Tool
{
27 /// Extract fortran dialect options from the driver arguments and add them to
28 /// the list of arguments for the generated command/job.
30 /// \param [in] Args The list of input driver arguments
31 /// \param [out] CmdArgs The list of output command arguments
32 void addFortranDialectOptions(const llvm::opt::ArgList
&Args
,
33 llvm::opt::ArgStringList
&CmdArgs
) const;
35 /// Extract preprocessing options from the driver arguments and add them to
36 /// the preprocessor command arguments.
38 /// \param [in] Args The list of input driver arguments
39 /// \param [out] CmdArgs The list of output command arguments
40 void addPreprocessingOptions(const llvm::opt::ArgList
&Args
,
41 llvm::opt::ArgStringList
&CmdArgs
) const;
43 /// Extract PIC options from the driver arguments and add them to
44 /// the command arguments.
46 /// \param [in] Args The list of input driver arguments
47 /// \param [out] CmdArgs The list of output command arguments
48 void addPicOptions(const llvm::opt::ArgList
&Args
,
49 llvm::opt::ArgStringList
&CmdArgs
) const;
51 /// Extract target options from the driver arguments and add them to
52 /// the command arguments.
54 /// \param [in] Args The list of input driver arguments
55 /// \param [out] CmdArgs The list of output command arguments
56 void addTargetOptions(const llvm::opt::ArgList
&Args
,
57 llvm::opt::ArgStringList
&CmdArgs
) const;
59 /// Add specific options for AArch64 target.
61 /// \param [in] Args The list of input driver arguments
62 /// \param [out] CmdArgs The list of output command arguments
63 void AddAArch64TargetArgs(const llvm::opt::ArgList
&Args
,
64 llvm::opt::ArgStringList
&CmdArgs
) const;
66 /// Add specific options for AMDGPU target.
68 /// \param [in] Args The list of input driver arguments
69 /// \param [out] CmdArgs The list of output command arguments
70 void AddAMDGPUTargetArgs(const llvm::opt::ArgList
&Args
,
71 llvm::opt::ArgStringList
&CmdArgs
) const;
73 /// Extract offload options from the driver arguments and add them to
74 /// the command arguments.
75 /// \param [in] C The current compilation for the driver invocation
76 /// \param [in] Inputs The input infomration on the current file inputs
77 /// \param [in] JA The job action
78 /// \param [in] Args The list of input driver arguments
79 /// \param [out] CmdArgs The list of output command arguments
80 void addOffloadOptions(Compilation
&C
, const InputInfoList
&Inputs
,
81 const JobAction
&JA
, const llvm::opt::ArgList
&Args
,
82 llvm::opt::ArgStringList
&CmdArgs
) const;
84 /// Extract options for code generation from the driver arguments and add them
85 /// to the command arguments.
87 /// \param [in] Args The list of input driver arguments
88 /// \param [out] CmdArgs The list of output command arguments
89 void addCodegenOptions(const llvm::opt::ArgList
&Args
,
90 llvm::opt::ArgStringList
&CmdArgs
) const;
92 /// Extract other compilation options from the driver arguments and add them
93 /// to the command arguments.
95 /// \param [in] Args The list of input driver arguments
96 /// \param [out] CmdArgs The list of output command arguments
97 void addOtherOptions(const llvm::opt::ArgList
&Args
,
98 llvm::opt::ArgStringList
&CmdArgs
) const;
101 Flang(const ToolChain
&TC
);
104 bool hasGoodDiagnostics() const override
{ return true; }
105 bool hasIntegratedAssembler() const override
{ return true; }
106 bool hasIntegratedCPP() const override
{ return true; }
107 bool canEmitIR() const override
{ return true; }
109 void ConstructJob(Compilation
&C
, const JobAction
&JA
,
110 const InputInfo
&Output
, const InputInfoList
&Inputs
,
111 const llvm::opt::ArgList
&TCArgs
,
112 const char *LinkingOutput
) const override
;
115 } // end namespace tools
117 } // end namespace driver
118 } // end namespace clang
120 #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_FLANG_H