Hexagon.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. //===--- Hexagon.h - Hexagon ToolChain Implementations ----------*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HEXAGON_H
  9. #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HEXAGON_H
  10. #include "Linux.h"
  11. #include "clang/Driver/Tool.h"
  12. #include "clang/Driver/ToolChain.h"
  13. namespace clang {
  14. namespace driver {
  15. namespace tools {
  16. namespace hexagon {
  17. // For Hexagon, we do not need to instantiate tools for PreProcess, PreCompile
  18. // and Compile.
  19. // We simply use "clang -cc1" for those actions.
  20. class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
  21. public:
  22. Assembler(const ToolChain &TC)
  23. : Tool("hexagon::Assembler", "hexagon-as", TC) {}
  24. bool hasIntegratedCPP() const override { return false; }
  25. void RenderExtraToolArgs(const JobAction &JA,
  26. llvm::opt::ArgStringList &CmdArgs) const;
  27. void ConstructJob(Compilation &C, const JobAction &JA,
  28. const InputInfo &Output, const InputInfoList &Inputs,
  29. const llvm::opt::ArgList &TCArgs,
  30. const char *LinkingOutput) const override;
  31. };
  32. class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
  33. public:
  34. Linker(const ToolChain &TC) : Tool("hexagon::Linker", "hexagon-ld", TC) {}
  35. bool hasIntegratedCPP() const override { return false; }
  36. bool isLinkJob() const override { return true; }
  37. virtual void RenderExtraToolArgs(const JobAction &JA,
  38. llvm::opt::ArgStringList &CmdArgs) const;
  39. void ConstructJob(Compilation &C, const JobAction &JA,
  40. const InputInfo &Output, const InputInfoList &Inputs,
  41. const llvm::opt::ArgList &TCArgs,
  42. const char *LinkingOutput) const override;
  43. };
  44. void getHexagonTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args,
  45. std::vector<StringRef> &Features);
  46. } // end namespace hexagon.
  47. } // end namespace tools
  48. namespace toolchains {
  49. class LLVM_LIBRARY_VISIBILITY HexagonToolChain : public Linux {
  50. protected:
  51. GCCVersion GCCLibAndIncVersion;
  52. Tool *buildAssembler() const override;
  53. Tool *buildLinker() const override;
  54. unsigned getOptimizationLevel(const llvm::opt::ArgList &DriverArgs) const;
  55. public:
  56. HexagonToolChain(const Driver &D, const llvm::Triple &Triple,
  57. const llvm::opt::ArgList &Args);
  58. ~HexagonToolChain() override;
  59. void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
  60. llvm::opt::ArgStringList &CC1Args,
  61. Action::OffloadKind DeviceOffloadKind) const override;
  62. void
  63. AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
  64. llvm::opt::ArgStringList &CC1Args) const override;
  65. void addLibStdCxxIncludePaths(
  66. const llvm::opt::ArgList &DriverArgs,
  67. llvm::opt::ArgStringList &CC1Args) const override;
  68. void addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
  69. llvm::opt::ArgStringList &CC1Args) const override;
  70. const char *getDefaultLinker() const override {
  71. return getTriple().isMusl() ? "ld.lld" : "hexagon-link";
  72. }
  73. CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
  74. void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
  75. llvm::opt::ArgStringList &CmdArgs) const override;
  76. StringRef GetGCCLibAndIncVersion() const { return GCCLibAndIncVersion.Text; }
  77. bool IsIntegratedAssemblerDefault() const override {
  78. return true;
  79. }
  80. std::string getHexagonTargetDir(
  81. const std::string &InstalledDir,
  82. const SmallVectorImpl<std::string> &PrefixDirs) const;
  83. void getHexagonLibraryPaths(const llvm::opt::ArgList &Args,
  84. ToolChain::path_list &LibPaths) const;
  85. std::string getCompilerRTPath() const override;
  86. static bool isAutoHVXEnabled(const llvm::opt::ArgList &Args);
  87. static StringRef GetDefaultCPU();
  88. static StringRef GetTargetCPUVersion(const llvm::opt::ArgList &Args);
  89. static Optional<unsigned> getSmallDataThreshold(
  90. const llvm::opt::ArgList &Args);
  91. };
  92. } // end namespace toolchains
  93. } // end namespace driver
  94. } // end namespace clang
  95. #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HEXAGON_H