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