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