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 LLVM_CLANG_LIB_DRIVER_TOOLS_H
11 #define LLVM_CLANG_LIB_DRIVER_TOOLS_H
13 #include "clang/Basic/DebugInfoOptions.h"
14 #include "clang/Basic/VersionTuple.h"
15 #include "clang/Driver/Tool.h"
16 #include "clang/Driver/Types.h"
17 #include "clang/Driver/Util.h"
18 #include "llvm/ADT/Triple.h"
19 #include "llvm/Option/Option.h"
20 #include "llvm/Support/Compiler.h"
29 namespace toolchains {
35 namespace visualstudio {
39 using llvm::opt::ArgStringList;
41 SmallString<128> getCompilerRT(const ToolChain &TC,
42 const llvm::opt::ArgList &Args,
43 StringRef Component, bool Shared = false);
45 /// \brief Clang compiler tool.
46 class LLVM_LIBRARY_VISIBILITY Clang : public Tool {
48 static const char *getBaseInputName(const llvm::opt::ArgList &Args,
49 const InputInfo &Input);
50 static const char *getBaseInputStem(const llvm::opt::ArgList &Args,
51 const InputInfoList &Inputs);
52 static const char *getDependencyFileName(const llvm::opt::ArgList &Args,
53 const InputInfoList &Inputs);
56 void AddPreprocessingOptions(Compilation &C, const JobAction &JA,
57 const Driver &D, const llvm::opt::ArgList &Args,
58 llvm::opt::ArgStringList &CmdArgs,
59 const InputInfo &Output,
60 const InputInfoList &Inputs,
61 const ToolChain *AuxToolChain) const;
63 void AddAArch64TargetArgs(const llvm::opt::ArgList &Args,
64 llvm::opt::ArgStringList &CmdArgs) const;
65 void AddARMTargetArgs(const llvm::Triple &Triple,
66 const llvm::opt::ArgList &Args,
67 llvm::opt::ArgStringList &CmdArgs,
68 bool KernelOrKext) const;
69 void AddARM64TargetArgs(const llvm::opt::ArgList &Args,
70 llvm::opt::ArgStringList &CmdArgs) const;
71 void AddMIPSTargetArgs(const llvm::opt::ArgList &Args,
72 llvm::opt::ArgStringList &CmdArgs) const;
73 void AddPPCTargetArgs(const llvm::opt::ArgList &Args,
74 llvm::opt::ArgStringList &CmdArgs) const;
75 void AddR600TargetArgs(const llvm::opt::ArgList &Args,
76 llvm::opt::ArgStringList &CmdArgs) const;
77 void AddSparcTargetArgs(const llvm::opt::ArgList &Args,
78 llvm::opt::ArgStringList &CmdArgs) const;
79 void AddSystemZTargetArgs(const llvm::opt::ArgList &Args,
80 llvm::opt::ArgStringList &CmdArgs) const;
81 void AddX86TargetArgs(const llvm::opt::ArgList &Args,
82 llvm::opt::ArgStringList &CmdArgs) const;
83 void AddHexagonTargetArgs(const llvm::opt::ArgList &Args,
84 llvm::opt::ArgStringList &CmdArgs) const;
85 void AddLanaiTargetArgs(const llvm::opt::ArgList &Args,
86 llvm::opt::ArgStringList &CmdArgs) const;
87 void AddWebAssemblyTargetArgs(const llvm::opt::ArgList &Args,
88 llvm::opt::ArgStringList &CmdArgs) const;
90 enum RewriteKind { RK_None, RK_Fragile, RK_NonFragile };
92 ObjCRuntime AddObjCRuntimeArgs(const llvm::opt::ArgList &args,
93 llvm::opt::ArgStringList &cmdArgs,
94 RewriteKind rewrite) const;
96 void AddClangCLArgs(const llvm::opt::ArgList &Args, types::ID InputType,
97 llvm::opt::ArgStringList &CmdArgs,
98 codegenoptions::DebugInfoKind *DebugInfoKind,
99 bool *EmitCodeView) const;
101 visualstudio::Compiler *getCLFallback() const;
103 mutable std::unique_ptr<visualstudio::Compiler> CLFallback;
106 // CAUTION! The first constructor argument ("clang") is not arbitrary,
107 // as it is for other tools. Some operations on a Tool actually test
108 // whether that tool is Clang based on the Tool's Name as a string.
109 Clang(const ToolChain &TC) : Tool("clang", "clang frontend", TC, RF_Full) {}
111 bool hasGoodDiagnostics() const override { return true; }
112 bool hasIntegratedAssembler() const override { return true; }
113 bool hasIntegratedCPP() const override { return true; }
114 bool canEmitIR() const override { return true; }
116 void ConstructJob(Compilation &C, const JobAction &JA,
117 const InputInfo &Output, const InputInfoList &Inputs,
118 const llvm::opt::ArgList &TCArgs,
119 const char *LinkingOutput) const override;
122 /// \brief Clang integrated assembler tool.
123 class LLVM_LIBRARY_VISIBILITY ClangAs : public Tool {
125 ClangAs(const ToolChain &TC)
126 : Tool("clang::as", "clang integrated assembler", TC, RF_Full) {}
127 void AddMIPSTargetArgs(const llvm::opt::ArgList &Args,
128 llvm::opt::ArgStringList &CmdArgs) const;
129 bool hasGoodDiagnostics() const override { return true; }
130 bool hasIntegratedAssembler() const override { return false; }
131 bool hasIntegratedCPP() const override { return false; }
133 void ConstructJob(Compilation &C, const JobAction &JA,
134 const InputInfo &Output, const InputInfoList &Inputs,
135 const llvm::opt::ArgList &TCArgs,
136 const char *LinkingOutput) const override;
139 /// \brief Base class for all GNU tools that provide the same behavior when
140 /// it comes to response files support
141 class LLVM_LIBRARY_VISIBILITY GnuTool : public Tool {
142 virtual void anchor();
145 GnuTool(const char *Name, const char *ShortName, const ToolChain &TC)
146 : Tool(Name, ShortName, TC, RF_Full, llvm::sys::WEM_CurrentCodePage) {}
149 /// gcc - Generic GCC tool implementations.
151 class LLVM_LIBRARY_VISIBILITY Common : public GnuTool {
153 Common(const char *Name, const char *ShortName, const ToolChain &TC)
154 : GnuTool(Name, ShortName, TC) {}
156 // A gcc tool has an "integrated" assembler that it will call to produce an
157 // object. Let it use that assembler so that we don't have to deal with
158 // assembly syntax incompatibilities.
159 bool hasIntegratedAssembler() const override { return true; }
160 void ConstructJob(Compilation &C, const JobAction &JA,
161 const InputInfo &Output, const InputInfoList &Inputs,
162 const llvm::opt::ArgList &TCArgs,
163 const char *LinkingOutput) const override;
165 /// RenderExtraToolArgs - Render any arguments necessary to force
166 /// the particular tool mode.
167 virtual void RenderExtraToolArgs(const JobAction &JA,
168 llvm::opt::ArgStringList &CmdArgs) const = 0;
171 class LLVM_LIBRARY_VISIBILITY Preprocessor : public Common {
173 Preprocessor(const ToolChain &TC)
174 : Common("gcc::Preprocessor", "gcc preprocessor", TC) {}
176 bool hasGoodDiagnostics() const override { return true; }
177 bool hasIntegratedCPP() const override { return false; }
179 void RenderExtraToolArgs(const JobAction &JA,
180 llvm::opt::ArgStringList &CmdArgs) const override;
183 class LLVM_LIBRARY_VISIBILITY Compiler : public Common {
185 Compiler(const ToolChain &TC) : Common("gcc::Compiler", "gcc frontend", TC) {}
187 bool hasGoodDiagnostics() const override { return true; }
188 bool hasIntegratedCPP() const override { return true; }
190 void RenderExtraToolArgs(const JobAction &JA,
191 llvm::opt::ArgStringList &CmdArgs) const override;
194 class LLVM_LIBRARY_VISIBILITY Linker : public Common {
196 Linker(const ToolChain &TC) : Common("gcc::Linker", "linker (via gcc)", TC) {}
198 bool hasIntegratedCPP() const override { return false; }
199 bool isLinkJob() const override { return true; }
201 void RenderExtraToolArgs(const JobAction &JA,
202 llvm::opt::ArgStringList &CmdArgs) const override;
204 } // end namespace gcc
207 // For Hexagon, we do not need to instantiate tools for PreProcess, PreCompile
209 // We simply use "clang -cc1" for those actions.
210 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
212 Assembler(const ToolChain &TC)
213 : GnuTool("hexagon::Assembler", "hexagon-as", TC) {}
215 bool hasIntegratedCPP() const override { return false; }
217 void RenderExtraToolArgs(const JobAction &JA,
218 llvm::opt::ArgStringList &CmdArgs) const;
219 void ConstructJob(Compilation &C, const JobAction &JA,
220 const InputInfo &Output, const InputInfoList &Inputs,
221 const llvm::opt::ArgList &TCArgs,
222 const char *LinkingOutput) const override;
225 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
227 Linker(const ToolChain &TC) : GnuTool("hexagon::Linker", "hexagon-ld", TC) {}
229 bool hasIntegratedCPP() const override { return false; }
230 bool isLinkJob() const override { return true; }
232 virtual void RenderExtraToolArgs(const JobAction &JA,
233 llvm::opt::ArgStringList &CmdArgs) const;
234 void ConstructJob(Compilation &C, const JobAction &JA,
235 const InputInfo &Output, const InputInfoList &Inputs,
236 const llvm::opt::ArgList &TCArgs,
237 const char *LinkingOutput) const override;
239 } // end namespace hexagon.
243 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
245 Linker(const ToolChain &TC) : GnuTool("amdgpu::Linker", "ld.lld", TC) {}
246 bool isLinkJob() const override { return true; }
247 bool hasIntegratedCPP() const override { return false; }
248 void ConstructJob(Compilation &C, const JobAction &JA,
249 const InputInfo &Output, const InputInfoList &Inputs,
250 const llvm::opt::ArgList &TCArgs,
251 const char *LinkingOutput) const override;
254 } // end namespace amdgpu
258 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
260 explicit Linker(const ToolChain &TC);
261 bool isLinkJob() const override;
262 bool hasIntegratedCPP() const override;
263 void ConstructJob(Compilation &C, const JobAction &JA,
264 const InputInfo &Output, const InputInfoList &Inputs,
265 const llvm::opt::ArgList &TCArgs,
266 const char *LinkingOutput) const override;
269 } // end namespace wasm
272 std::string getARMTargetCPU(StringRef CPU, StringRef Arch,
273 const llvm::Triple &Triple);
274 const std::string getARMArch(StringRef Arch,
275 const llvm::Triple &Triple);
276 StringRef getARMCPUForMArch(StringRef Arch, const llvm::Triple &Triple);
277 StringRef getLLVMArchSuffixForARM(StringRef CPU, StringRef Arch,
278 const llvm::Triple &Triple);
280 void appendEBLinkFlags(const llvm::opt::ArgList &Args, ArgStringList &CmdArgs,
281 const llvm::Triple &Triple);
282 } // end namespace arm
285 typedef enum { NanLegacy = 1, Nan2008 = 2 } NanEncoding;
287 enum class FloatABI {
293 NanEncoding getSupportedNanEncoding(StringRef &CPU);
294 void getMipsCPUAndABI(const llvm::opt::ArgList &Args,
295 const llvm::Triple &Triple, StringRef &CPUName,
297 std::string getMipsABILibSuffix(const llvm::opt::ArgList &Args,
298 const llvm::Triple &Triple);
299 bool hasMipsAbiArg(const llvm::opt::ArgList &Args, const char *Value);
300 bool isUCLibc(const llvm::opt::ArgList &Args);
301 bool isNaN2008(const llvm::opt::ArgList &Args, const llvm::Triple &Triple);
302 bool isFP64ADefault(const llvm::Triple &Triple, StringRef CPUName);
303 bool isFPXXDefault(const llvm::Triple &Triple, StringRef CPUName,
304 StringRef ABIName, mips::FloatABI FloatABI);
305 bool shouldUseFPXX(const llvm::opt::ArgList &Args, const llvm::Triple &Triple,
306 StringRef CPUName, StringRef ABIName,
307 mips::FloatABI FloatABI);
308 } // end namespace mips
311 bool hasPPCAbiArg(const llvm::opt::ArgList &Args, const char *Value);
312 } // end namespace ppc
314 /// cloudabi -- Directly call GNU Binutils linker
316 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
318 Linker(const ToolChain &TC) : GnuTool("cloudabi::Linker", "linker", TC) {}
320 bool hasIntegratedCPP() const override { return false; }
321 bool isLinkJob() const override { return true; }
323 void ConstructJob(Compilation &C, const JobAction &JA,
324 const InputInfo &Output, const InputInfoList &Inputs,
325 const llvm::opt::ArgList &TCArgs,
326 const char *LinkingOutput) const override;
328 } // end namespace cloudabi
331 llvm::Triple::ArchType getArchTypeForMachOArchName(StringRef Str);
332 void setTripleTypeForMachOArchName(llvm::Triple &T, StringRef Str);
334 class LLVM_LIBRARY_VISIBILITY MachOTool : public Tool {
335 virtual void anchor();
338 void AddMachOArch(const llvm::opt::ArgList &Args,
339 llvm::opt::ArgStringList &CmdArgs) const;
341 const toolchains::MachO &getMachOToolChain() const {
342 return reinterpret_cast<const toolchains::MachO &>(getToolChain());
347 const char *Name, const char *ShortName, const ToolChain &TC,
348 ResponseFileSupport ResponseSupport = RF_None,
349 llvm::sys::WindowsEncodingMethod ResponseEncoding = llvm::sys::WEM_UTF8,
350 const char *ResponseFlag = "@")
351 : Tool(Name, ShortName, TC, ResponseSupport, ResponseEncoding,
355 class LLVM_LIBRARY_VISIBILITY Assembler : public MachOTool {
357 Assembler(const ToolChain &TC)
358 : MachOTool("darwin::Assembler", "assembler", TC) {}
360 bool hasIntegratedCPP() const override { return false; }
362 void ConstructJob(Compilation &C, const JobAction &JA,
363 const InputInfo &Output, const InputInfoList &Inputs,
364 const llvm::opt::ArgList &TCArgs,
365 const char *LinkingOutput) const override;
368 class LLVM_LIBRARY_VISIBILITY Linker : public MachOTool {
369 bool NeedsTempPath(const InputInfoList &Inputs) const;
370 void AddLinkArgs(Compilation &C, const llvm::opt::ArgList &Args,
371 llvm::opt::ArgStringList &CmdArgs,
372 const InputInfoList &Inputs) const;
375 Linker(const ToolChain &TC)
376 : MachOTool("darwin::Linker", "linker", TC, RF_FileList,
377 llvm::sys::WEM_UTF8, "-filelist") {}
379 bool hasIntegratedCPP() const override { return false; }
380 bool isLinkJob() const override { return true; }
382 void ConstructJob(Compilation &C, const JobAction &JA,
383 const InputInfo &Output, const InputInfoList &Inputs,
384 const llvm::opt::ArgList &TCArgs,
385 const char *LinkingOutput) const override;
388 class LLVM_LIBRARY_VISIBILITY Lipo : public MachOTool {
390 Lipo(const ToolChain &TC) : MachOTool("darwin::Lipo", "lipo", TC) {}
392 bool hasIntegratedCPP() const override { return false; }
394 void ConstructJob(Compilation &C, const JobAction &JA,
395 const InputInfo &Output, const InputInfoList &Inputs,
396 const llvm::opt::ArgList &TCArgs,
397 const char *LinkingOutput) const override;
400 class LLVM_LIBRARY_VISIBILITY Dsymutil : public MachOTool {
402 Dsymutil(const ToolChain &TC)
403 : MachOTool("darwin::Dsymutil", "dsymutil", TC) {}
405 bool hasIntegratedCPP() const override { return false; }
406 bool isDsymutilJob() const override { return true; }
408 void ConstructJob(Compilation &C, const JobAction &JA,
409 const InputInfo &Output, const InputInfoList &Inputs,
410 const llvm::opt::ArgList &TCArgs,
411 const char *LinkingOutput) const override;
414 class LLVM_LIBRARY_VISIBILITY VerifyDebug : public MachOTool {
416 VerifyDebug(const ToolChain &TC)
417 : MachOTool("darwin::VerifyDebug", "dwarfdump", TC) {}
419 bool hasIntegratedCPP() const override { return false; }
421 void ConstructJob(Compilation &C, const JobAction &JA,
422 const InputInfo &Output, const InputInfoList &Inputs,
423 const llvm::opt::ArgList &TCArgs,
424 const char *LinkingOutput) const override;
426 } // end namespace darwin
428 /// openbsd -- Directly call GNU Binutils assembler and linker
430 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
432 Assembler(const ToolChain &TC)
433 : GnuTool("openbsd::Assembler", "assembler", TC) {}
435 bool hasIntegratedCPP() const override { return false; }
437 void ConstructJob(Compilation &C, const JobAction &JA,
438 const InputInfo &Output, const InputInfoList &Inputs,
439 const llvm::opt::ArgList &TCArgs,
440 const char *LinkingOutput) const override;
443 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
445 Linker(const ToolChain &TC) : GnuTool("openbsd::Linker", "linker", TC) {}
447 bool hasIntegratedCPP() const override { return false; }
448 bool isLinkJob() const override { return true; }
450 void ConstructJob(Compilation &C, const JobAction &JA,
451 const InputInfo &Output, const InputInfoList &Inputs,
452 const llvm::opt::ArgList &TCArgs,
453 const char *LinkingOutput) const override;
455 } // end namespace openbsd
457 /// bitrig -- Directly call GNU Binutils assembler and linker
459 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
461 Assembler(const ToolChain &TC)
462 : GnuTool("bitrig::Assembler", "assembler", TC) {}
464 bool hasIntegratedCPP() const override { return false; }
466 void ConstructJob(Compilation &C, const JobAction &JA,
467 const InputInfo &Output, const InputInfoList &Inputs,
468 const llvm::opt::ArgList &TCArgs,
469 const char *LinkingOutput) const override;
472 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
474 Linker(const ToolChain &TC) : GnuTool("bitrig::Linker", "linker", TC) {}
476 bool hasIntegratedCPP() const override { return false; }
477 bool isLinkJob() const override { return true; }
479 void ConstructJob(Compilation &C, const JobAction &JA,
480 const InputInfo &Output, const InputInfoList &Inputs,
481 const llvm::opt::ArgList &TCArgs,
482 const char *LinkingOutput) const override;
484 } // end namespace bitrig
486 /// freebsd -- Directly call GNU Binutils assembler and linker
488 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
490 Assembler(const ToolChain &TC)
491 : GnuTool("freebsd::Assembler", "assembler", TC) {}
493 bool hasIntegratedCPP() const override { return false; }
495 void ConstructJob(Compilation &C, const JobAction &JA,
496 const InputInfo &Output, const InputInfoList &Inputs,
497 const llvm::opt::ArgList &TCArgs,
498 const char *LinkingOutput) const override;
501 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
503 Linker(const ToolChain &TC) : GnuTool("freebsd::Linker", "linker", TC) {}
505 bool hasIntegratedCPP() const override { return false; }
506 bool isLinkJob() const override { return true; }
508 void ConstructJob(Compilation &C, const JobAction &JA,
509 const InputInfo &Output, const InputInfoList &Inputs,
510 const llvm::opt::ArgList &TCArgs,
511 const char *LinkingOutput) const override;
513 } // end namespace freebsd
515 /// netbsd -- Directly call GNU Binutils assembler and linker
517 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
519 Assembler(const ToolChain &TC)
520 : GnuTool("netbsd::Assembler", "assembler", TC) {}
522 bool hasIntegratedCPP() const override { return false; }
524 void ConstructJob(Compilation &C, const JobAction &JA,
525 const InputInfo &Output, const InputInfoList &Inputs,
526 const llvm::opt::ArgList &TCArgs,
527 const char *LinkingOutput) const override;
530 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
532 Linker(const ToolChain &TC) : GnuTool("netbsd::Linker", "linker", TC) {}
534 bool hasIntegratedCPP() const override { return false; }
535 bool isLinkJob() const override { return true; }
537 void ConstructJob(Compilation &C, const JobAction &JA,
538 const InputInfo &Output, const InputInfoList &Inputs,
539 const llvm::opt::ArgList &TCArgs,
540 const char *LinkingOutput) const override;
542 } // end namespace netbsd
544 /// Directly call GNU Binutils' assembler and linker.
546 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
548 Assembler(const ToolChain &TC) : GnuTool("GNU::Assembler", "assembler", TC) {}
550 bool hasIntegratedCPP() const override { return false; }
552 void ConstructJob(Compilation &C, const JobAction &JA,
553 const InputInfo &Output, const InputInfoList &Inputs,
554 const llvm::opt::ArgList &TCArgs,
555 const char *LinkingOutput) const override;
558 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
560 Linker(const ToolChain &TC) : GnuTool("GNU::Linker", "linker", TC) {}
562 bool hasIntegratedCPP() const override { return false; }
563 bool isLinkJob() const override { return true; }
565 void ConstructJob(Compilation &C, const JobAction &JA,
566 const InputInfo &Output, const InputInfoList &Inputs,
567 const llvm::opt::ArgList &TCArgs,
568 const char *LinkingOutput) const override;
570 } // end namespace gnutools
572 namespace nacltools {
573 class LLVM_LIBRARY_VISIBILITY AssemblerARM : public gnutools::Assembler {
575 AssemblerARM(const ToolChain &TC) : gnutools::Assembler(TC) {}
577 void ConstructJob(Compilation &C, const JobAction &JA,
578 const InputInfo &Output, const InputInfoList &Inputs,
579 const llvm::opt::ArgList &TCArgs,
580 const char *LinkingOutput) const override;
583 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
585 Linker(const ToolChain &TC) : GnuTool("NaCl::Linker", "linker", TC) {}
587 bool hasIntegratedCPP() const override { return false; }
588 bool isLinkJob() const override { return true; }
590 void ConstructJob(Compilation &C, const JobAction &JA,
591 const InputInfo &Output, const InputInfoList &Inputs,
592 const llvm::opt::ArgList &TCArgs,
593 const char *LinkingOutput) const override;
595 } // end namespace nacltools
597 /// minix -- Directly call GNU Binutils assembler and linker
599 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
601 Assembler(const ToolChain &TC)
602 : GnuTool("minix::Assembler", "assembler", TC) {}
604 bool hasIntegratedCPP() const override { return false; }
606 void ConstructJob(Compilation &C, const JobAction &JA,
607 const InputInfo &Output, const InputInfoList &Inputs,
608 const llvm::opt::ArgList &TCArgs,
609 const char *LinkingOutput) const override;
612 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
614 Linker(const ToolChain &TC) : GnuTool("minix::Linker", "linker", TC) {}
616 bool hasIntegratedCPP() const override { return false; }
617 bool isLinkJob() const override { return true; }
619 void ConstructJob(Compilation &C, const JobAction &JA,
620 const InputInfo &Output, const InputInfoList &Inputs,
621 const llvm::opt::ArgList &TCArgs,
622 const char *LinkingOutput) const override;
624 } // end namespace minix
626 /// solaris -- Directly call Solaris assembler and linker
628 class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
630 Assembler(const ToolChain &TC)
631 : Tool("solaris::Assembler", "assembler", TC) {}
633 bool hasIntegratedCPP() const override { return false; }
635 void ConstructJob(Compilation &C, const JobAction &JA,
636 const InputInfo &Output, const InputInfoList &Inputs,
637 const llvm::opt::ArgList &TCArgs,
638 const char *LinkingOutput) const override;
641 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
643 Linker(const ToolChain &TC) : Tool("solaris::Linker", "linker", TC) {}
645 bool hasIntegratedCPP() const override { return false; }
646 bool isLinkJob() const override { return true; }
648 void ConstructJob(Compilation &C, const JobAction &JA,
649 const InputInfo &Output, const InputInfoList &Inputs,
650 const llvm::opt::ArgList &TCArgs,
651 const char *LinkingOutput) const override;
653 } // end namespace solaris
655 /// dragonfly -- Directly call GNU Binutils assembler and linker
656 namespace dragonfly {
657 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
659 Assembler(const ToolChain &TC)
660 : GnuTool("dragonfly::Assembler", "assembler", TC) {}
662 bool hasIntegratedCPP() const override { return false; }
664 void ConstructJob(Compilation &C, const JobAction &JA,
665 const InputInfo &Output, const InputInfoList &Inputs,
666 const llvm::opt::ArgList &TCArgs,
667 const char *LinkingOutput) const override;
670 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
672 Linker(const ToolChain &TC) : GnuTool("dragonfly::Linker", "linker", TC) {}
674 bool hasIntegratedCPP() const override { return false; }
675 bool isLinkJob() const override { return true; }
677 void ConstructJob(Compilation &C, const JobAction &JA,
678 const InputInfo &Output, const InputInfoList &Inputs,
679 const llvm::opt::ArgList &TCArgs,
680 const char *LinkingOutput) const override;
682 } // end namespace dragonfly
684 /// Visual studio tools.
685 namespace visualstudio {
686 VersionTuple getMSVCVersion(const Driver *D, const ToolChain &TC,
687 const llvm::Triple &Triple,
688 const llvm::opt::ArgList &Args, bool IsWindowsMSVC);
690 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
692 Linker(const ToolChain &TC)
693 : Tool("visualstudio::Linker", "linker", TC, RF_Full,
694 llvm::sys::WEM_UTF16) {}
696 bool hasIntegratedCPP() const override { return false; }
697 bool isLinkJob() const override { return true; }
699 void ConstructJob(Compilation &C, const JobAction &JA,
700 const InputInfo &Output, const InputInfoList &Inputs,
701 const llvm::opt::ArgList &TCArgs,
702 const char *LinkingOutput) const override;
705 class LLVM_LIBRARY_VISIBILITY Compiler : public Tool {
707 Compiler(const ToolChain &TC)
708 : Tool("visualstudio::Compiler", "compiler", TC, RF_Full,
709 llvm::sys::WEM_UTF16) {}
711 bool hasIntegratedAssembler() const override { return true; }
712 bool hasIntegratedCPP() const override { return true; }
713 bool isLinkJob() const override { return false; }
715 void ConstructJob(Compilation &C, const JobAction &JA,
716 const InputInfo &Output, const InputInfoList &Inputs,
717 const llvm::opt::ArgList &TCArgs,
718 const char *LinkingOutput) const override;
720 std::unique_ptr<Command> GetCommand(Compilation &C, const JobAction &JA,
721 const InputInfo &Output,
722 const InputInfoList &Inputs,
723 const llvm::opt::ArgList &TCArgs,
724 const char *LinkingOutput) const;
726 } // end namespace visualstudio
728 /// MinGW -- Directly call GNU Binutils assembler and linker
730 class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
732 Assembler(const ToolChain &TC) : Tool("MinGW::Assemble", "assembler", TC) {}
734 bool hasIntegratedCPP() const override { return false; }
736 void ConstructJob(Compilation &C, const JobAction &JA,
737 const InputInfo &Output, const InputInfoList &Inputs,
738 const llvm::opt::ArgList &TCArgs,
739 const char *LinkingOutput) const override;
742 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
744 Linker(const ToolChain &TC) : Tool("MinGW::Linker", "linker", TC) {}
746 bool hasIntegratedCPP() const override { return false; }
747 bool isLinkJob() const override { return true; }
749 void ConstructJob(Compilation &C, const JobAction &JA,
750 const InputInfo &Output, const InputInfoList &Inputs,
751 const llvm::opt::ArgList &TCArgs,
752 const char *LinkingOutput) const override;
755 void AddLibGCC(const llvm::opt::ArgList &Args, ArgStringList &CmdArgs) const;
757 } // end namespace MinGW
760 enum class FloatABI {
767 FloatABI getARMFloatABI(const ToolChain &TC, const llvm::opt::ArgList &Args);
768 } // end namespace arm
771 enum class FloatABI {
777 FloatABI getPPCFloatABI(const Driver &D, const llvm::opt::ArgList &Args);
778 } // end namespace ppc
781 enum class FloatABI {
787 FloatABI getSparcFloatABI(const Driver &D, const llvm::opt::ArgList &Args);
788 } // end namespace sparc
791 // For XCore, we do not need to instantiate tools for PreProcess, PreCompile and
793 // We simply use "clang -cc1" for those actions.
794 class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
796 Assembler(const ToolChain &TC) : Tool("XCore::Assembler", "XCore-as", TC) {}
798 bool hasIntegratedCPP() const override { return false; }
799 void ConstructJob(Compilation &C, const JobAction &JA,
800 const InputInfo &Output, const InputInfoList &Inputs,
801 const llvm::opt::ArgList &TCArgs,
802 const char *LinkingOutput) const override;
805 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
807 Linker(const ToolChain &TC) : Tool("XCore::Linker", "XCore-ld", TC) {}
809 bool hasIntegratedCPP() const override { return false; }
810 bool isLinkJob() const override { return true; }
811 void ConstructJob(Compilation &C, const JobAction &JA,
812 const InputInfo &Output, const InputInfoList &Inputs,
813 const llvm::opt::ArgList &TCArgs,
814 const char *LinkingOutput) const override;
816 } // end namespace XCore.
818 namespace CrossWindows {
819 class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
821 Assembler(const ToolChain &TC) : Tool("CrossWindows::Assembler", "as", TC) {}
823 bool hasIntegratedCPP() const override { return false; }
825 void ConstructJob(Compilation &C, const JobAction &JA,
826 const InputInfo &Output, const InputInfoList &Inputs,
827 const llvm::opt::ArgList &TCArgs,
828 const char *LinkingOutput) const override;
831 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
833 Linker(const ToolChain &TC)
834 : Tool("CrossWindows::Linker", "ld", TC, RF_Full) {}
836 bool hasIntegratedCPP() const override { return false; }
837 bool isLinkJob() const override { return true; }
839 void ConstructJob(Compilation &C, const JobAction &JA,
840 const InputInfo &Output, const InputInfoList &Inputs,
841 const llvm::opt::ArgList &TCArgs,
842 const char *LinkingOutput) const override;
844 } // end namespace CrossWindows
846 /// SHAVE tools -- Directly call moviCompile and moviAsm
848 class LLVM_LIBRARY_VISIBILITY Compiler : public Tool {
850 Compiler(const ToolChain &TC) : Tool("moviCompile", "movicompile", TC) {}
852 bool hasIntegratedCPP() const override { return true; }
854 void ConstructJob(Compilation &C, const JobAction &JA,
855 const InputInfo &Output, const InputInfoList &Inputs,
856 const llvm::opt::ArgList &TCArgs,
857 const char *LinkingOutput) const override;
860 class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
862 Assembler(const ToolChain &TC) : Tool("moviAsm", "moviAsm", TC) {}
864 bool hasIntegratedCPP() const override { return false; } // not sure.
866 void ConstructJob(Compilation &C, const JobAction &JA,
867 const InputInfo &Output, const InputInfoList &Inputs,
868 const llvm::opt::ArgList &TCArgs,
869 const char *LinkingOutput) const override;
871 } // end namespace SHAVE
873 /// The Myriad toolchain uses tools that are in two different namespaces.
874 /// The Compiler and Assembler as defined above are in the SHAVE namespace,
875 /// whereas the linker, which accepts code for a mixture of Sparc and SHAVE,
876 /// is in the Myriad namespace.
878 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
880 Linker(const ToolChain &TC) : GnuTool("shave::Linker", "ld", TC) {}
881 bool hasIntegratedCPP() const override { return false; }
882 bool isLinkJob() const override { return true; }
883 void ConstructJob(Compilation &C, const JobAction &JA,
884 const InputInfo &Output, const InputInfoList &Inputs,
885 const llvm::opt::ArgList &TCArgs,
886 const char *LinkingOutput) const override;
888 } // end namespace Myriad
891 class LLVM_LIBRARY_VISIBILITY Assemble : public Tool {
893 Assemble(const ToolChain &TC)
894 : Tool("PS4cpu::Assemble", "assembler", TC, RF_Full) {}
896 bool hasIntegratedCPP() const override { return false; }
898 void ConstructJob(Compilation &C, const JobAction &JA,
899 const InputInfo &Output,
900 const InputInfoList &Inputs,
901 const llvm::opt::ArgList &TCArgs,
902 const char *LinkingOutput) const override;
905 class LLVM_LIBRARY_VISIBILITY Link : public Tool {
907 Link(const ToolChain &TC) : Tool("PS4cpu::Link", "linker", TC, RF_Full) {}
909 bool hasIntegratedCPP() const override { return false; }
910 bool isLinkJob() const override { return true; }
912 void ConstructJob(Compilation &C, const JobAction &JA,
913 const InputInfo &Output,
914 const InputInfoList &Inputs,
915 const llvm::opt::ArgList &TCArgs,
916 const char *LinkingOutput) const override;
918 } // end namespace PS4cpu
922 // Run ptxas, the NVPTX assembler.
923 class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
925 Assembler(const ToolChain &TC)
926 : Tool("NVPTX::Assembler", "ptxas", TC, RF_Full, llvm::sys::WEM_UTF8,
929 bool hasIntegratedCPP() const override { return false; }
931 void ConstructJob(Compilation &C, const JobAction &JA,
932 const InputInfo &Output, const InputInfoList &Inputs,
933 const llvm::opt::ArgList &TCArgs,
934 const char *LinkingOutput) const override;
937 // Runs fatbinary, which combines GPU object files ("cubin" files) and/or PTX
938 // assembly into a single output file.
939 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
941 Linker(const ToolChain &TC)
942 : Tool("NVPTX::Linker", "fatbinary", TC, RF_Full, llvm::sys::WEM_UTF8,
945 bool hasIntegratedCPP() const override { return false; }
947 void ConstructJob(Compilation &C, const JobAction &JA,
948 const InputInfo &Output, const InputInfoList &Inputs,
949 const llvm::opt::ArgList &TCArgs,
950 const char *LinkingOutput) const override;
953 } // end namespace NVPTX
955 } // end namespace tools
956 } // end namespace driver
957 } // end namespace clang
959 #endif // LLVM_CLANG_LIB_DRIVER_TOOLS_H