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