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