clang  14.0.0git
Hexagon.h
Go to the documentation of this file.
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 
9 #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HEXAGON_H
10 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HEXAGON_H
11 
12 #include "Linux.h"
13 #include "clang/Driver/Tool.h"
14 #include "clang/Driver/ToolChain.h"
15 
16 namespace clang {
17 namespace driver {
18 namespace tools {
19 namespace hexagon {
20 // For Hexagon, we do not need to instantiate tools for PreProcess, PreCompile
21 // and Compile.
22 // We simply use "clang -cc1" for those actions.
23 class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
24 public:
25  Assembler(const ToolChain &TC)
26  : Tool("hexagon::Assembler", "hexagon-as", TC) {}
27 
28  bool hasIntegratedCPP() const override { return false; }
29 
30  void RenderExtraToolArgs(const JobAction &JA,
31  llvm::opt::ArgStringList &CmdArgs) const;
32  void ConstructJob(Compilation &C, const JobAction &JA,
33  const InputInfo &Output, const InputInfoList &Inputs,
34  const llvm::opt::ArgList &TCArgs,
35  const char *LinkingOutput) const override;
36 };
37 
38 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
39 public:
40  Linker(const ToolChain &TC) : Tool("hexagon::Linker", "hexagon-ld", TC) {}
41 
42  bool hasIntegratedCPP() const override { return false; }
43  bool isLinkJob() const override { return true; }
44 
45  virtual void RenderExtraToolArgs(const JobAction &JA,
46  llvm::opt::ArgStringList &CmdArgs) const;
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 
53 void getHexagonTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args,
54  std::vector<StringRef> &Features);
55 
56 } // end namespace hexagon.
57 } // end namespace tools
58 
59 namespace toolchains {
60 
61 class LLVM_LIBRARY_VISIBILITY HexagonToolChain : public Linux {
62 protected:
63  GCCVersion GCCLibAndIncVersion;
64  Tool *buildAssembler() const override;
65  Tool *buildLinker() const override;
66 
67  unsigned getOptimizationLevel(const llvm::opt::ArgList &DriverArgs) const;
68 
69 public:
70  HexagonToolChain(const Driver &D, const llvm::Triple &Triple,
71  const llvm::opt::ArgList &Args);
72  ~HexagonToolChain() override;
73 
74  void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
75  llvm::opt::ArgStringList &CC1Args,
76  Action::OffloadKind DeviceOffloadKind) const override;
77  void
78  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
79  llvm::opt::ArgStringList &CC1Args) const override;
80  void addLibStdCxxIncludePaths(
81  const llvm::opt::ArgList &DriverArgs,
82  llvm::opt::ArgStringList &CC1Args) const override;
83 
84  void addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
85  llvm::opt::ArgStringList &CC1Args) const override;
86 
87  const char *getDefaultLinker() const override {
88  return getTriple().isMusl() ? "ld.lld" : "hexagon-link";
89  }
90 
91  CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
92 
93  void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
94  llvm::opt::ArgStringList &CmdArgs) const override;
95 
96  StringRef GetGCCLibAndIncVersion() const { return GCCLibAndIncVersion.Text; }
97  bool IsIntegratedAssemblerDefault() const override {
98  return true;
99  }
100 
101  std::string getHexagonTargetDir(
102  const std::string &InstalledDir,
103  const SmallVectorImpl<std::string> &PrefixDirs) const;
104  void getHexagonLibraryPaths(const llvm::opt::ArgList &Args,
105  ToolChain::path_list &LibPaths) const;
106 
107  std::string getCompilerRTPath() const override;
108 
109  static bool isAutoHVXEnabled(const llvm::opt::ArgList &Args);
110  static StringRef GetDefaultCPU();
111  static StringRef GetTargetCPUVersion(const llvm::opt::ArgList &Args);
112 
113  static Optional<unsigned> getSmallDataThreshold(
114  const llvm::opt::ArgList &Args);
115 };
116 
117 } // end namespace toolchains
118 } // end namespace driver
119 } // end namespace clang
120 
121 #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HEXAGON_H
clang::driver::tools::hexagon::Assembler::Assembler
Assembler(const ToolChain &TC)
Definition: Hexagon.h:25
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::driver::toolchains::HexagonToolChain::getDefaultLinker
const char * getDefaultLinker() const override
GetDefaultLinker - Get the default linker to use.
Definition: Hexagon.h:87
llvm::SmallVector
Definition: LLVM.h:38
clang::driver::toolchains::HexagonToolChain::GCCLibAndIncVersion
GCCVersion GCCLibAndIncVersion
Definition: Hexagon.h:63
llvm::Optional< unsigned >
clang::driver::toolchains::HexagonToolChain
Definition: Hexagon.h:61
clang::driver::InputInfo
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:22
clang::driver::tools::hexagon::getHexagonTargetFeatures
void getHexagonTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args, std::vector< StringRef > &Features)
clang::driver::toolchains::HexagonToolChain::IsIntegratedAssemblerDefault
bool IsIntegratedAssemblerDefault() const override
IsIntegratedAssemblerDefault - Does this tool chain enable -integrated-as by default.
Definition: Hexagon.h:97
clang::driver::Tool
Tool - Information on a specific compilation tool.
Definition: Tool.h:32
clang::driver::tools::hexagon::Linker::isLinkJob
bool isLinkJob() const override
Definition: Hexagon.h:43
clang::driver::tools::hexagon::Linker::hasIntegratedCPP
bool hasIntegratedCPP() const override
Definition: Hexagon.h:42
clang::driver::tools::hexagon::Assembler
Definition: Hexagon.h:23
clang::driver::tools::hexagon::Linker::Linker
Linker(const ToolChain &TC)
Definition: Hexagon.h:40
Tool.h
clang::driver::toolchains::Linux
Definition: Linux.h:19
clang::driver::tools::hexagon::Assembler::hasIntegratedCPP
bool hasIntegratedCPP() const override
Definition: Hexagon.h:28
Linux.h
ToolChain.h
clang::driver::ToolChain
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:91
clang::driver::Compilation
Compilation - A set of tasks to perform for a single driver invocation.
Definition: Compilation.h:45
clang
Definition: CalledOnceCheck.h:17
clang::driver::Driver
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:59
clang::driver::toolchains::HexagonToolChain::GetGCCLibAndIncVersion
StringRef GetGCCLibAndIncVersion() const
Definition: Hexagon.h:96
getOptimizationLevel
static unsigned getOptimizationLevel(ArgList &Args, InputKind IK, DiagnosticsEngine &Diags)
Definition: CompilerInvocation.cpp:541
clang::driver::tools::hexagon::Linker
Definition: Hexagon.h:38
clang::driver::Action::OffloadKind
OffloadKind
Definition: Action.h:85
llvm::SmallVectorImpl
Definition: LLVM.h:39
clang::driver::JobAction
Definition: Action.h:380