]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/lib/Driver/Tools.h
MFV r298178:
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / lib / Driver / Tools.h
1 //===--- Tools.h - Tool Implementations -------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_CLANG_LIB_DRIVER_TOOLS_H
11 #define LLVM_CLANG_LIB_DRIVER_TOOLS_H
12
13 #include "clang/Basic/VersionTuple.h"
14 #include "clang/Driver/Tool.h"
15 #include "clang/Driver/Types.h"
16 #include "clang/Driver/Util.h"
17 #include "clang/Frontend/CodeGenOptions.h"
18 #include "llvm/ADT/Triple.h"
19 #include "llvm/Option/Option.h"
20 #include "llvm/Support/Compiler.h"
21
22 namespace clang {
23 class ObjCRuntime;
24
25 namespace driver {
26 class Command;
27 class Driver;
28
29 namespace toolchains {
30 class MachO;
31 }
32
33 namespace tools {
34
35 namespace visualstudio {
36 class Compiler;
37 }
38
39 using llvm::opt::ArgStringList;
40
41 SmallString<128> getCompilerRT(const ToolChain &TC,
42                                const llvm::opt::ArgList &Args,
43                                StringRef Component, bool Shared = false);
44
45 /// \brief Clang compiler tool.
46 class LLVM_LIBRARY_VISIBILITY Clang : public Tool {
47 public:
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);
54
55 private:
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;
62
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 AddWebAssemblyTargetArgs(const llvm::opt::ArgList &Args,
86                                 llvm::opt::ArgStringList &CmdArgs) const;
87
88   enum RewriteKind { RK_None, RK_Fragile, RK_NonFragile };
89
90   ObjCRuntime AddObjCRuntimeArgs(const llvm::opt::ArgList &args,
91                                  llvm::opt::ArgStringList &cmdArgs,
92                                  RewriteKind rewrite) const;
93
94   void AddClangCLArgs(const llvm::opt::ArgList &Args,
95                       llvm::opt::ArgStringList &CmdArgs,
96                       enum CodeGenOptions::DebugInfoKind *DebugInfoKind,
97                       bool *EmitCodeView) const;
98
99   visualstudio::Compiler *getCLFallback() const;
100
101   mutable std::unique_ptr<visualstudio::Compiler> CLFallback;
102
103 public:
104   // CAUTION! The first constructor argument ("clang") is not arbitrary,
105   // as it is for other tools. Some operations on a Tool actually test
106   // whether that tool is Clang based on the Tool's Name as a string.
107   Clang(const ToolChain &TC) : Tool("clang", "clang frontend", TC, RF_Full) {}
108
109   bool hasGoodDiagnostics() const override { return true; }
110   bool hasIntegratedAssembler() const override { return true; }
111   bool hasIntegratedCPP() const override { return true; }
112   bool canEmitIR() const override { return true; }
113
114   void ConstructJob(Compilation &C, const JobAction &JA,
115                     const InputInfo &Output, const InputInfoList &Inputs,
116                     const llvm::opt::ArgList &TCArgs,
117                     const char *LinkingOutput) const override;
118 };
119
120 /// \brief Clang integrated assembler tool.
121 class LLVM_LIBRARY_VISIBILITY ClangAs : public Tool {
122 public:
123   ClangAs(const ToolChain &TC)
124       : Tool("clang::as", "clang integrated assembler", TC, RF_Full) {}
125   void AddMIPSTargetArgs(const llvm::opt::ArgList &Args,
126                          llvm::opt::ArgStringList &CmdArgs) const;
127   bool hasGoodDiagnostics() const override { return true; }
128   bool hasIntegratedAssembler() const override { return false; }
129   bool hasIntegratedCPP() const override { return false; }
130
131   void ConstructJob(Compilation &C, const JobAction &JA,
132                     const InputInfo &Output, const InputInfoList &Inputs,
133                     const llvm::opt::ArgList &TCArgs,
134                     const char *LinkingOutput) const override;
135 };
136
137 /// \brief Base class for all GNU tools that provide the same behavior when
138 /// it comes to response files support
139 class LLVM_LIBRARY_VISIBILITY GnuTool : public Tool {
140   virtual void anchor();
141
142 public:
143   GnuTool(const char *Name, const char *ShortName, const ToolChain &TC)
144       : Tool(Name, ShortName, TC, RF_Full, llvm::sys::WEM_CurrentCodePage) {}
145 };
146
147 /// gcc - Generic GCC tool implementations.
148 namespace gcc {
149 class LLVM_LIBRARY_VISIBILITY Common : public GnuTool {
150 public:
151   Common(const char *Name, const char *ShortName, const ToolChain &TC)
152       : GnuTool(Name, ShortName, TC) {}
153
154   // A gcc tool has an "integrated" assembler that it will call to produce an
155   // object. Let it use that assembler so that we don't have to deal with
156   // assembly syntax incompatibilities.
157   bool hasIntegratedAssembler() const override { return true; }
158   void ConstructJob(Compilation &C, const JobAction &JA,
159                     const InputInfo &Output, const InputInfoList &Inputs,
160                     const llvm::opt::ArgList &TCArgs,
161                     const char *LinkingOutput) const override;
162
163   /// RenderExtraToolArgs - Render any arguments necessary to force
164   /// the particular tool mode.
165   virtual void RenderExtraToolArgs(const JobAction &JA,
166                                    llvm::opt::ArgStringList &CmdArgs) const = 0;
167 };
168
169 class LLVM_LIBRARY_VISIBILITY Preprocessor : public Common {
170 public:
171   Preprocessor(const ToolChain &TC)
172       : Common("gcc::Preprocessor", "gcc preprocessor", TC) {}
173
174   bool hasGoodDiagnostics() const override { return true; }
175   bool hasIntegratedCPP() const override { return false; }
176
177   void RenderExtraToolArgs(const JobAction &JA,
178                            llvm::opt::ArgStringList &CmdArgs) const override;
179 };
180
181 class LLVM_LIBRARY_VISIBILITY Compiler : public Common {
182 public:
183   Compiler(const ToolChain &TC) : Common("gcc::Compiler", "gcc frontend", TC) {}
184
185   bool hasGoodDiagnostics() const override { return true; }
186   bool hasIntegratedCPP() const override { return true; }
187
188   void RenderExtraToolArgs(const JobAction &JA,
189                            llvm::opt::ArgStringList &CmdArgs) const override;
190 };
191
192 class LLVM_LIBRARY_VISIBILITY Linker : public Common {
193 public:
194   Linker(const ToolChain &TC) : Common("gcc::Linker", "linker (via gcc)", TC) {}
195
196   bool hasIntegratedCPP() const override { return false; }
197   bool isLinkJob() const override { return true; }
198
199   void RenderExtraToolArgs(const JobAction &JA,
200                            llvm::opt::ArgStringList &CmdArgs) const override;
201 };
202 } // end namespace gcc
203
204 namespace hexagon {
205 // For Hexagon, we do not need to instantiate tools for PreProcess, PreCompile
206 // and Compile.
207 // We simply use "clang -cc1" for those actions.
208 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
209 public:
210   Assembler(const ToolChain &TC)
211       : GnuTool("hexagon::Assembler", "hexagon-as", TC) {}
212
213   bool hasIntegratedCPP() const override { return false; }
214
215   void RenderExtraToolArgs(const JobAction &JA,
216                            llvm::opt::ArgStringList &CmdArgs) const;
217   void ConstructJob(Compilation &C, const JobAction &JA,
218                     const InputInfo &Output, const InputInfoList &Inputs,
219                     const llvm::opt::ArgList &TCArgs,
220                     const char *LinkingOutput) const override;
221 };
222
223 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
224 public:
225   Linker(const ToolChain &TC) : GnuTool("hexagon::Linker", "hexagon-ld", TC) {}
226
227   bool hasIntegratedCPP() const override { return false; }
228   bool isLinkJob() const override { return true; }
229
230   virtual void RenderExtraToolArgs(const JobAction &JA,
231                                    llvm::opt::ArgStringList &CmdArgs) const;
232   void ConstructJob(Compilation &C, const JobAction &JA,
233                     const InputInfo &Output, const InputInfoList &Inputs,
234                     const llvm::opt::ArgList &TCArgs,
235                     const char *LinkingOutput) const override;
236 };
237 } // end namespace hexagon.
238
239 namespace amdgpu {
240
241 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
242 public:
243   Linker(const ToolChain &TC) : GnuTool("amdgpu::Linker", "ld.lld", TC) {}
244   bool isLinkJob() const override { return true; }
245   bool hasIntegratedCPP() const override { return false; }
246   void ConstructJob(Compilation &C, const JobAction &JA,
247                     const InputInfo &Output, const InputInfoList &Inputs,
248                     const llvm::opt::ArgList &TCArgs,
249                     const char *LinkingOutput) const override;
250 };
251
252 } // end namespace amdgpu
253
254 namespace wasm {
255
256 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
257 public:
258   explicit Linker(const ToolChain &TC);
259   bool isLinkJob() const override;
260   bool hasIntegratedCPP() const override;
261   void ConstructJob(Compilation &C, const JobAction &JA,
262                     const InputInfo &Output, const InputInfoList &Inputs,
263                     const llvm::opt::ArgList &TCArgs,
264                     const char *LinkingOutput) const override;
265 };
266
267 } // end namespace wasm
268
269 namespace arm {
270 std::string getARMTargetCPU(StringRef CPU, StringRef Arch,
271                             const llvm::Triple &Triple);
272 const std::string getARMArch(StringRef Arch,
273                              const llvm::Triple &Triple);
274 StringRef getARMCPUForMArch(StringRef Arch, const llvm::Triple &Triple);
275 StringRef getLLVMArchSuffixForARM(StringRef CPU, StringRef Arch,
276                                   const llvm::Triple &Triple);
277
278 void appendEBLinkFlags(const llvm::opt::ArgList &Args, ArgStringList &CmdArgs,
279                        const llvm::Triple &Triple);
280 } // end namespace arm
281
282 namespace mips {
283 typedef enum { NanLegacy = 1, Nan2008 = 2 } NanEncoding;
284
285 enum class FloatABI {
286   Invalid,
287   Soft,
288   Hard,
289 };
290
291 NanEncoding getSupportedNanEncoding(StringRef &CPU);
292 void getMipsCPUAndABI(const llvm::opt::ArgList &Args,
293                       const llvm::Triple &Triple, StringRef &CPUName,
294                       StringRef &ABIName);
295 std::string getMipsABILibSuffix(const llvm::opt::ArgList &Args,
296                                 const llvm::Triple &Triple);
297 bool hasMipsAbiArg(const llvm::opt::ArgList &Args, const char *Value);
298 bool isUCLibc(const llvm::opt::ArgList &Args);
299 bool isNaN2008(const llvm::opt::ArgList &Args, const llvm::Triple &Triple);
300 bool isFPXXDefault(const llvm::Triple &Triple, StringRef CPUName,
301                    StringRef ABIName, mips::FloatABI FloatABI);
302 bool shouldUseFPXX(const llvm::opt::ArgList &Args, const llvm::Triple &Triple,
303                    StringRef CPUName, StringRef ABIName,
304                    mips::FloatABI FloatABI);
305 } // end namespace mips
306
307 namespace ppc {
308 bool hasPPCAbiArg(const llvm::opt::ArgList &Args, const char *Value);
309 } // end namespace ppc
310
311 /// cloudabi -- Directly call GNU Binutils linker
312 namespace cloudabi {
313 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
314 public:
315   Linker(const ToolChain &TC) : GnuTool("cloudabi::Linker", "linker", TC) {}
316
317   bool hasIntegratedCPP() const override { return false; }
318   bool isLinkJob() const override { return true; }
319
320   void ConstructJob(Compilation &C, const JobAction &JA,
321                     const InputInfo &Output, const InputInfoList &Inputs,
322                     const llvm::opt::ArgList &TCArgs,
323                     const char *LinkingOutput) const override;
324 };
325 } // end namespace cloudabi
326
327 namespace darwin {
328 llvm::Triple::ArchType getArchTypeForMachOArchName(StringRef Str);
329 void setTripleTypeForMachOArchName(llvm::Triple &T, StringRef Str);
330
331 class LLVM_LIBRARY_VISIBILITY MachOTool : public Tool {
332   virtual void anchor();
333
334 protected:
335   void AddMachOArch(const llvm::opt::ArgList &Args,
336                     llvm::opt::ArgStringList &CmdArgs) const;
337
338   const toolchains::MachO &getMachOToolChain() const {
339     return reinterpret_cast<const toolchains::MachO &>(getToolChain());
340   }
341
342 public:
343   MachOTool(
344       const char *Name, const char *ShortName, const ToolChain &TC,
345       ResponseFileSupport ResponseSupport = RF_None,
346       llvm::sys::WindowsEncodingMethod ResponseEncoding = llvm::sys::WEM_UTF8,
347       const char *ResponseFlag = "@")
348       : Tool(Name, ShortName, TC, ResponseSupport, ResponseEncoding,
349              ResponseFlag) {}
350 };
351
352 class LLVM_LIBRARY_VISIBILITY Assembler : public MachOTool {
353 public:
354   Assembler(const ToolChain &TC)
355       : MachOTool("darwin::Assembler", "assembler", TC) {}
356
357   bool hasIntegratedCPP() const override { return false; }
358
359   void ConstructJob(Compilation &C, const JobAction &JA,
360                     const InputInfo &Output, const InputInfoList &Inputs,
361                     const llvm::opt::ArgList &TCArgs,
362                     const char *LinkingOutput) const override;
363 };
364
365 class LLVM_LIBRARY_VISIBILITY Linker : public MachOTool {
366   bool NeedsTempPath(const InputInfoList &Inputs) const;
367   void AddLinkArgs(Compilation &C, const llvm::opt::ArgList &Args,
368                    llvm::opt::ArgStringList &CmdArgs,
369                    const InputInfoList &Inputs) const;
370
371 public:
372   Linker(const ToolChain &TC)
373       : MachOTool("darwin::Linker", "linker", TC, RF_FileList,
374                   llvm::sys::WEM_UTF8, "-filelist") {}
375
376   bool hasIntegratedCPP() const override { return false; }
377   bool isLinkJob() const override { return true; }
378
379   void ConstructJob(Compilation &C, const JobAction &JA,
380                     const InputInfo &Output, const InputInfoList &Inputs,
381                     const llvm::opt::ArgList &TCArgs,
382                     const char *LinkingOutput) const override;
383 };
384
385 class LLVM_LIBRARY_VISIBILITY Lipo : public MachOTool {
386 public:
387   Lipo(const ToolChain &TC) : MachOTool("darwin::Lipo", "lipo", TC) {}
388
389   bool hasIntegratedCPP() const override { return false; }
390
391   void ConstructJob(Compilation &C, const JobAction &JA,
392                     const InputInfo &Output, const InputInfoList &Inputs,
393                     const llvm::opt::ArgList &TCArgs,
394                     const char *LinkingOutput) const override;
395 };
396
397 class LLVM_LIBRARY_VISIBILITY Dsymutil : public MachOTool {
398 public:
399   Dsymutil(const ToolChain &TC)
400       : MachOTool("darwin::Dsymutil", "dsymutil", TC) {}
401
402   bool hasIntegratedCPP() const override { return false; }
403   bool isDsymutilJob() const override { return true; }
404
405   void ConstructJob(Compilation &C, const JobAction &JA,
406                     const InputInfo &Output, const InputInfoList &Inputs,
407                     const llvm::opt::ArgList &TCArgs,
408                     const char *LinkingOutput) const override;
409 };
410
411 class LLVM_LIBRARY_VISIBILITY VerifyDebug : public MachOTool {
412 public:
413   VerifyDebug(const ToolChain &TC)
414       : MachOTool("darwin::VerifyDebug", "dwarfdump", TC) {}
415
416   bool hasIntegratedCPP() const override { return false; }
417
418   void ConstructJob(Compilation &C, const JobAction &JA,
419                     const InputInfo &Output, const InputInfoList &Inputs,
420                     const llvm::opt::ArgList &TCArgs,
421                     const char *LinkingOutput) const override;
422 };
423 } // end namespace darwin
424
425 /// openbsd -- Directly call GNU Binutils assembler and linker
426 namespace openbsd {
427 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
428 public:
429   Assembler(const ToolChain &TC)
430       : GnuTool("openbsd::Assembler", "assembler", TC) {}
431
432   bool hasIntegratedCPP() const override { return false; }
433
434   void ConstructJob(Compilation &C, const JobAction &JA,
435                     const InputInfo &Output, const InputInfoList &Inputs,
436                     const llvm::opt::ArgList &TCArgs,
437                     const char *LinkingOutput) const override;
438 };
439
440 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
441 public:
442   Linker(const ToolChain &TC) : GnuTool("openbsd::Linker", "linker", TC) {}
443
444   bool hasIntegratedCPP() const override { return false; }
445   bool isLinkJob() const override { return true; }
446
447   void ConstructJob(Compilation &C, const JobAction &JA,
448                     const InputInfo &Output, const InputInfoList &Inputs,
449                     const llvm::opt::ArgList &TCArgs,
450                     const char *LinkingOutput) const override;
451 };
452 } // end namespace openbsd
453
454 /// bitrig -- Directly call GNU Binutils assembler and linker
455 namespace bitrig {
456 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
457 public:
458   Assembler(const ToolChain &TC)
459       : GnuTool("bitrig::Assembler", "assembler", TC) {}
460
461   bool hasIntegratedCPP() const override { return false; }
462
463   void ConstructJob(Compilation &C, const JobAction &JA,
464                     const InputInfo &Output, const InputInfoList &Inputs,
465                     const llvm::opt::ArgList &TCArgs,
466                     const char *LinkingOutput) const override;
467 };
468
469 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
470 public:
471   Linker(const ToolChain &TC) : GnuTool("bitrig::Linker", "linker", TC) {}
472
473   bool hasIntegratedCPP() const override { return false; }
474   bool isLinkJob() const override { return true; }
475
476   void ConstructJob(Compilation &C, const JobAction &JA,
477                     const InputInfo &Output, const InputInfoList &Inputs,
478                     const llvm::opt::ArgList &TCArgs,
479                     const char *LinkingOutput) const override;
480 };
481 } // end namespace bitrig
482
483 /// freebsd -- Directly call GNU Binutils assembler and linker
484 namespace freebsd {
485 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
486 public:
487   Assembler(const ToolChain &TC)
488       : GnuTool("freebsd::Assembler", "assembler", TC) {}
489
490   bool hasIntegratedCPP() const override { return false; }
491
492   void ConstructJob(Compilation &C, const JobAction &JA,
493                     const InputInfo &Output, const InputInfoList &Inputs,
494                     const llvm::opt::ArgList &TCArgs,
495                     const char *LinkingOutput) const override;
496 };
497
498 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
499 public:
500   Linker(const ToolChain &TC) : GnuTool("freebsd::Linker", "linker", TC) {}
501
502   bool hasIntegratedCPP() const override { return false; }
503   bool isLinkJob() const override { return true; }
504
505   void ConstructJob(Compilation &C, const JobAction &JA,
506                     const InputInfo &Output, const InputInfoList &Inputs,
507                     const llvm::opt::ArgList &TCArgs,
508                     const char *LinkingOutput) const override;
509 };
510 } // end namespace freebsd
511
512 /// netbsd -- Directly call GNU Binutils assembler and linker
513 namespace netbsd {
514 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
515 public:
516   Assembler(const ToolChain &TC)
517       : GnuTool("netbsd::Assembler", "assembler", TC) {}
518
519   bool hasIntegratedCPP() const override { return false; }
520
521   void ConstructJob(Compilation &C, const JobAction &JA,
522                     const InputInfo &Output, const InputInfoList &Inputs,
523                     const llvm::opt::ArgList &TCArgs,
524                     const char *LinkingOutput) const override;
525 };
526
527 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
528 public:
529   Linker(const ToolChain &TC) : GnuTool("netbsd::Linker", "linker", TC) {}
530
531   bool hasIntegratedCPP() const override { return false; }
532   bool isLinkJob() const override { return true; }
533
534   void ConstructJob(Compilation &C, const JobAction &JA,
535                     const InputInfo &Output, const InputInfoList &Inputs,
536                     const llvm::opt::ArgList &TCArgs,
537                     const char *LinkingOutput) const override;
538 };
539 } // end namespace netbsd
540
541 /// Directly call GNU Binutils' assembler and linker.
542 namespace gnutools {
543 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
544 public:
545   Assembler(const ToolChain &TC) : GnuTool("GNU::Assembler", "assembler", TC) {}
546
547   bool hasIntegratedCPP() const override { return false; }
548
549   void ConstructJob(Compilation &C, const JobAction &JA,
550                     const InputInfo &Output, const InputInfoList &Inputs,
551                     const llvm::opt::ArgList &TCArgs,
552                     const char *LinkingOutput) const override;
553 };
554
555 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
556 public:
557   Linker(const ToolChain &TC) : GnuTool("GNU::Linker", "linker", TC) {}
558
559   bool hasIntegratedCPP() const override { return false; }
560   bool isLinkJob() const override { return true; }
561
562   void ConstructJob(Compilation &C, const JobAction &JA,
563                     const InputInfo &Output, const InputInfoList &Inputs,
564                     const llvm::opt::ArgList &TCArgs,
565                     const char *LinkingOutput) const override;
566 };
567 } // end namespace gnutools
568
569 namespace nacltools {
570 class LLVM_LIBRARY_VISIBILITY AssemblerARM : public gnutools::Assembler {
571 public:
572   AssemblerARM(const ToolChain &TC) : gnutools::Assembler(TC) {}
573
574   void ConstructJob(Compilation &C, const JobAction &JA,
575                     const InputInfo &Output, const InputInfoList &Inputs,
576                     const llvm::opt::ArgList &TCArgs,
577                     const char *LinkingOutput) const override;
578 };
579
580 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
581 public:
582   Linker(const ToolChain &TC) : GnuTool("NaCl::Linker", "linker", TC) {}
583
584   bool hasIntegratedCPP() const override { return false; }
585   bool isLinkJob() const override { return true; }
586
587   void ConstructJob(Compilation &C, const JobAction &JA,
588                     const InputInfo &Output, const InputInfoList &Inputs,
589                     const llvm::opt::ArgList &TCArgs,
590                     const char *LinkingOutput) const override;
591 };
592 } // end namespace nacltools
593
594 /// minix -- Directly call GNU Binutils assembler and linker
595 namespace minix {
596 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
597 public:
598   Assembler(const ToolChain &TC)
599       : GnuTool("minix::Assembler", "assembler", TC) {}
600
601   bool hasIntegratedCPP() const override { return false; }
602
603   void ConstructJob(Compilation &C, const JobAction &JA,
604                     const InputInfo &Output, const InputInfoList &Inputs,
605                     const llvm::opt::ArgList &TCArgs,
606                     const char *LinkingOutput) const override;
607 };
608
609 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
610 public:
611   Linker(const ToolChain &TC) : GnuTool("minix::Linker", "linker", TC) {}
612
613   bool hasIntegratedCPP() const override { return false; }
614   bool isLinkJob() const override { return true; }
615
616   void ConstructJob(Compilation &C, const JobAction &JA,
617                     const InputInfo &Output, const InputInfoList &Inputs,
618                     const llvm::opt::ArgList &TCArgs,
619                     const char *LinkingOutput) const override;
620 };
621 } // end namespace minix
622
623 /// solaris -- Directly call Solaris assembler and linker
624 namespace solaris {
625 class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
626 public:
627   Assembler(const ToolChain &TC)
628       : Tool("solaris::Assembler", "assembler", TC) {}
629
630   bool hasIntegratedCPP() const override { return false; }
631
632   void ConstructJob(Compilation &C, const JobAction &JA,
633                     const InputInfo &Output, const InputInfoList &Inputs,
634                     const llvm::opt::ArgList &TCArgs,
635                     const char *LinkingOutput) const override;
636 };
637
638 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
639 public:
640   Linker(const ToolChain &TC) : Tool("solaris::Linker", "linker", TC) {}
641
642   bool hasIntegratedCPP() const override { return false; }
643   bool isLinkJob() const override { return true; }
644
645   void ConstructJob(Compilation &C, const JobAction &JA,
646                     const InputInfo &Output, const InputInfoList &Inputs,
647                     const llvm::opt::ArgList &TCArgs,
648                     const char *LinkingOutput) const override;
649 };
650 } // end namespace solaris
651
652 /// dragonfly -- Directly call GNU Binutils assembler and linker
653 namespace dragonfly {
654 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
655 public:
656   Assembler(const ToolChain &TC)
657       : GnuTool("dragonfly::Assembler", "assembler", TC) {}
658
659   bool hasIntegratedCPP() const override { return false; }
660
661   void ConstructJob(Compilation &C, const JobAction &JA,
662                     const InputInfo &Output, const InputInfoList &Inputs,
663                     const llvm::opt::ArgList &TCArgs,
664                     const char *LinkingOutput) const override;
665 };
666
667 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
668 public:
669   Linker(const ToolChain &TC) : GnuTool("dragonfly::Linker", "linker", TC) {}
670
671   bool hasIntegratedCPP() const override { return false; }
672   bool isLinkJob() const override { return true; }
673
674   void ConstructJob(Compilation &C, const JobAction &JA,
675                     const InputInfo &Output, const InputInfoList &Inputs,
676                     const llvm::opt::ArgList &TCArgs,
677                     const char *LinkingOutput) const override;
678 };
679 } // end namespace dragonfly
680
681 /// Visual studio tools.
682 namespace visualstudio {
683 VersionTuple getMSVCVersion(const Driver *D, const llvm::Triple &Triple,
684                             const llvm::opt::ArgList &Args, bool IsWindowsMSVC);
685
686 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
687 public:
688   Linker(const ToolChain &TC)
689       : Tool("visualstudio::Linker", "linker", TC, RF_Full,
690              llvm::sys::WEM_UTF16) {}
691
692   bool hasIntegratedCPP() const override { return false; }
693   bool isLinkJob() const override { return true; }
694
695   void ConstructJob(Compilation &C, const JobAction &JA,
696                     const InputInfo &Output, const InputInfoList &Inputs,
697                     const llvm::opt::ArgList &TCArgs,
698                     const char *LinkingOutput) const override;
699 };
700
701 class LLVM_LIBRARY_VISIBILITY Compiler : public Tool {
702 public:
703   Compiler(const ToolChain &TC)
704       : Tool("visualstudio::Compiler", "compiler", TC, RF_Full,
705              llvm::sys::WEM_UTF16) {}
706
707   bool hasIntegratedAssembler() const override { return true; }
708   bool hasIntegratedCPP() const override { return true; }
709   bool isLinkJob() const override { return false; }
710
711   void ConstructJob(Compilation &C, const JobAction &JA,
712                     const InputInfo &Output, const InputInfoList &Inputs,
713                     const llvm::opt::ArgList &TCArgs,
714                     const char *LinkingOutput) const override;
715
716   std::unique_ptr<Command> GetCommand(Compilation &C, const JobAction &JA,
717                                       const InputInfo &Output,
718                                       const InputInfoList &Inputs,
719                                       const llvm::opt::ArgList &TCArgs,
720                                       const char *LinkingOutput) const;
721 };
722 } // end namespace visualstudio
723
724 /// MinGW -- Directly call GNU Binutils assembler and linker
725 namespace MinGW {
726 class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
727 public:
728   Assembler(const ToolChain &TC) : Tool("MinGW::Assemble", "assembler", TC) {}
729
730   bool hasIntegratedCPP() const override { return false; }
731
732   void ConstructJob(Compilation &C, const JobAction &JA,
733                     const InputInfo &Output, const InputInfoList &Inputs,
734                     const llvm::opt::ArgList &TCArgs,
735                     const char *LinkingOutput) const override;
736 };
737
738 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
739 public:
740   Linker(const ToolChain &TC) : Tool("MinGW::Linker", "linker", TC) {}
741
742   bool hasIntegratedCPP() const override { return false; }
743   bool isLinkJob() const override { return true; }
744
745   void ConstructJob(Compilation &C, const JobAction &JA,
746                     const InputInfo &Output, const InputInfoList &Inputs,
747                     const llvm::opt::ArgList &TCArgs,
748                     const char *LinkingOutput) const override;
749
750 private:
751   void AddLibGCC(const llvm::opt::ArgList &Args, ArgStringList &CmdArgs) const;
752 };
753 } // end namespace MinGW
754
755 namespace arm {
756 enum class FloatABI {
757   Invalid,
758   Soft,
759   SoftFP,
760   Hard,
761 };
762
763 FloatABI getARMFloatABI(const ToolChain &TC, const llvm::opt::ArgList &Args);
764 } // end namespace arm
765
766 namespace ppc {
767 enum class FloatABI {
768   Invalid,
769   Soft,
770   Hard,
771 };
772
773 FloatABI getPPCFloatABI(const Driver &D, const llvm::opt::ArgList &Args);
774 } // end namespace ppc
775
776 namespace XCore {
777 // For XCore, we do not need to instantiate tools for PreProcess, PreCompile and
778 // Compile.
779 // We simply use "clang -cc1" for those actions.
780 class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
781 public:
782   Assembler(const ToolChain &TC) : Tool("XCore::Assembler", "XCore-as", TC) {}
783
784   bool hasIntegratedCPP() const override { return false; }
785   void ConstructJob(Compilation &C, const JobAction &JA,
786                     const InputInfo &Output, const InputInfoList &Inputs,
787                     const llvm::opt::ArgList &TCArgs,
788                     const char *LinkingOutput) const override;
789 };
790
791 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
792 public:
793   Linker(const ToolChain &TC) : Tool("XCore::Linker", "XCore-ld", TC) {}
794
795   bool hasIntegratedCPP() const override { return false; }
796   bool isLinkJob() const override { return true; }
797   void ConstructJob(Compilation &C, const JobAction &JA,
798                     const InputInfo &Output, const InputInfoList &Inputs,
799                     const llvm::opt::ArgList &TCArgs,
800                     const char *LinkingOutput) const override;
801 };
802 } // end namespace XCore.
803
804 namespace CrossWindows {
805 class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
806 public:
807   Assembler(const ToolChain &TC) : Tool("CrossWindows::Assembler", "as", TC) {}
808
809   bool hasIntegratedCPP() const override { return false; }
810
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;
815 };
816
817 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
818 public:
819   Linker(const ToolChain &TC)
820       : Tool("CrossWindows::Linker", "ld", TC, RF_Full) {}
821
822   bool hasIntegratedCPP() const override { return false; }
823   bool isLinkJob() const override { return true; }
824
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;
829 };
830 } // end namespace CrossWindows
831
832 /// SHAVE tools -- Directly call moviCompile and moviAsm
833 namespace SHAVE {
834 class LLVM_LIBRARY_VISIBILITY Compiler : public Tool {
835 public:
836   Compiler(const ToolChain &TC) : Tool("moviCompile", "movicompile", TC) {}
837
838   bool hasIntegratedCPP() const override { return true; }
839
840   void ConstructJob(Compilation &C, const JobAction &JA,
841                     const InputInfo &Output, const InputInfoList &Inputs,
842                     const llvm::opt::ArgList &TCArgs,
843                     const char *LinkingOutput) const override;
844 };
845
846 class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
847 public:
848   Assembler(const ToolChain &TC) : Tool("moviAsm", "moviAsm", TC) {}
849
850   bool hasIntegratedCPP() const override { return false; } // not sure.
851
852   void ConstructJob(Compilation &C, const JobAction &JA,
853                     const InputInfo &Output, const InputInfoList &Inputs,
854                     const llvm::opt::ArgList &TCArgs,
855                     const char *LinkingOutput) const override;
856 };
857 } // end namespace SHAVE
858
859 /// The Myriad toolchain uses tools that are in two different namespaces.
860 /// The Compiler and Assembler as defined above are in the SHAVE namespace,
861 /// whereas the linker, which accepts code for a mixture of Sparc and SHAVE,
862 /// is in the Myriad namespace.
863 namespace Myriad {
864 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
865 public:
866   Linker(const ToolChain &TC) : GnuTool("shave::Linker", "ld", TC) {}
867   bool hasIntegratedCPP() const override { return false; }
868   bool isLinkJob() const override { return true; }
869   void ConstructJob(Compilation &C, const JobAction &JA,
870                     const InputInfo &Output, const InputInfoList &Inputs,
871                     const llvm::opt::ArgList &TCArgs,
872                     const char *LinkingOutput) const override;
873 };
874 } // end namespace Myriad
875
876 namespace PS4cpu {
877 class LLVM_LIBRARY_VISIBILITY Assemble : public Tool {
878 public:
879   Assemble(const ToolChain &TC)
880       : Tool("PS4cpu::Assemble", "assembler", TC, RF_Full) {}
881
882   bool hasIntegratedCPP() const override { return false; }
883
884   void ConstructJob(Compilation &C, const JobAction &JA,
885                     const InputInfo &Output,
886                     const InputInfoList &Inputs,
887                     const llvm::opt::ArgList &TCArgs,
888                     const char *LinkingOutput) const override;
889 };
890
891 class LLVM_LIBRARY_VISIBILITY Link : public Tool {
892 public:
893   Link(const ToolChain &TC) : Tool("PS4cpu::Link", "linker", TC, RF_Full) {}
894
895   bool hasIntegratedCPP() const override { return false; }
896   bool isLinkJob() const override { return true; }
897
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;
903 };
904 } // end namespace PS4cpu
905
906 } // end namespace tools
907 } // end namespace driver
908 } // end namespace clang
909
910 #endif // LLVM_CLANG_LIB_DRIVER_TOOLS_H