1 //===--- Hexagon.h - Hexagon 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_HEXAGON_H
11 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HEXAGON_H
12 
13 #include "Linux.h"
14 #include "clang/Driver/Tool.h"
15 #include "clang/Driver/ToolChain.h"
16 
17 namespace clang {
18 namespace driver {
19 namespace tools {
20 namespace hexagon {
21 // For Hexagon, we do not need to instantiate tools for PreProcess, PreCompile
22 // and Compile.
23 // We simply use "clang -cc1" for those actions.
24 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
25 public:
Assembler(const ToolChain & TC)26   Assembler(const ToolChain &TC)
27       : GnuTool("hexagon::Assembler", "hexagon-as", TC) {}
28 
hasIntegratedCPP()29   bool hasIntegratedCPP() const override { return false; }
30 
31   void RenderExtraToolArgs(const JobAction &JA,
32                            llvm::opt::ArgStringList &CmdArgs) const;
33   void ConstructJob(Compilation &C, const JobAction &JA,
34                     const InputInfo &Output, const InputInfoList &Inputs,
35                     const llvm::opt::ArgList &TCArgs,
36                     const char *LinkingOutput) const override;
37 };
38 
39 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
40 public:
Linker(const ToolChain & TC)41   Linker(const ToolChain &TC) : GnuTool("hexagon::Linker", "hexagon-ld", TC) {}
42 
hasIntegratedCPP()43   bool hasIntegratedCPP() const override { return false; }
isLinkJob()44   bool isLinkJob() const override { return true; }
45 
46   virtual void RenderExtraToolArgs(const JobAction &JA,
47                                    llvm::opt::ArgStringList &CmdArgs) const;
48   void ConstructJob(Compilation &C, const JobAction &JA,
49                     const InputInfo &Output, const InputInfoList &Inputs,
50                     const llvm::opt::ArgList &TCArgs,
51                     const char *LinkingOutput) const override;
52 };
53 
54 void getHexagonTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args,
55                               std::vector<StringRef> &Features);
56 
57 } // end namespace hexagon.
58 } // end namespace tools
59 
60 namespace toolchains {
61 
62 class LLVM_LIBRARY_VISIBILITY HexagonToolChain : public Linux {
63 protected:
64   GCCVersion GCCLibAndIncVersion;
65   Tool *buildAssembler() const override;
66   Tool *buildLinker() const override;
67 
68   unsigned getOptimizationLevel(const llvm::opt::ArgList &DriverArgs) const;
69 
70 public:
71   HexagonToolChain(const Driver &D, const llvm::Triple &Triple,
72                    const llvm::opt::ArgList &Args);
73   ~HexagonToolChain() override;
74 
75   void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
76                              llvm::opt::ArgStringList &CC1Args,
77                              Action::OffloadKind DeviceOffloadKind) const override;
78   void
79   AddClangSystemIncludeArgs(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   CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
85 
GetGCCLibAndIncVersion()86   StringRef GetGCCLibAndIncVersion() const { return GCCLibAndIncVersion.Text; }
IsIntegratedAssemblerDefault()87   bool IsIntegratedAssemblerDefault() const override {
88     return true;
89   }
90 
91   std::string getHexagonTargetDir(
92       const std::string &InstalledDir,
93       const SmallVectorImpl<std::string> &PrefixDirs) const;
94   void getHexagonLibraryPaths(const llvm::opt::ArgList &Args,
95       ToolChain::path_list &LibPaths) const;
96 
97   static bool isAutoHVXEnabled(const llvm::opt::ArgList &Args);
98   static const StringRef GetDefaultCPU();
99   static const StringRef GetTargetCPUVersion(const llvm::opt::ArgList &Args);
100 
101   static Optional<unsigned> getSmallDataThreshold(
102       const llvm::opt::ArgList &Args);
103 };
104 
105 } // end namespace toolchains
106 } // end namespace driver
107 } // end namespace clang
108 
109 #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HEXAGON_H
110