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 AddSparcTargetArgs(const ArgList
&Args
, ArgStringList
&CmdArgs
) const;
40 void AddX86TargetArgs(const ArgList
&Args
, ArgStringList
&CmdArgs
) const;
43 Clang(const ToolChain
&TC
) : Tool("clang", "clang frontend", TC
) {}
45 virtual bool hasGoodDiagnostics() const { return true; }
46 virtual bool hasIntegratedAssembler() const { return true; }
47 virtual bool hasIntegratedCPP() const { return true; }
49 virtual void ConstructJob(Compilation
&C
, const JobAction
&JA
,
50 const InputInfo
&Output
,
51 const InputInfoList
&Inputs
,
52 const ArgList
&TCArgs
,
53 const char *LinkingOutput
) const;
56 /// \brief Clang integrated assembler tool.
57 class LLVM_LIBRARY_VISIBILITY ClangAs
: public Tool
{
59 ClangAs(const ToolChain
&TC
) : Tool("clang::as",
60 "clang integrated assembler", TC
) {}
62 virtual bool hasGoodDiagnostics() const { return true; }
63 virtual bool hasIntegratedAssembler() const { return false; }
64 virtual bool hasIntegratedCPP() const { return false; }
66 virtual void ConstructJob(Compilation
&C
, const JobAction
&JA
,
67 const InputInfo
&Output
,
68 const InputInfoList
&Inputs
,
69 const ArgList
&TCArgs
,
70 const char *LinkingOutput
) const;
73 /// gcc - Generic GCC tool implementations.
75 class LLVM_LIBRARY_VISIBILITY Common
: public Tool
{
77 Common(const char *Name
, const char *ShortName
,
78 const ToolChain
&TC
) : Tool(Name
, ShortName
, TC
) {}
80 virtual void ConstructJob(Compilation
&C
, const JobAction
&JA
,
81 const InputInfo
&Output
,
82 const InputInfoList
&Inputs
,
83 const ArgList
&TCArgs
,
84 const char *LinkingOutput
) const;
86 /// RenderExtraToolArgs - Render any arguments necessary to force
87 /// the particular tool mode.
88 virtual void RenderExtraToolArgs(const JobAction
&JA
,
89 ArgStringList
&CmdArgs
) const = 0;
93 class LLVM_LIBRARY_VISIBILITY Preprocess
: public Common
{
95 Preprocess(const ToolChain
&TC
) : Common("gcc::Preprocess",
96 "gcc preprocessor", TC
) {}
98 virtual bool hasGoodDiagnostics() const { return true; }
99 virtual bool hasIntegratedCPP() const { return false; }
101 virtual void RenderExtraToolArgs(const JobAction
&JA
,
102 ArgStringList
&CmdArgs
) const;
105 class LLVM_LIBRARY_VISIBILITY Precompile
: public Common
{
107 Precompile(const ToolChain
&TC
) : Common("gcc::Precompile",
108 "gcc precompile", TC
) {}
110 virtual bool hasGoodDiagnostics() const { return true; }
111 virtual bool hasIntegratedCPP() const { return true; }
113 virtual void RenderExtraToolArgs(const JobAction
&JA
,
114 ArgStringList
&CmdArgs
) const;
117 class LLVM_LIBRARY_VISIBILITY Compile
: public Common
{
119 Compile(const ToolChain
&TC
) : Common("gcc::Compile",
120 "gcc frontend", TC
) {}
122 virtual bool hasGoodDiagnostics() const { return true; }
123 virtual bool hasIntegratedCPP() const { return true; }
125 virtual void RenderExtraToolArgs(const JobAction
&JA
,
126 ArgStringList
&CmdArgs
) const;
129 class LLVM_LIBRARY_VISIBILITY Assemble
: public Common
{
131 Assemble(const ToolChain
&TC
) : Common("gcc::Assemble",
132 "assembler (via gcc)", TC
) {}
134 virtual bool hasIntegratedCPP() const { return false; }
136 virtual void RenderExtraToolArgs(const JobAction
&JA
,
137 ArgStringList
&CmdArgs
) const;
140 class LLVM_LIBRARY_VISIBILITY Link
: public Common
{
142 Link(const ToolChain
&TC
) : Common("gcc::Link",
143 "linker (via gcc)", TC
) {}
145 virtual bool hasIntegratedCPP() const { return false; }
147 virtual void RenderExtraToolArgs(const JobAction
&JA
,
148 ArgStringList
&CmdArgs
) const;
150 } // end namespace gcc
153 class LLVM_LIBRARY_VISIBILITY DarwinTool
: public Tool
{
155 void AddDarwinArch(const ArgList
&Args
, ArgStringList
&CmdArgs
) const;
157 const toolchains::Darwin
&getDarwinToolChain() const {
158 return reinterpret_cast<const toolchains::Darwin
&>(getToolChain());
162 DarwinTool(const char *Name
, const char *ShortName
,
163 const ToolChain
&TC
) : Tool(Name
, ShortName
, TC
) {}
166 class LLVM_LIBRARY_VISIBILITY CC1
: public DarwinTool
{
168 static const char *getBaseInputName(const ArgList
&Args
,
169 const InputInfoList
&Input
);
170 static const char *getBaseInputStem(const ArgList
&Args
,
171 const InputInfoList
&Input
);
172 static const char *getDependencyFileName(const ArgList
&Args
,
173 const InputInfoList
&Inputs
);
176 const char *getCC1Name(types::ID Type
) const;
178 void AddCC1Args(const ArgList
&Args
, ArgStringList
&CmdArgs
) const;
179 void AddCC1OptionsArgs(const ArgList
&Args
, ArgStringList
&CmdArgs
,
180 const InputInfoList
&Inputs
,
181 const ArgStringList
&OutputArgs
) const;
182 void AddCPPOptionsArgs(const ArgList
&Args
, ArgStringList
&CmdArgs
,
183 const InputInfoList
&Inputs
,
184 const ArgStringList
&OutputArgs
) const;
185 void AddCPPUniqueOptionsArgs(const ArgList
&Args
,
186 ArgStringList
&CmdArgs
,
187 const InputInfoList
&Inputs
) const;
188 void AddCPPArgs(const ArgList
&Args
, ArgStringList
&CmdArgs
) const;
191 CC1(const char *Name
, const char *ShortName
,
192 const ToolChain
&TC
) : DarwinTool(Name
, ShortName
, TC
) {}
194 virtual bool hasGoodDiagnostics() const { return true; }
195 virtual bool hasIntegratedCPP() const { return true; }
198 class LLVM_LIBRARY_VISIBILITY Preprocess
: public CC1
{
200 Preprocess(const ToolChain
&TC
) : CC1("darwin::Preprocess",
201 "gcc preprocessor", TC
) {}
203 virtual void ConstructJob(Compilation
&C
, const JobAction
&JA
,
204 const InputInfo
&Output
,
205 const InputInfoList
&Inputs
,
206 const ArgList
&TCArgs
,
207 const char *LinkingOutput
) const;
210 class LLVM_LIBRARY_VISIBILITY Compile
: public CC1
{
212 Compile(const ToolChain
&TC
) : CC1("darwin::Compile", "gcc frontend", TC
) {}
214 virtual void ConstructJob(Compilation
&C
, const JobAction
&JA
,
215 const InputInfo
&Output
,
216 const InputInfoList
&Inputs
,
217 const ArgList
&TCArgs
,
218 const char *LinkingOutput
) const;
221 class LLVM_LIBRARY_VISIBILITY Assemble
: public DarwinTool
{
223 Assemble(const ToolChain
&TC
) : DarwinTool("darwin::Assemble",
226 virtual bool hasIntegratedCPP() const { return false; }
228 virtual void ConstructJob(Compilation
&C
, const JobAction
&JA
,
229 const InputInfo
&Output
,
230 const InputInfoList
&Inputs
,
231 const ArgList
&TCArgs
,
232 const char *LinkingOutput
) const;
235 class LLVM_LIBRARY_VISIBILITY Link
: public DarwinTool
{
236 void AddLinkArgs(Compilation
&C
, const ArgList
&Args
,
237 ArgStringList
&CmdArgs
) const;
240 Link(const ToolChain
&TC
) : DarwinTool("darwin::Link", "linker", TC
) {}
242 virtual bool hasIntegratedCPP() const { return false; }
244 virtual void ConstructJob(Compilation
&C
, const JobAction
&JA
,
245 const InputInfo
&Output
,
246 const InputInfoList
&Inputs
,
247 const ArgList
&TCArgs
,
248 const char *LinkingOutput
) const;
251 class LLVM_LIBRARY_VISIBILITY Lipo
: public DarwinTool
{
253 Lipo(const ToolChain
&TC
) : DarwinTool("darwin::Lipo", "lipo", TC
) {}
255 virtual bool hasIntegratedCPP() const { return false; }
257 virtual void ConstructJob(Compilation
&C
, const JobAction
&JA
,
258 const InputInfo
&Output
,
259 const InputInfoList
&Inputs
,
260 const ArgList
&TCArgs
,
261 const char *LinkingOutput
) const;
264 class LLVM_LIBRARY_VISIBILITY Dsymutil
: public DarwinTool
{
266 Dsymutil(const ToolChain
&TC
) : DarwinTool("darwin::Dsymutil",
269 virtual bool hasIntegratedCPP() const { return false; }
271 virtual void ConstructJob(Compilation
&C
, const JobAction
&JA
,
272 const InputInfo
&Output
,
273 const InputInfoList
&Inputs
,
274 const ArgList
&TCArgs
,
275 const char *LinkingOutput
) const;
279 /// openbsd -- Directly call GNU Binutils assembler and linker
281 class LLVM_LIBRARY_VISIBILITY Assemble
: public Tool
{
283 Assemble(const ToolChain
&TC
) : Tool("openbsd::Assemble", "assembler",
286 virtual bool hasIntegratedCPP() const { return false; }
288 virtual void ConstructJob(Compilation
&C
, const JobAction
&JA
,
289 const InputInfo
&Output
,
290 const InputInfoList
&Inputs
,
291 const ArgList
&TCArgs
,
292 const char *LinkingOutput
) const;
294 class LLVM_LIBRARY_VISIBILITY Link
: public Tool
{
296 Link(const ToolChain
&TC
) : Tool("openbsd::Link", "linker", TC
) {}
298 virtual bool hasIntegratedCPP() const { return false; }
300 virtual void ConstructJob(Compilation
&C
, const JobAction
&JA
,
301 const InputInfo
&Output
,
302 const InputInfoList
&Inputs
,
303 const ArgList
&TCArgs
,
304 const char *LinkingOutput
) const;
306 } // end namespace openbsd
308 /// freebsd -- Directly call GNU Binutils assembler and linker
310 class LLVM_LIBRARY_VISIBILITY Assemble
: public Tool
{
312 Assemble(const ToolChain
&TC
) : Tool("freebsd::Assemble", "assembler",
315 virtual bool hasIntegratedCPP() const { return false; }
317 virtual void ConstructJob(Compilation
&C
, const JobAction
&JA
,
318 const InputInfo
&Output
,
319 const InputInfoList
&Inputs
,
320 const ArgList
&TCArgs
,
321 const char *LinkingOutput
) const;
323 class LLVM_LIBRARY_VISIBILITY Link
: public Tool
{
325 Link(const ToolChain
&TC
) : Tool("freebsd::Link", "linker", TC
) {}
327 virtual bool hasIntegratedCPP() const { return false; }
329 virtual void ConstructJob(Compilation
&C
, const JobAction
&JA
,
330 const InputInfo
&Output
,
331 const InputInfoList
&Inputs
,
332 const ArgList
&TCArgs
,
333 const char *LinkingOutput
) const;
335 } // end namespace freebsd
337 /// linux -- Directly call GNU Binutils assembler and linker
338 namespace linuxtools
{
339 class LLVM_LIBRARY_VISIBILITY Assemble
: public Tool
{
341 Assemble(const ToolChain
&TC
) : Tool("linux::Assemble", "assembler",
344 virtual bool hasIntegratedCPP() const { return false; }
346 virtual void ConstructJob(Compilation
&C
, const JobAction
&JA
,
347 const InputInfo
&Output
,
348 const InputInfoList
&Inputs
,
349 const ArgList
&TCArgs
,
350 const char *LinkingOutput
) const;
352 class LLVM_LIBRARY_VISIBILITY Link
: public Tool
{
354 Link(const ToolChain
&TC
) : Tool("linux::Link", "linker", TC
) {}
356 virtual bool hasIntegratedCPP() const { return false; }
358 virtual void ConstructJob(Compilation
&C
, const JobAction
&JA
,
359 const InputInfo
&Output
,
360 const InputInfoList
&Inputs
,
361 const ArgList
&TCArgs
,
362 const char *LinkingOutput
) const;
365 /// minix -- Directly call GNU Binutils assembler and linker
367 class LLVM_LIBRARY_VISIBILITY Assemble
: public Tool
{
369 Assemble(const ToolChain
&TC
) : Tool("minix::Assemble", "assembler",
372 virtual bool hasIntegratedCPP() const { return false; }
374 virtual void ConstructJob(Compilation
&C
, const JobAction
&JA
,
375 const InputInfo
&Output
,
376 const InputInfoList
&Inputs
,
377 const ArgList
&TCArgs
,
378 const char *LinkingOutput
) const;
380 class LLVM_LIBRARY_VISIBILITY Link
: public Tool
{
382 Link(const ToolChain
&TC
) : Tool("minix::Link", "linker", TC
) {}
384 virtual bool hasIntegratedCPP() const { return false; }
386 virtual void ConstructJob(Compilation
&C
, const JobAction
&JA
,
387 const InputInfo
&Output
,
388 const InputInfoList
&Inputs
,
389 const ArgList
&TCArgs
,
390 const char *LinkingOutput
) const;
392 } // end namespace minix
394 /// auroraux -- Directly call GNU Binutils assembler and linker
396 class LLVM_LIBRARY_VISIBILITY Assemble
: public Tool
{
398 Assemble(const ToolChain
&TC
) : Tool("auroraux::Assemble", "assembler",
401 virtual bool hasIntegratedCPP() const { return false; }
403 virtual void ConstructJob(Compilation
&C
, const JobAction
&JA
,
404 const InputInfo
&Output
,
405 const InputInfoList
&Inputs
,
406 const ArgList
&TCArgs
,
407 const char *LinkingOutput
) const;
409 class LLVM_LIBRARY_VISIBILITY Link
: public Tool
{
411 Link(const ToolChain
&TC
) : Tool("auroraux::Link", "linker", TC
) {}
413 virtual bool hasIntegratedCPP() const { return false; }
415 virtual void ConstructJob(Compilation
&C
, const JobAction
&JA
,
416 const InputInfo
&Output
,
417 const InputInfoList
&Inputs
,
418 const ArgList
&TCArgs
,
419 const char *LinkingOutput
) const;
421 } // end namespace auroraux
423 /// dragonfly -- Directly call GNU Binutils assembler and linker
424 namespace dragonfly
{
425 class LLVM_LIBRARY_VISIBILITY Assemble
: public Tool
{
427 Assemble(const ToolChain
&TC
) : Tool("dragonfly::Assemble", "assembler",
430 virtual bool hasIntegratedCPP() const { return false; }
432 virtual void ConstructJob(Compilation
&C
, const JobAction
&JA
,
433 const InputInfo
&Output
,
434 const InputInfoList
&Inputs
,
435 const ArgList
&TCArgs
,
436 const char *LinkingOutput
) const;
438 class LLVM_LIBRARY_VISIBILITY Link
: public Tool
{
440 Link(const ToolChain
&TC
) : Tool("dragonfly::Link", "linker", TC
) {}
442 virtual bool hasIntegratedCPP() const { return false; }
444 virtual void ConstructJob(Compilation
&C
, const JobAction
&JA
,
445 const InputInfo
&Output
,
446 const InputInfoList
&Inputs
,
447 const ArgList
&TCArgs
,
448 const char *LinkingOutput
) const;
450 } // end namespace dragonfly
452 /// Visual studio tools.
453 namespace visualstudio
{
454 class LLVM_LIBRARY_VISIBILITY Link
: public Tool
{
456 Link(const ToolChain
&TC
) : Tool("visualstudio::Link", "linker", TC
) {}
458 virtual bool hasIntegratedCPP() const { return false; }
460 virtual void ConstructJob(Compilation
&C
, const JobAction
&JA
,
461 const InputInfo
&Output
,
462 const InputInfoList
&Inputs
,
463 const ArgList
&TCArgs
,
464 const char *LinkingOutput
) const;
466 } // end namespace visualstudio
468 } // end namespace toolchains
469 } // end namespace driver
470 } // end namespace clang
472 #endif // CLANG_LIB_DRIVER_TOOLS_H_