Myriad.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //===--- Myriad.h - Myriad 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_MYRIAD_H
  9. #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MYRIAD_H
  10. #include "Gnu.h"
  11. #include "clang/Driver/Tool.h"
  12. #include "clang/Driver/ToolChain.h"
  13. namespace clang {
  14. namespace driver {
  15. namespace tools {
  16. /// SHAVE tools -- Directly call moviCompile and moviAsm
  17. namespace SHAVE {
  18. class LLVM_LIBRARY_VISIBILITY Compiler : public Tool {
  19. public:
  20. Compiler(const ToolChain &TC) : Tool("moviCompile", "movicompile", TC) {}
  21. bool hasIntegratedCPP() const override { return true; }
  22. void ConstructJob(Compilation &C, const JobAction &JA,
  23. const InputInfo &Output, const InputInfoList &Inputs,
  24. const llvm::opt::ArgList &TCArgs,
  25. const char *LinkingOutput) const override;
  26. };
  27. class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
  28. public:
  29. Assembler(const ToolChain &TC) : Tool("moviAsm", "moviAsm", TC) {}
  30. bool hasIntegratedCPP() const override { return false; } // not sure.
  31. void ConstructJob(Compilation &C, const JobAction &JA,
  32. const InputInfo &Output, const InputInfoList &Inputs,
  33. const llvm::opt::ArgList &TCArgs,
  34. const char *LinkingOutput) const override;
  35. };
  36. } // end namespace SHAVE
  37. /// The Myriad toolchain uses tools that are in two different namespaces.
  38. /// The Compiler and Assembler as defined above are in the SHAVE namespace,
  39. /// whereas the linker, which accepts code for a mixture of Sparc and SHAVE,
  40. /// is in the Myriad namespace.
  41. namespace Myriad {
  42. class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
  43. public:
  44. Linker(const ToolChain &TC) : Tool("shave::Linker", "ld", TC) {}
  45. bool hasIntegratedCPP() const override { return false; }
  46. bool isLinkJob() const override { return true; }
  47. void ConstructJob(Compilation &C, const JobAction &JA,
  48. const InputInfo &Output, const InputInfoList &Inputs,
  49. const llvm::opt::ArgList &TCArgs,
  50. const char *LinkingOutput) const override;
  51. };
  52. } // end namespace Myriad
  53. } // end namespace tools
  54. namespace toolchains {
  55. /// MyriadToolChain - A tool chain using either clang or the external compiler
  56. /// installed by the Movidius SDK to perform all subcommands.
  57. class LLVM_LIBRARY_VISIBILITY MyriadToolChain : public Generic_ELF {
  58. public:
  59. MyriadToolChain(const Driver &D, const llvm::Triple &Triple,
  60. const llvm::opt::ArgList &Args);
  61. ~MyriadToolChain() override;
  62. void
  63. AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
  64. llvm::opt::ArgStringList &CC1Args) const override;
  65. void addLibCxxIncludePaths(
  66. const llvm::opt::ArgList &DriverArgs,
  67. llvm::opt::ArgStringList &CC1Args) const override;
  68. void addLibStdCxxIncludePaths(
  69. const llvm::opt::ArgList &DriverArgs,
  70. llvm::opt::ArgStringList &CC1Args) const override;
  71. Tool *SelectTool(const JobAction &JA) const override;
  72. unsigned GetDefaultDwarfVersion() const override { return 2; }
  73. SanitizerMask getSupportedSanitizers() const override;
  74. protected:
  75. Tool *buildLinker() const override;
  76. bool isShaveCompilation(const llvm::Triple &T) const {
  77. return T.getArch() == llvm::Triple::shave;
  78. }
  79. private:
  80. mutable std::unique_ptr<Tool> Compiler;
  81. mutable std::unique_ptr<Tool> Assembler;
  82. };
  83. } // end namespace toolchains
  84. } // end namespace driver
  85. } // end namespace clang
  86. #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MYRIAD_H