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