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