clang 23.0.0git
Flang.h
Go to the documentation of this file.
1//===--- Flang.h - Flang Tool and ToolChain Implementations ====-*- C++ -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_FLANG_H
10#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_FLANG_H
11
12#include "clang/Driver/Tool.h"
13#include "clang/Driver/Action.h"
16#include "llvm/Option/ArgList.h"
17#include "llvm/Support/Compiler.h"
18
19namespace clang {
20namespace driver {
21
22namespace tools {
23
24/// Flang compiler tool.
25class LLVM_LIBRARY_VISIBILITY Flang : public Tool {
26private:
27 /// Extract fortran dialect options from the driver arguments and add them to
28 /// the list of arguments for the generated command/job.
29 ///
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;
34
35 /// Extract preprocessing options from the driver arguments and add them to
36 /// the preprocessor command arguments.
37 ///
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;
42
43 /// Extract LTO options from the driver arguments and add them to
44 /// the command arguments.
45 ///
46 /// \param [in] Args The list of input driver arguments
47 /// \param [out] CmdArgs The list of output command arguments
48 void addLTOOptions(const llvm::opt::ArgList &Args,
49 llvm::opt::ArgStringList &CmdArgs) const;
50
51 /// Extract PIC options from the driver arguments and add them to
52 /// the command arguments.
53 ///
54 /// \param [in] Args The list of input driver arguments
55 /// \param [out] CmdArgs The list of output command arguments
56 void addPicOptions(const llvm::opt::ArgList &Args,
57 llvm::opt::ArgStringList &CmdArgs) const;
58
59 /// Extract target options from the driver arguments and add them to
60 /// the command arguments.
61 ///
62 /// \param [in] Args The list of input driver arguments
63 /// \param [out] CmdArgs The list of output command arguments
64 /// \param [in] BoundArch The bound architecture for offload compilation
65 /// \param [in] DeviceOffloadKind The offload kind
66 void addTargetOptions(const llvm::opt::ArgList &Args,
67 llvm::opt::ArgStringList &CmdArgs,
68 llvm::StringRef BoundArch,
69 Action::OffloadKind DeviceOffloadKind) const;
70
71 /// Add specific options for AArch64 target.
72 ///
73 /// \param [in] Args The list of input driver arguments
74 /// \param [out] CmdArgs The list of output command arguments
75 void AddAArch64TargetArgs(const llvm::opt::ArgList &Args,
76 llvm::opt::ArgStringList &CmdArgs) const;
77
78 /// Add specific options for AMDGPU target.
79 ///
80 /// \param [in] Args The list of input driver arguments
81 /// \param [out] CmdArgs The list of output command arguments
82 /// \param [in] BoundArch The bound architecture for offload compilation
83 /// \param [in] DeviceOffloadKind The offload kind
84 void AddAMDGPUTargetArgs(const llvm::opt::ArgList &Args,
85 llvm::opt::ArgStringList &CmdArgs,
86 llvm::StringRef BoundArch,
87 Action::OffloadKind DeviceOffloadKind) const;
88
89 void AddNVPTXTargetArgs(const llvm::opt::ArgList &Args,
90 llvm::opt::ArgStringList &CmdArgs,
91 llvm::StringRef BoundArch,
92 Action::OffloadKind DeviceOffloadKind) const;
93
94 /// Add specific options for LoongArch64 target.
95 ///
96 /// \param [in] Args The list of input driver arguments
97 /// \param [out] CmdArgs The list of output command arguments
98 void AddLoongArch64TargetArgs(const llvm::opt::ArgList &Args,
99 llvm::opt::ArgStringList &CmdArgs) const;
100
101 /// Add specific options for RISC-V target.
102 ///
103 /// \param [in] Args The list of input driver arguments
104 /// \param [out] CmdArgs The list of output command arguments
105 void AddRISCVTargetArgs(const llvm::opt::ArgList &Args,
106 llvm::opt::ArgStringList &CmdArgs) const;
107
108 /// Add specific options for X86_64 target.
109 ///
110 /// \param [in] Args The list of input driver arguments
111 /// \param [out] CmdArgs The list of output command arguments
112 void AddX86_64TargetArgs(const llvm::opt::ArgList &Args,
113 llvm::opt::ArgStringList &CmdArgs) const;
114
115 /// Add specific options for PPC target.
116 ///
117 /// \param [in] Args The list of input driver arguments
118 /// \param [out] CmdArgs The list of output command arguments
119 void AddPPCTargetArgs(const llvm::opt::ArgList &Args,
120 llvm::opt::ArgStringList &CmdArgs) const;
121
122 /// Extract offload options from the driver arguments and add them to
123 /// the command arguments.
124 /// \param [in] C The current compilation for the driver invocation
125 /// \param [in] Inputs The input infomration on the current file inputs
126 /// \param [in] JA The job action
127 /// \param [in] Args The list of input driver arguments
128 /// \param [out] CmdArgs The list of output command arguments
129 void addOffloadOptions(Compilation &C, const InputInfoList &Inputs,
130 const JobAction &JA, const llvm::opt::ArgList &Args,
131 llvm::opt::ArgStringList &CmdArgs) const;
132
133 /// Extract options for code generation from the driver arguments and add them
134 /// to the command arguments.
135 ///
136 /// \param [in] Args The list of input driver arguments
137 /// \param [out] CmdArgs The list of output command arguments
138 void addCodegenOptions(const llvm::opt::ArgList &Args,
139 llvm::opt::ArgStringList &CmdArgs) const;
140
141 /// Extract debug compilation options from the driver arguments and add them
142 /// to the command arguments.
143 ///
144 /// \param [in] Args The list of input driver arguments
145 /// \param [in] JA The job action
146 /// \param [in] Output The output information on the current file output
147 /// \param [in] Input The input information on the current file input
148 /// \param [out] CmdArgs The list of output command arguments
149 void addDebugOptions(const llvm::opt::ArgList &Args, const JobAction &JA,
150 const InputInfo &Output, const InputInfo &Input,
151 llvm::opt::ArgStringList &CmdArgs) const;
152
153public:
154 Flang(const ToolChain &TC);
155 ~Flang() override;
156
157 bool hasGoodDiagnostics() const override { return true; }
158 bool hasIntegratedAssembler() const override { return true; }
159 bool hasIntegratedCPP() const override { return true; }
160 bool canEmitIR() const override { return true; }
161
162 void ConstructJob(Compilation &C, const JobAction &JA,
163 const InputInfo &Output, const InputInfoList &Inputs,
164 const llvm::opt::ArgList &TCArgs,
165 const char *LinkingOutput) const override;
166};
167
168} // end namespace tools
169
170} // end namespace driver
171} // end namespace clang
172
173#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_FLANG_H
Compilation - A set of tasks to perform for a single driver invocation.
Definition Compilation.h:45
InputInfo - Wrapper for information about an input source.
Definition InputInfo.h:22
ToolChain - Access to tools for a single platform.
Definition ToolChain.h:95
Tool(const char *Name, const char *ShortName, const ToolChain &TC)
Definition Tool.cpp:14
bool canEmitIR() const override
Definition Flang.h:160
bool hasGoodDiagnostics() const override
Does this tool have "good" standardized diagnostics, or should the driver add an additional "command ...
Definition Flang.h:157
Flang(const ToolChain &TC)
Definition Flang.cpp:1350
bool hasIntegratedAssembler() const override
Definition Flang.h:158
bool hasIntegratedCPP() const override
Definition Flang.h:159
SmallVector< InputInfo, 4 > InputInfoList
Definition Driver.h:50
The JSON file list parser is used to communicate input to InstallAPI.