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