1 //===--- Tools.h - Tool Implementations -------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef CLANG_LIB_DRIVER_TOOLS_H_
11 #define CLANG_LIB_DRIVER_TOOLS_H_
13 #include "clang/Driver/Tool.h"
14 #include "clang/Driver/Types.h"
15 #include "clang/Driver/Util.h"
17 #include "llvm/Support/Compiler.h"
23 namespace toolchains {
29 /// \brief Clang compiler tool.
30 class LLVM_LIBRARY_VISIBILITY Clang : public Tool {
31 void AddPreprocessingOptions(const Driver &D,
33 ArgStringList &CmdArgs,
34 const InputInfo &Output,
35 const InputInfoList &Inputs) const;
37 void AddARMTargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const;
38 void AddMIPSTargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const;
39 void AddX86TargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const;
42 Clang(const ToolChain &TC) : Tool("clang", "clang frontend", TC) {}
44 virtual bool hasGoodDiagnostics() const { return true; }
45 virtual bool hasIntegratedAssembler() const { return true; }
46 virtual bool hasIntegratedCPP() const { return true; }
48 virtual void ConstructJob(Compilation &C, const JobAction &JA,
49 const InputInfo &Output,
50 const InputInfoList &Inputs,
51 const ArgList &TCArgs,
52 const char *LinkingOutput) const;
55 /// \brief Clang integrated assembler tool.
56 class LLVM_LIBRARY_VISIBILITY ClangAs : public Tool {
58 ClangAs(const ToolChain &TC) : Tool("clang::as",
59 "clang integrated assembler", TC) {}
61 virtual bool hasGoodDiagnostics() const { return true; }
62 virtual bool hasIntegratedAssembler() const { return false; }
63 virtual bool hasIntegratedCPP() const { return false; }
65 virtual void ConstructJob(Compilation &C, const JobAction &JA,
66 const InputInfo &Output,
67 const InputInfoList &Inputs,
68 const ArgList &TCArgs,
69 const char *LinkingOutput) const;
72 /// gcc - Generic GCC tool implementations.
74 class LLVM_LIBRARY_VISIBILITY Common : public Tool {
76 Common(const char *Name, const char *ShortName,
77 const ToolChain &TC) : Tool(Name, ShortName, TC) {}
79 virtual void ConstructJob(Compilation &C, const JobAction &JA,
80 const InputInfo &Output,
81 const InputInfoList &Inputs,
82 const ArgList &TCArgs,
83 const char *LinkingOutput) const;
85 /// RenderExtraToolArgs - Render any arguments necessary to force
86 /// the particular tool mode.
87 virtual void RenderExtraToolArgs(const JobAction &JA,
88 ArgStringList &CmdArgs) const = 0;
92 class LLVM_LIBRARY_VISIBILITY Preprocess : public Common {
94 Preprocess(const ToolChain &TC) : Common("gcc::Preprocess",
95 "gcc preprocessor", TC) {}
97 virtual bool hasGoodDiagnostics() const { return true; }
98 virtual bool hasIntegratedCPP() const { return false; }
100 virtual void RenderExtraToolArgs(const JobAction &JA,
101 ArgStringList &CmdArgs) const;
104 class LLVM_LIBRARY_VISIBILITY Precompile : public Common {
106 Precompile(const ToolChain &TC) : Common("gcc::Precompile",
107 "gcc precompile", TC) {}
109 virtual bool hasGoodDiagnostics() const { return true; }
110 virtual bool hasIntegratedCPP() const { return true; }
112 virtual void RenderExtraToolArgs(const JobAction &JA,
113 ArgStringList &CmdArgs) const;
116 class LLVM_LIBRARY_VISIBILITY Compile : public Common {
118 Compile(const ToolChain &TC) : Common("gcc::Compile",
119 "gcc frontend", TC) {}
121 virtual bool hasGoodDiagnostics() const { return true; }
122 virtual bool hasIntegratedCPP() const { return true; }
124 virtual void RenderExtraToolArgs(const JobAction &JA,
125 ArgStringList &CmdArgs) const;
128 class LLVM_LIBRARY_VISIBILITY Assemble : public Common {
130 Assemble(const ToolChain &TC) : Common("gcc::Assemble",
131 "assembler (via gcc)", TC) {}
133 virtual bool hasIntegratedCPP() const { return false; }
135 virtual void RenderExtraToolArgs(const JobAction &JA,
136 ArgStringList &CmdArgs) const;
139 class LLVM_LIBRARY_VISIBILITY Link : public Common {
141 Link(const ToolChain &TC) : Common("gcc::Link",
142 "linker (via gcc)", TC) {}
144 virtual bool hasIntegratedCPP() const { return false; }
146 virtual void RenderExtraToolArgs(const JobAction &JA,
147 ArgStringList &CmdArgs) const;
149 } // end namespace gcc
152 class LLVM_LIBRARY_VISIBILITY DarwinTool : public Tool {
154 void AddDarwinArch(const ArgList &Args, ArgStringList &CmdArgs) const;
156 const toolchains::Darwin &getDarwinToolChain() const {
157 return reinterpret_cast<const toolchains::Darwin&>(getToolChain());
161 DarwinTool(const char *Name, const char *ShortName,
162 const ToolChain &TC) : Tool(Name, ShortName, TC) {}
165 class LLVM_LIBRARY_VISIBILITY CC1 : public DarwinTool {
167 static const char *getBaseInputName(const ArgList &Args,
168 const InputInfoList &Input);
169 static const char *getBaseInputStem(const ArgList &Args,
170 const InputInfoList &Input);
171 static const char *getDependencyFileName(const ArgList &Args,
172 const InputInfoList &Inputs);
175 const char *getCC1Name(types::ID Type) const;
177 void AddCC1Args(const ArgList &Args, ArgStringList &CmdArgs) const;
178 void AddCC1OptionsArgs(const ArgList &Args, ArgStringList &CmdArgs,
179 const InputInfoList &Inputs,
180 const ArgStringList &OutputArgs) const;
181 void AddCPPOptionsArgs(const ArgList &Args, ArgStringList &CmdArgs,
182 const InputInfoList &Inputs,
183 const ArgStringList &OutputArgs) const;
184 void AddCPPUniqueOptionsArgs(const ArgList &Args,
185 ArgStringList &CmdArgs,
186 const InputInfoList &Inputs) const;
187 void AddCPPArgs(const ArgList &Args, ArgStringList &CmdArgs) const;
190 CC1(const char *Name, const char *ShortName,
191 const ToolChain &TC) : DarwinTool(Name, ShortName, TC) {}
193 virtual bool hasGoodDiagnostics() const { return true; }
194 virtual bool hasIntegratedCPP() const { return true; }
197 class LLVM_LIBRARY_VISIBILITY Preprocess : public CC1 {
199 Preprocess(const ToolChain &TC) : CC1("darwin::Preprocess",
200 "gcc preprocessor", TC) {}
202 virtual void ConstructJob(Compilation &C, const JobAction &JA,
203 const InputInfo &Output,
204 const InputInfoList &Inputs,
205 const ArgList &TCArgs,
206 const char *LinkingOutput) const;
209 class LLVM_LIBRARY_VISIBILITY Compile : public CC1 {
211 Compile(const ToolChain &TC) : CC1("darwin::Compile", "gcc frontend", TC) {}
213 virtual void ConstructJob(Compilation &C, const JobAction &JA,
214 const InputInfo &Output,
215 const InputInfoList &Inputs,
216 const ArgList &TCArgs,
217 const char *LinkingOutput) const;
220 class LLVM_LIBRARY_VISIBILITY Assemble : public DarwinTool {
222 Assemble(const ToolChain &TC) : DarwinTool("darwin::Assemble",
225 virtual bool hasIntegratedCPP() const { return false; }
227 virtual void ConstructJob(Compilation &C, const JobAction &JA,
228 const InputInfo &Output,
229 const InputInfoList &Inputs,
230 const ArgList &TCArgs,
231 const char *LinkingOutput) const;
234 class LLVM_LIBRARY_VISIBILITY Link : public DarwinTool {
235 void AddLinkArgs(const ArgList &Args, ArgStringList &CmdArgs) const;
238 Link(const ToolChain &TC) : DarwinTool("darwin::Link", "linker", TC) {}
240 virtual bool hasIntegratedCPP() const { return false; }
242 virtual void ConstructJob(Compilation &C, const JobAction &JA,
243 const InputInfo &Output,
244 const InputInfoList &Inputs,
245 const ArgList &TCArgs,
246 const char *LinkingOutput) const;
249 class LLVM_LIBRARY_VISIBILITY Lipo : public DarwinTool {
251 Lipo(const ToolChain &TC) : DarwinTool("darwin::Lipo", "lipo", TC) {}
253 virtual bool hasIntegratedCPP() const { return false; }
255 virtual void ConstructJob(Compilation &C, const JobAction &JA,
256 const InputInfo &Output,
257 const InputInfoList &Inputs,
258 const ArgList &TCArgs,
259 const char *LinkingOutput) const;
262 class LLVM_LIBRARY_VISIBILITY Dsymutil : public DarwinTool {
264 Dsymutil(const ToolChain &TC) : DarwinTool("darwin::Dsymutil",
267 virtual bool hasIntegratedCPP() const { return false; }
269 virtual void ConstructJob(Compilation &C, const JobAction &JA,
270 const InputInfo &Output,
271 const InputInfoList &Inputs,
272 const ArgList &TCArgs,
273 const char *LinkingOutput) const;
277 /// openbsd -- Directly call GNU Binutils assembler and linker
279 class LLVM_LIBRARY_VISIBILITY Assemble : public Tool {
281 Assemble(const ToolChain &TC) : Tool("openbsd::Assemble", "assembler",
284 virtual bool hasIntegratedCPP() const { return false; }
286 virtual void ConstructJob(Compilation &C, const JobAction &JA,
287 const InputInfo &Output,
288 const InputInfoList &Inputs,
289 const ArgList &TCArgs,
290 const char *LinkingOutput) const;
292 class LLVM_LIBRARY_VISIBILITY Link : public Tool {
294 Link(const ToolChain &TC) : Tool("openbsd::Link", "linker", TC) {}
296 virtual bool hasIntegratedCPP() const { return false; }
298 virtual void ConstructJob(Compilation &C, const JobAction &JA,
299 const InputInfo &Output,
300 const InputInfoList &Inputs,
301 const ArgList &TCArgs,
302 const char *LinkingOutput) const;
304 } // end namespace openbsd
306 /// freebsd -- Directly call GNU Binutils assembler and linker
308 class LLVM_LIBRARY_VISIBILITY Assemble : public Tool {
310 Assemble(const ToolChain &TC) : Tool("freebsd::Assemble", "assembler",
313 virtual bool hasIntegratedCPP() const { return false; }
315 virtual void ConstructJob(Compilation &C, const JobAction &JA,
316 const InputInfo &Output,
317 const InputInfoList &Inputs,
318 const ArgList &TCArgs,
319 const char *LinkingOutput) const;
321 class LLVM_LIBRARY_VISIBILITY Link : public Tool {
323 Link(const ToolChain &TC) : Tool("freebsd::Link", "linker", TC) {}
325 virtual bool hasIntegratedCPP() const { return false; }
327 virtual void ConstructJob(Compilation &C, const JobAction &JA,
328 const InputInfo &Output,
329 const InputInfoList &Inputs,
330 const ArgList &TCArgs,
331 const char *LinkingOutput) const;
333 } // end namespace freebsd
335 /// minix -- Directly call GNU Binutils assembler and linker
337 class LLVM_LIBRARY_VISIBILITY Assemble : public Tool {
339 Assemble(const ToolChain &TC) : Tool("minix::Assemble", "assembler",
342 virtual bool hasIntegratedCPP() const { return false; }
344 virtual void ConstructJob(Compilation &C, const JobAction &JA,
345 const InputInfo &Output,
346 const InputInfoList &Inputs,
347 const ArgList &TCArgs,
348 const char *LinkingOutput) const;
350 class LLVM_LIBRARY_VISIBILITY Link : public Tool {
352 Link(const ToolChain &TC) : Tool("minix::Link", "linker", TC) {}
354 virtual bool hasIntegratedCPP() const { return false; }
356 virtual void ConstructJob(Compilation &C, const JobAction &JA,
357 const InputInfo &Output,
358 const InputInfoList &Inputs,
359 const ArgList &TCArgs,
360 const char *LinkingOutput) const;
362 } // end namespace minix
364 /// auroraux -- Directly call GNU Binutils assembler and linker
366 class LLVM_LIBRARY_VISIBILITY Assemble : public Tool {
368 Assemble(const ToolChain &TC) : Tool("auroraux::Assemble", "assembler",
371 virtual bool hasIntegratedCPP() const { return false; }
373 virtual void ConstructJob(Compilation &C, const JobAction &JA,
374 const InputInfo &Output,
375 const InputInfoList &Inputs,
376 const ArgList &TCArgs,
377 const char *LinkingOutput) const;
379 class LLVM_LIBRARY_VISIBILITY Link : public Tool {
381 Link(const ToolChain &TC) : Tool("auroraux::Link", "linker", TC) {}
383 virtual bool hasIntegratedCPP() const { return false; }
385 virtual void ConstructJob(Compilation &C, const JobAction &JA,
386 const InputInfo &Output,
387 const InputInfoList &Inputs,
388 const ArgList &TCArgs,
389 const char *LinkingOutput) const;
391 } // end namespace auroraux
393 /// dragonfly -- Directly call GNU Binutils assembler and linker
394 namespace dragonfly {
395 class LLVM_LIBRARY_VISIBILITY Assemble : public Tool {
397 Assemble(const ToolChain &TC) : Tool("dragonfly::Assemble", "assembler",
400 virtual bool hasIntegratedCPP() const { return false; }
402 virtual void ConstructJob(Compilation &C, const JobAction &JA,
403 const InputInfo &Output,
404 const InputInfoList &Inputs,
405 const ArgList &TCArgs,
406 const char *LinkingOutput) const;
408 class LLVM_LIBRARY_VISIBILITY Link : public Tool {
410 Link(const ToolChain &TC) : Tool("dragonfly::Link", "linker", TC) {}
412 virtual bool hasIntegratedCPP() const { return false; }
414 virtual void ConstructJob(Compilation &C, const JobAction &JA,
415 const InputInfo &Output,
416 const InputInfoList &Inputs,
417 const ArgList &TCArgs,
418 const char *LinkingOutput) const;
420 } // end namespace dragonfly
422 } // end namespace toolchains
423 } // end namespace driver
424 } // end namespace clang
426 #endif // CLANG_LIB_DRIVER_TOOLS_H_