xref: /NextBSD/contrib/llvm/tools/clang/lib/Driver/Tools.h (revision 84d351007654069f9643c8e4b4802a7f5f08ee42)
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 "llvm/ADT/Triple.h"
18 #include "llvm/Option/Option.h"
19 #include "llvm/Support/Compiler.h"
20 
21 namespace clang {
22   class ObjCRuntime;
23 
24 namespace driver {
25   class Command;
26   class Driver;
27 
28 namespace toolchains {
29   class MachO;
30 }
31 
32 namespace tools {
33 
34 namespace visualstudio {
35 class Compiler;
36 }
37 
38 using llvm::opt::ArgStringList;
39 
40 SmallString<128> getCompilerRT(const ToolChain &TC, StringRef Component,
41                                bool Shared = false);
42 
43   /// \brief Clang compiler tool.
44   class LLVM_LIBRARY_VISIBILITY Clang : public Tool {
45   public:
46     static const char *getBaseInputName(const llvm::opt::ArgList &Args,
47                                         const InputInfo &Input);
48     static const char *getBaseInputStem(const llvm::opt::ArgList &Args,
49                                         const InputInfoList &Inputs);
50     static const char *getDependencyFileName(const llvm::opt::ArgList &Args,
51                                              const InputInfoList &Inputs);
52 
53   private:
54     void AddPreprocessingOptions(Compilation &C, const JobAction &JA,
55                                  const Driver &D,
56                                  const llvm::opt::ArgList &Args,
57                                  llvm::opt::ArgStringList &CmdArgs,
58                                  const InputInfo &Output,
59                                  const InputInfoList &Inputs) const;
60 
61     void AddAArch64TargetArgs(const llvm::opt::ArgList &Args,
62                               llvm::opt::ArgStringList &CmdArgs) const;
63     void AddARMTargetArgs(const llvm::opt::ArgList &Args,
64                           llvm::opt::ArgStringList &CmdArgs,
65                           bool KernelOrKext) const;
66     void AddARM64TargetArgs(const llvm::opt::ArgList &Args,
67                             llvm::opt::ArgStringList &CmdArgs) const;
68     void AddMIPSTargetArgs(const llvm::opt::ArgList &Args,
69                            llvm::opt::ArgStringList &CmdArgs) const;
70     void AddPPCTargetArgs(const llvm::opt::ArgList &Args,
71                           llvm::opt::ArgStringList &CmdArgs) const;
72     void AddR600TargetArgs(const llvm::opt::ArgList &Args,
73                            llvm::opt::ArgStringList &CmdArgs) const;
74     void AddSparcTargetArgs(const llvm::opt::ArgList &Args,
75                             llvm::opt::ArgStringList &CmdArgs) const;
76     void AddSystemZTargetArgs(const llvm::opt::ArgList &Args,
77                               llvm::opt::ArgStringList &CmdArgs) const;
78     void AddX86TargetArgs(const llvm::opt::ArgList &Args,
79                           llvm::opt::ArgStringList &CmdArgs) const;
80     void AddHexagonTargetArgs(const llvm::opt::ArgList &Args,
81                               llvm::opt::ArgStringList &CmdArgs) const;
82 
83     enum RewriteKind { RK_None, RK_Fragile, RK_NonFragile };
84 
85     ObjCRuntime AddObjCRuntimeArgs(const llvm::opt::ArgList &args,
86                                    llvm::opt::ArgStringList &cmdArgs,
87                                    RewriteKind rewrite) const;
88 
89     void AddClangCLArgs(const llvm::opt::ArgList &Args,
90                         llvm::opt::ArgStringList &CmdArgs) const;
91 
92     visualstudio::Compiler *getCLFallback() const;
93 
94     mutable std::unique_ptr<visualstudio::Compiler> CLFallback;
95 
96   public:
97     // CAUTION! The first constructor argument ("clang") is not arbitrary,
98     // as it is for other tools. Some operations on a Tool actually test
99     // whether that tool is Clang based on the Tool's Name as a string.
Clang(const ToolChain & TC)100     Clang(const ToolChain &TC) : Tool("clang", "clang frontend", TC, RF_Full) {}
101 
hasGoodDiagnostics()102     bool hasGoodDiagnostics() const override { return true; }
hasIntegratedAssembler()103     bool hasIntegratedAssembler() const override { return true; }
hasIntegratedCPP()104     bool hasIntegratedCPP() const override { return true; }
canEmitIR()105     bool canEmitIR() const override { return true; }
106 
107     void ConstructJob(Compilation &C, const JobAction &JA,
108                       const InputInfo &Output, const InputInfoList &Inputs,
109                       const llvm::opt::ArgList &TCArgs,
110                       const char *LinkingOutput) const override;
111   };
112 
113   /// \brief Clang integrated assembler tool.
114   class LLVM_LIBRARY_VISIBILITY ClangAs : public Tool {
115   public:
ClangAs(const ToolChain & TC)116     ClangAs(const ToolChain &TC) : Tool("clang::as",
117                                         "clang integrated assembler", TC,
118                                         RF_Full) {}
119     void AddMIPSTargetArgs(const llvm::opt::ArgList &Args,
120                            llvm::opt::ArgStringList &CmdArgs) const;
hasGoodDiagnostics()121     bool hasGoodDiagnostics() const override { return true; }
hasIntegratedAssembler()122     bool hasIntegratedAssembler() const override { return false; }
hasIntegratedCPP()123     bool hasIntegratedCPP() const override { return false; }
124 
125     void ConstructJob(Compilation &C, const JobAction &JA,
126                       const InputInfo &Output, const InputInfoList &Inputs,
127                       const llvm::opt::ArgList &TCArgs,
128                       const char *LinkingOutput) const override;
129   };
130 
131   /// \brief Base class for all GNU tools that provide the same behavior when
132   /// it comes to response files support
133   class LLVM_LIBRARY_VISIBILITY GnuTool : public Tool {
134     virtual void anchor();
135 
136   public:
GnuTool(const char * Name,const char * ShortName,const ToolChain & TC)137     GnuTool(const char *Name, const char *ShortName, const ToolChain &TC)
138         : Tool(Name, ShortName, TC, RF_Full, llvm::sys::WEM_CurrentCodePage) {}
139   };
140 
141   /// gcc - Generic GCC tool implementations.
142 namespace gcc {
143   class LLVM_LIBRARY_VISIBILITY Common : public GnuTool {
144   public:
Common(const char * Name,const char * ShortName,const ToolChain & TC)145     Common(const char *Name, const char *ShortName,
146            const ToolChain &TC) : GnuTool(Name, ShortName, TC) {}
147 
148     void ConstructJob(Compilation &C, const JobAction &JA,
149                       const InputInfo &Output,
150                       const InputInfoList &Inputs,
151                       const llvm::opt::ArgList &TCArgs,
152                       const char *LinkingOutput) const override;
153 
154     /// RenderExtraToolArgs - Render any arguments necessary to force
155     /// the particular tool mode.
156     virtual void
157     RenderExtraToolArgs(const JobAction &JA,
158                         llvm::opt::ArgStringList &CmdArgs) const = 0;
159   };
160 
161   class LLVM_LIBRARY_VISIBILITY Preprocessor : public Common {
162   public:
Preprocessor(const ToolChain & TC)163     Preprocessor(const ToolChain &TC)
164         : Common("gcc::Preprocessor", "gcc preprocessor", TC) {}
165 
hasGoodDiagnostics()166     bool hasGoodDiagnostics() const override { return true; }
hasIntegratedCPP()167     bool hasIntegratedCPP() const override { return false; }
168 
169     void RenderExtraToolArgs(const JobAction &JA,
170                              llvm::opt::ArgStringList &CmdArgs) const override;
171   };
172 
173   class LLVM_LIBRARY_VISIBILITY Compiler : public Common {
174   public:
Compiler(const ToolChain & TC)175     Compiler(const ToolChain &TC)
176         : Common("gcc::Compiler", "gcc frontend", TC) {}
177 
hasGoodDiagnostics()178     bool hasGoodDiagnostics() const override { return true; }
hasIntegratedCPP()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:
Linker(const ToolChain & TC)187     Linker(const ToolChain &TC)
188         : Common("gcc::Linker", "linker (via gcc)", TC) {}
189 
hasIntegratedCPP()190     bool hasIntegratedCPP() const override { return false; }
isLinkJob()191     bool isLinkJob() const override { return true; }
192 
193     void RenderExtraToolArgs(const JobAction &JA,
194                              llvm::opt::ArgStringList &CmdArgs) const override;
195   };
196 } // end namespace gcc
197 
198 namespace hexagon {
199 // For Hexagon, we do not need to instantiate tools for PreProcess, PreCompile
200 // and Compile.
201 // We simply use "clang -cc1" for those actions.
202 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
203 public:
Assembler(const ToolChain & TC)204   Assembler(const ToolChain &TC)
205       : GnuTool("hexagon::Assembler", "hexagon-as", TC) {}
206 
hasIntegratedCPP()207   bool hasIntegratedCPP() const override { return false; }
208 
209     void RenderExtraToolArgs(const JobAction &JA,
210                              llvm::opt::ArgStringList &CmdArgs) const;
211     void ConstructJob(Compilation &C, const JobAction &JA,
212                       const InputInfo &Output, const InputInfoList &Inputs,
213                       const llvm::opt::ArgList &TCArgs,
214                       const char *LinkingOutput) const override;
215 };
216 
217 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
218 public:
Linker(const ToolChain & TC)219   Linker(const ToolChain &TC) : GnuTool("hexagon::Linker", "hexagon-ld", TC) {}
220 
hasIntegratedCPP()221   bool hasIntegratedCPP() const override { return false; }
isLinkJob()222     bool isLinkJob() const override { return true; }
223 
224     virtual void RenderExtraToolArgs(const JobAction &JA,
225                                      llvm::opt::ArgStringList &CmdArgs) const;
226     void ConstructJob(Compilation &C, const JobAction &JA,
227                       const InputInfo &Output, const InputInfoList &Inputs,
228                       const llvm::opt::ArgList &TCArgs,
229                       const char *LinkingOutput) const override;
230   };
231 } // end namespace hexagon.
232 
233 namespace arm {
234   std::string getARMTargetCPU(StringRef CPU, StringRef Arch,
235                               const llvm::Triple &Triple);
236   const std::string getARMArch(StringRef Arch,
237                                const llvm::Triple &Triple);
238   const char* getARMCPUForMArch(StringRef Arch,
239                                 const llvm::Triple &Triple);
240   const char* getLLVMArchSuffixForARM(StringRef CPU, StringRef Arch);
241 
242   void appendEBLinkFlags(const llvm::opt::ArgList &Args, ArgStringList &CmdArgs, const llvm::Triple &Triple);
243 }
244 
245 namespace mips {
246   typedef enum {
247     NanLegacy = 1,
248     Nan2008 = 2
249   } NanEncoding;
250   NanEncoding getSupportedNanEncoding(StringRef &CPU);
251   void getMipsCPUAndABI(const llvm::opt::ArgList &Args,
252                         const llvm::Triple &Triple, StringRef &CPUName,
253                         StringRef &ABIName);
254   bool hasMipsAbiArg(const llvm::opt::ArgList &Args, const char *Value);
255   bool isUCLibc(const llvm::opt::ArgList &Args);
256   bool isNaN2008(const llvm::opt::ArgList &Args, const llvm::Triple &Triple);
257   bool isFPXXDefault(const llvm::Triple &Triple, StringRef CPUName,
258                      StringRef ABIName, StringRef FloatABI);
259   bool shouldUseFPXX(const llvm::opt::ArgList &Args, const llvm::Triple &Triple,
260                      StringRef CPUName, StringRef ABIName, StringRef FloatABI);
261 }
262 
263 namespace ppc {
264   bool hasPPCAbiArg(const llvm::opt::ArgList &Args, const char *Value);
265 }
266 
267 /// cloudabi -- Directly call GNU Binutils linker
268 namespace cloudabi {
269 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
270 public:
Linker(const ToolChain & TC)271   Linker(const ToolChain &TC) : GnuTool("cloudabi::Linker", "linker", TC) {}
272 
hasIntegratedCPP()273   bool hasIntegratedCPP() const override { return false; }
isLinkJob()274   bool isLinkJob() const override { return true; }
275 
276   void ConstructJob(Compilation &C, const JobAction &JA,
277                     const InputInfo &Output, const InputInfoList &Inputs,
278                     const llvm::opt::ArgList &TCArgs,
279                     const char *LinkingOutput) const override;
280 };
281 } // end namespace cloudabi
282 
283 namespace darwin {
284   llvm::Triple::ArchType getArchTypeForMachOArchName(StringRef Str);
285   void setTripleTypeForMachOArchName(llvm::Triple &T, StringRef Str);
286 
287   class LLVM_LIBRARY_VISIBILITY MachOTool : public Tool {
288     virtual void anchor();
289   protected:
290     void AddMachOArch(const llvm::opt::ArgList &Args,
291                        llvm::opt::ArgStringList &CmdArgs) const;
292 
getMachOToolChain()293     const toolchains::MachO &getMachOToolChain() const {
294       return reinterpret_cast<const toolchains::MachO&>(getToolChain());
295     }
296 
297   public:
298     MachOTool(
299         const char *Name, const char *ShortName, const ToolChain &TC,
300         ResponseFileSupport ResponseSupport = RF_None,
301         llvm::sys::WindowsEncodingMethod ResponseEncoding = llvm::sys::WEM_UTF8,
302         const char *ResponseFlag = "@")
Tool(Name,ShortName,TC,ResponseSupport,ResponseEncoding,ResponseFlag)303         : Tool(Name, ShortName, TC, ResponseSupport, ResponseEncoding,
304                ResponseFlag) {}
305   };
306 
307   class LLVM_LIBRARY_VISIBILITY Assembler : public MachOTool {
308   public:
Assembler(const ToolChain & TC)309     Assembler(const ToolChain &TC)
310         : MachOTool("darwin::Assembler", "assembler", TC) {}
311 
hasIntegratedCPP()312     bool hasIntegratedCPP() const override { return false; }
313 
314     void ConstructJob(Compilation &C, const JobAction &JA,
315                       const InputInfo &Output, const InputInfoList &Inputs,
316                       const llvm::opt::ArgList &TCArgs,
317                       const char *LinkingOutput) const override;
318   };
319 
320   class LLVM_LIBRARY_VISIBILITY Linker : public MachOTool {
321     bool NeedsTempPath(const InputInfoList &Inputs) const;
322     void AddLinkArgs(Compilation &C, const llvm::opt::ArgList &Args,
323                      llvm::opt::ArgStringList &CmdArgs,
324                      const InputInfoList &Inputs) const;
325 
326   public:
Linker(const ToolChain & TC)327     Linker(const ToolChain &TC)
328         : MachOTool("darwin::Linker", "linker", TC, RF_FileList,
329                     llvm::sys::WEM_UTF8, "-filelist") {}
330 
hasIntegratedCPP()331     bool hasIntegratedCPP() const override { return false; }
isLinkJob()332     bool isLinkJob() const override { return true; }
333 
334     void ConstructJob(Compilation &C, const JobAction &JA,
335                       const InputInfo &Output, const InputInfoList &Inputs,
336                       const llvm::opt::ArgList &TCArgs,
337                       const char *LinkingOutput) const override;
338   };
339 
340   class LLVM_LIBRARY_VISIBILITY Lipo : public MachOTool  {
341   public:
Lipo(const ToolChain & TC)342     Lipo(const ToolChain &TC) : MachOTool("darwin::Lipo", "lipo", TC) {}
343 
hasIntegratedCPP()344     bool hasIntegratedCPP() const override { return false; }
345 
346     void ConstructJob(Compilation &C, const JobAction &JA,
347                       const InputInfo &Output, const InputInfoList &Inputs,
348                       const llvm::opt::ArgList &TCArgs,
349                       const char *LinkingOutput) const override;
350   };
351 
352   class LLVM_LIBRARY_VISIBILITY Dsymutil : public MachOTool  {
353   public:
Dsymutil(const ToolChain & TC)354     Dsymutil(const ToolChain &TC) : MachOTool("darwin::Dsymutil",
355                                               "dsymutil", TC) {}
356 
hasIntegratedCPP()357     bool hasIntegratedCPP() const override { return false; }
isDsymutilJob()358     bool isDsymutilJob() const override { return true; }
359 
360     void ConstructJob(Compilation &C, const JobAction &JA,
361                       const InputInfo &Output,
362                       const InputInfoList &Inputs,
363                       const llvm::opt::ArgList &TCArgs,
364                       const char *LinkingOutput) const override;
365   };
366 
367   class LLVM_LIBRARY_VISIBILITY VerifyDebug : public MachOTool  {
368   public:
VerifyDebug(const ToolChain & TC)369     VerifyDebug(const ToolChain &TC) : MachOTool("darwin::VerifyDebug",
370                                                  "dwarfdump", TC) {}
371 
hasIntegratedCPP()372     bool hasIntegratedCPP() const override { return false; }
373 
374     void ConstructJob(Compilation &C, const JobAction &JA,
375                       const InputInfo &Output, const InputInfoList &Inputs,
376                       const llvm::opt::ArgList &TCArgs,
377                       const char *LinkingOutput) const override;
378   };
379 
380 }
381 
382 /// openbsd -- Directly call GNU Binutils assembler and linker
383 namespace openbsd {
384 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
385 public:
Assembler(const ToolChain & TC)386   Assembler(const ToolChain &TC)
387       : GnuTool("openbsd::Assembler", "assembler", TC) {}
388 
hasIntegratedCPP()389   bool hasIntegratedCPP() const override { return false; }
390 
391   void ConstructJob(Compilation &C, const JobAction &JA,
392                     const InputInfo &Output, const InputInfoList &Inputs,
393                     const llvm::opt::ArgList &TCArgs,
394                     const char *LinkingOutput) const override;
395 };
396 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
397 public:
Linker(const ToolChain & TC)398   Linker(const ToolChain &TC) : GnuTool("openbsd::Linker", "linker", TC) {}
399 
hasIntegratedCPP()400   bool hasIntegratedCPP() const override { return false; }
isLinkJob()401   bool isLinkJob() 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 } // end namespace openbsd
409 
410 /// bitrig -- Directly call GNU Binutils assembler and linker
411 namespace bitrig {
412 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
413 public:
Assembler(const ToolChain & TC)414   Assembler(const ToolChain &TC)
415       : GnuTool("bitrig::Assembler", "assembler", TC) {}
416 
hasIntegratedCPP()417   bool hasIntegratedCPP() const override { return false; }
418 
419   void ConstructJob(Compilation &C, const JobAction &JA,
420                     const InputInfo &Output, const InputInfoList &Inputs,
421                     const llvm::opt::ArgList &TCArgs,
422                     const char *LinkingOutput) const override;
423 };
424 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
425 public:
Linker(const ToolChain & TC)426   Linker(const ToolChain &TC) : GnuTool("bitrig::Linker", "linker", TC) {}
427 
hasIntegratedCPP()428   bool hasIntegratedCPP() const override { return false; }
isLinkJob()429   bool isLinkJob() const override { return true; }
430 
431     void ConstructJob(Compilation &C, const JobAction &JA,
432                       const InputInfo &Output, const InputInfoList &Inputs,
433                       const llvm::opt::ArgList &TCArgs,
434                       const char *LinkingOutput) const override;
435   };
436 } // end namespace bitrig
437 
438 /// freebsd -- Directly call GNU Binutils assembler and linker
439 namespace freebsd {
440 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
441 public:
Assembler(const ToolChain & TC)442   Assembler(const ToolChain &TC)
443       : GnuTool("freebsd::Assembler", "assembler", TC) {}
444 
hasIntegratedCPP()445   bool hasIntegratedCPP() const override { return false; }
446 
447   void ConstructJob(Compilation &C, const JobAction &JA,
448                     const InputInfo &Output, const InputInfoList &Inputs,
449                     const llvm::opt::ArgList &TCArgs,
450                     const char *LinkingOutput) const override;
451 };
452 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
453 public:
Linker(const ToolChain & TC)454   Linker(const ToolChain &TC) : GnuTool("freebsd::Linker", "linker", TC) {}
455 
hasIntegratedCPP()456   bool hasIntegratedCPP() const override { return false; }
isLinkJob()457   bool isLinkJob() const override { return true; }
458 
459     void ConstructJob(Compilation &C, const JobAction &JA,
460                       const InputInfo &Output, const InputInfoList &Inputs,
461                       const llvm::opt::ArgList &TCArgs,
462                       const char *LinkingOutput) const override;
463   };
464 } // end namespace freebsd
465 
466 /// netbsd -- Directly call GNU Binutils assembler and linker
467 namespace netbsd {
468 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
469 
470 public:
Assembler(const ToolChain & TC)471   Assembler(const ToolChain &TC)
472       : GnuTool("netbsd::Assembler", "assembler", TC) {}
473 
hasIntegratedCPP()474   bool hasIntegratedCPP() const override { return false; }
475 
476   void ConstructJob(Compilation &C, const JobAction &JA,
477                     const InputInfo &Output, const InputInfoList &Inputs,
478                     const llvm::opt::ArgList &TCArgs,
479                     const char *LinkingOutput) const override;
480 };
481 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
482 
483 public:
Linker(const ToolChain & TC)484   Linker(const ToolChain &TC) : GnuTool("netbsd::Linker", "linker", TC) {}
485 
hasIntegratedCPP()486   bool hasIntegratedCPP() const override { return false; }
isLinkJob()487   bool isLinkJob() const override { return true; }
488 
489     void ConstructJob(Compilation &C, const JobAction &JA,
490                       const InputInfo &Output, const InputInfoList &Inputs,
491                       const llvm::opt::ArgList &TCArgs,
492                       const char *LinkingOutput) const override;
493   };
494 } // end namespace netbsd
495 
496 /// Directly call GNU Binutils' assembler and linker.
497 namespace gnutools {
498 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
499 public:
Assembler(const ToolChain & TC)500   Assembler(const ToolChain &TC) : GnuTool("GNU::Assembler", "assembler", TC) {}
501 
hasIntegratedCPP()502   bool hasIntegratedCPP() const override { return false; }
503 
504   void ConstructJob(Compilation &C, const JobAction &JA,
505                     const InputInfo &Output, const InputInfoList &Inputs,
506                     const llvm::opt::ArgList &TCArgs,
507                     const char *LinkingOutput) const override;
508 };
509 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
510 public:
Linker(const ToolChain & TC)511   Linker(const ToolChain &TC) : GnuTool("GNU::Linker", "linker", TC) {}
512 
hasIntegratedCPP()513   bool hasIntegratedCPP() const override { return false; }
isLinkJob()514   bool isLinkJob() const override { return true; }
515 
516     void ConstructJob(Compilation &C, const JobAction &JA,
517                       const InputInfo &Output,
518                       const InputInfoList &Inputs,
519                       const llvm::opt::ArgList &TCArgs,
520                       const char *LinkingOutput) const override;
521   };
522   }
523 
524   namespace nacltools {
525   class LLVM_LIBRARY_VISIBILITY AssemblerARM : public gnutools::Assembler {
526   public:
AssemblerARM(const ToolChain & TC)527     AssemblerARM(const ToolChain &TC) : gnutools::Assembler(TC) {}
528 
529     void ConstructJob(Compilation &C, const JobAction &JA,
530                       const InputInfo &Output, const InputInfoList &Inputs,
531                       const llvm::opt::ArgList &TCArgs,
532                       const char *LinkingOutput) const override;
533   };
534   class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
535   public:
Linker(const ToolChain & TC)536     Linker(const ToolChain &TC) : Tool("NaCl::Linker", "linker", TC) {}
537 
hasIntegratedCPP()538     bool hasIntegratedCPP() const override { return false; }
isLinkJob()539     bool isLinkJob() const override { return true; }
540 
541     void ConstructJob(Compilation &C, const JobAction &JA,
542                               const InputInfo &Output,
543                               const InputInfoList &Inputs,
544                               const llvm::opt::ArgList &TCArgs,
545                               const char *LinkingOutput) const override;
546   };
547 }
548 
549 /// minix -- Directly call GNU Binutils assembler and linker
550 namespace minix {
551 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
552 public:
Assembler(const ToolChain & TC)553   Assembler(const ToolChain &TC)
554       : GnuTool("minix::Assembler", "assembler", TC) {}
555 
hasIntegratedCPP()556   bool hasIntegratedCPP() const override { return false; }
557 
558   void ConstructJob(Compilation &C, const JobAction &JA,
559                     const InputInfo &Output, const InputInfoList &Inputs,
560                     const llvm::opt::ArgList &TCArgs,
561                     const char *LinkingOutput) const override;
562 };
563 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
564 public:
Linker(const ToolChain & TC)565   Linker(const ToolChain &TC) : GnuTool("minix::Linker", "linker", TC) {}
566 
hasIntegratedCPP()567   bool hasIntegratedCPP() const override { return false; }
isLinkJob()568   bool isLinkJob() const override { return true; }
569 
570     void ConstructJob(Compilation &C, const JobAction &JA,
571                       const InputInfo &Output,
572                       const InputInfoList &Inputs,
573                       const llvm::opt::ArgList &TCArgs,
574                       const char *LinkingOutput) const override;
575   };
576 } // end namespace minix
577 
578 /// solaris -- Directly call Solaris assembler and linker
579 namespace solaris {
580 class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
581 public:
Assembler(const ToolChain & TC)582   Assembler(const ToolChain &TC)
583       : Tool("solaris::Assembler", "assembler", TC) {}
584 
hasIntegratedCPP()585   bool hasIntegratedCPP() const override { return false; }
586 
587   void ConstructJob(Compilation &C, const JobAction &JA,
588                     const InputInfo &Output, const InputInfoList &Inputs,
589                     const llvm::opt::ArgList &TCArgs,
590                     const char *LinkingOutput) const override;
591 };
592 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
593 public:
Linker(const ToolChain & TC)594   Linker(const ToolChain &TC) : Tool("solaris::Linker", "linker", TC) {}
595 
hasIntegratedCPP()596   bool hasIntegratedCPP() const override { return false; }
isLinkJob()597   bool isLinkJob() const override { return true; }
598 
599     void ConstructJob(Compilation &C, const JobAction &JA,
600                       const InputInfo &Output, const InputInfoList &Inputs,
601                       const llvm::opt::ArgList &TCArgs,
602                       const char *LinkingOutput) const override;
603   };
604 } // end namespace solaris
605 
606 /// dragonfly -- Directly call GNU Binutils assembler and linker
607 namespace dragonfly {
608 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
609 public:
Assembler(const ToolChain & TC)610   Assembler(const ToolChain &TC)
611       : GnuTool("dragonfly::Assembler", "assembler", TC) {}
612 
hasIntegratedCPP()613   bool hasIntegratedCPP() const override { return false; }
614 
615   void ConstructJob(Compilation &C, const JobAction &JA,
616                     const InputInfo &Output, const InputInfoList &Inputs,
617                     const llvm::opt::ArgList &TCArgs,
618                     const char *LinkingOutput) const override;
619 };
620 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
621 public:
Linker(const ToolChain & TC)622   Linker(const ToolChain &TC) : GnuTool("dragonfly::Linker", "linker", TC) {}
623 
hasIntegratedCPP()624   bool hasIntegratedCPP() const override { return false; }
isLinkJob()625   bool isLinkJob() const override { return true; }
626 
627     void ConstructJob(Compilation &C, const JobAction &JA,
628                       const InputInfo &Output,
629                       const InputInfoList &Inputs,
630                       const llvm::opt::ArgList &TCArgs,
631                       const char *LinkingOutput) const override;
632   };
633 } // end namespace dragonfly
634 
635 /// Visual studio tools.
636 namespace visualstudio {
637 VersionTuple getMSVCVersion(const Driver *D, const llvm::Triple &Triple,
638                             const llvm::opt::ArgList &Args, bool IsWindowsMSVC);
639 
640 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
641 public:
Linker(const ToolChain & TC)642   Linker(const ToolChain &TC)
643       : Tool("visualstudio::Linker", "linker", TC, RF_Full,
644              llvm::sys::WEM_UTF16) {}
645 
hasIntegratedCPP()646   bool hasIntegratedCPP() const override { return false; }
isLinkJob()647     bool isLinkJob() const override { return true; }
648 
649     void ConstructJob(Compilation &C, const JobAction &JA,
650                       const InputInfo &Output, const InputInfoList &Inputs,
651                       const llvm::opt::ArgList &TCArgs,
652                       const char *LinkingOutput) const override;
653 };
654 
655 class LLVM_LIBRARY_VISIBILITY Compiler : public Tool {
656 public:
Compiler(const ToolChain & TC)657   Compiler(const ToolChain &TC)
658       : Tool("visualstudio::Compiler", "compiler", TC, RF_Full,
659              llvm::sys::WEM_UTF16) {}
660 
hasIntegratedAssembler()661   bool hasIntegratedAssembler() const override { return true; }
hasIntegratedCPP()662     bool hasIntegratedCPP() const override { return true; }
isLinkJob()663     bool isLinkJob() const override { return false; }
664 
665     void ConstructJob(Compilation &C, const JobAction &JA,
666                       const InputInfo &Output, const InputInfoList &Inputs,
667                       const llvm::opt::ArgList &TCArgs,
668                       const char *LinkingOutput) const override;
669 
670     std::unique_ptr<Command> GetCommand(Compilation &C, const JobAction &JA,
671                                         const InputInfo &Output,
672                                         const InputInfoList &Inputs,
673                                         const llvm::opt::ArgList &TCArgs,
674                                         const char *LinkingOutput) const;
675   };
676 } // end namespace visualstudio
677 
678 /// MinGW -- Directly call GNU Binutils assembler and linker
679 namespace MinGW {
680 class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
681 public:
Assembler(const ToolChain & TC)682   Assembler(const ToolChain &TC) : Tool("MinGW::Assemble", "assembler", TC) {}
683 
hasIntegratedCPP()684   bool hasIntegratedCPP() const override { return false; }
685 
686   void ConstructJob(Compilation &C, const JobAction &JA,
687                     const InputInfo &Output, const InputInfoList &Inputs,
688                     const llvm::opt::ArgList &TCArgs,
689                     const char *LinkingOutput) const override;
690 };
691 
692 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
693 public:
Linker(const ToolChain & TC)694   Linker(const ToolChain &TC) : Tool("MinGW::Linker", "linker", TC) {}
695 
hasIntegratedCPP()696   bool hasIntegratedCPP() const override { return false; }
isLinkJob()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 private:
705   void AddLibGCC(const llvm::opt::ArgList &Args, ArgStringList &CmdArgs) const;
706 };
707 } // end namespace MinGW
708 
709 namespace arm {
710   StringRef getARMFloatABI(const Driver &D, const llvm::opt::ArgList &Args,
711                          const llvm::Triple &Triple);
712 }
713 namespace XCore {
714 // For XCore, we do not need to instantiate tools for PreProcess, PreCompile and
715 // Compile.
716 // We simply use "clang -cc1" for those actions.
717 class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
718 public:
Assembler(const ToolChain & TC)719   Assembler(const ToolChain &TC) : Tool("XCore::Assembler", "XCore-as", TC) {}
720 
hasIntegratedCPP()721   bool hasIntegratedCPP() const override { return false; }
722   void ConstructJob(Compilation &C, const JobAction &JA,
723                     const InputInfo &Output, const InputInfoList &Inputs,
724                     const llvm::opt::ArgList &TCArgs,
725                     const char *LinkingOutput) const override;
726 };
727 
728 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
729 public:
Linker(const ToolChain & TC)730   Linker(const ToolChain &TC) : Tool("XCore::Linker", "XCore-ld", TC) {}
731 
hasIntegratedCPP()732   bool hasIntegratedCPP() const override { return false; }
isLinkJob()733     bool isLinkJob() const override { return true; }
734     void ConstructJob(Compilation &C, const JobAction &JA,
735                       const InputInfo &Output, const InputInfoList &Inputs,
736                       const llvm::opt::ArgList &TCArgs,
737                       const char *LinkingOutput) const override;
738   };
739   } // end namespace XCore.
740 
741   namespace CrossWindows {
742   class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
743   public:
Assembler(const ToolChain & TC)744     Assembler(const ToolChain &TC)
745         : Tool("CrossWindows::Assembler", "as", TC) {}
746 
hasIntegratedCPP()747     bool hasIntegratedCPP() const override { return false; }
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 
755   class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
756   public:
Linker(const ToolChain & TC)757     Linker(const ToolChain &TC)
758         : Tool("CrossWindows::Linker", "ld", TC, RF_Full) {}
759 
hasIntegratedCPP()760     bool hasIntegratedCPP() const override { return false; }
isLinkJob()761     bool isLinkJob() const override { return true; }
762 
763   void ConstructJob(Compilation &C, const JobAction &JA,
764                     const InputInfo &Output, const InputInfoList &Inputs,
765                     const llvm::opt::ArgList &TCArgs,
766                     const char *LinkingOutput) const override;
767 };
768 }
769 
770 /// SHAVE tools -- Directly call moviCompile and moviAsm
771 namespace SHAVE {
772 class LLVM_LIBRARY_VISIBILITY Compiler : public Tool {
773 public:
Compiler(const ToolChain & TC)774   Compiler(const ToolChain &TC) : Tool("moviCompile", "movicompile", TC) {}
775 
hasIntegratedCPP()776   bool hasIntegratedCPP() const override { return true; }
777 
778   void ConstructJob(Compilation &C, const JobAction &JA,
779                     const InputInfo &Output, const InputInfoList &Inputs,
780                     const llvm::opt::ArgList &TCArgs,
781                     const char *LinkingOutput) const override;
782 };
783 
784 class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
785 public:
Assembler(const ToolChain & TC)786   Assembler(const ToolChain &TC) : Tool("moviAsm", "moviAsm", TC) {}
787 
hasIntegratedCPP()788   bool hasIntegratedCPP() const override { return false; } // not sure.
789 
790   void ConstructJob(Compilation &C, const JobAction &JA,
791                     const InputInfo &Output, const InputInfoList &Inputs,
792                     const llvm::opt::ArgList &TCArgs,
793                     const char *LinkingOutput) const override;
794 };
795 } // end namespace SHAVE
796 
797 } // end namespace tools
798 } // end namespace driver
799 } // end namespace clang
800 
801 #endif
802