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, BoundArch BA,
68 Action::OffloadKind DeviceOffloadKind) const;
69
70 /// Add specific options for AArch64 target.
71 ///
72 /// \param [in] Args The list of input driver arguments
73 /// \param [out] CmdArgs The list of output command arguments
74 void AddAArch64TargetArgs(const llvm::opt::ArgList &Args,
75 llvm::opt::ArgStringList &CmdArgs) const;
76
77 /// Add specific options for AMDGPU target.
78 ///
79 /// \param [in] Args The list of input driver arguments
80 /// \param [out] CmdArgs The list of output command arguments
81 /// \param [in] BoundArch The bound architecture for offload compilation
82 /// \param [in] DeviceOffloadKind The offload kind
83 void AddAMDGPUTargetArgs(const llvm::opt::ArgList &Args,
84 llvm::opt::ArgStringList &CmdArgs, BoundArch BA,
85 Action::OffloadKind DeviceOffloadKind) const;
86
87 void AddNVPTXTargetArgs(const llvm::opt::ArgList &Args,
88 llvm::opt::ArgStringList &CmdArgs, BoundArch BA,
89 Action::OffloadKind DeviceOffloadKind) const;
90
91 /// Add specific options for LoongArch64 target.
92 ///
93 /// \param [in] Args The list of input driver arguments
94 /// \param [out] CmdArgs The list of output command arguments
95 void AddLoongArch64TargetArgs(const llvm::opt::ArgList &Args,
96 llvm::opt::ArgStringList &CmdArgs) const;
97
98 /// Add specific options for RISC-V target.
99 ///
100 /// \param [in] Args The list of input driver arguments
101 /// \param [out] CmdArgs The list of output command arguments
102 void AddRISCVTargetArgs(const llvm::opt::ArgList &Args,
103 llvm::opt::ArgStringList &CmdArgs) const;
104
105 /// Add specific options for X86_64 target.
106 ///
107 /// \param [in] Args The list of input driver arguments
108 /// \param [out] CmdArgs The list of output command arguments
109 void AddX86_64TargetArgs(const llvm::opt::ArgList &Args,
110 llvm::opt::ArgStringList &CmdArgs) const;
111
112 /// Add specific options for PPC target.
113 ///
114 /// \param [in] Args The list of input driver arguments
115 /// \param [out] CmdArgs The list of output command arguments
116 void AddPPCTargetArgs(const llvm::opt::ArgList &Args,
117 llvm::opt::ArgStringList &CmdArgs) const;
118
119 /// Extract offload options from the driver arguments and add them to
120 /// the command arguments.
121 /// \param [in] C The current compilation for the driver invocation
122 /// \param [in] Inputs The input infomration on the current file inputs
123 /// \param [in] JA The job action
124 /// \param [in] Args The list of input driver arguments
125 /// \param [out] CmdArgs The list of output command arguments
126 void addOffloadOptions(Compilation &C, const InputInfoList &Inputs,
127 const JobAction &JA, const llvm::opt::ArgList &Args,
128 llvm::opt::ArgStringList &CmdArgs) const;
129
130 /// Extract options for code generation from the driver arguments and add them
131 /// to the command arguments.
132 ///
133 /// \param [in] Args The list of input driver arguments
134 /// \param [out] CmdArgs The list of output command arguments
135 void addCodegenOptions(const llvm::opt::ArgList &Args,
136 llvm::opt::ArgStringList &CmdArgs) const;
137
138 /// Extract debug compilation options from the driver arguments and add them
139 /// to the command arguments.
140 ///
141 /// \param [in] Args The list of input driver arguments
142 /// \param [in] JA The job action
143 /// \param [in] Output The output information on the current file output
144 /// \param [in] Input The input information on the current file input
145 /// \param [out] CmdArgs The list of output command arguments
146 void addDebugOptions(const llvm::opt::ArgList &Args, const JobAction &JA,
147 const InputInfo &Output, const InputInfo &Input,
148 llvm::opt::ArgStringList &CmdArgs) const;
149
150public:
151 Flang(const ToolChain &TC);
152 ~Flang() override;
153
154 bool hasGoodDiagnostics() const override { return true; }
155 bool hasIntegratedAssembler() const override { return true; }
156 bool hasIntegratedCPP() const override { return true; }
157 bool canEmitIR() const override { return true; }
158
159 void ConstructJob(Compilation &C, const JobAction &JA,
160 const InputInfo &Output, const InputInfoList &Inputs,
161 const llvm::opt::ArgList &TCArgs,
162 const char *LinkingOutput) const override;
163};
164
165} // end namespace tools
166
167} // end namespace driver
168} // end namespace clang
169
170#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_FLANG_H
Compilation - A set of tasks to perform for a single driver invocation.
Definition Compilation.h:46
InputInfo - Wrapper for information about an input source.
Definition InputInfo.h:22
ToolChain - Access to tools for a single platform.
Definition ToolChain.h:96
Tool(const char *Name, const char *ShortName, const ToolChain &TC)
Definition Tool.cpp:14
bool canEmitIR() const override
Definition Flang.h:157
bool hasGoodDiagnostics() const override
Does this tool have "good" standardized diagnostics, or should the driver add an additional "command ...
Definition Flang.h:154
Flang(const ToolChain &TC)
Definition Flang.cpp:1350
bool hasIntegratedAssembler() const override
Definition Flang.h:155
bool hasIntegratedCPP() const override
Definition Flang.h:156
SmallVector< InputInfo, 4 > InputInfoList
Definition Driver.h:51
The JSON file list parser is used to communicate input to InstallAPI.
Represents a bound architecture for offload / multiple architecture compilation.