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