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