Tools.h 31 KB

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