clang 20.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"
15
16namespace clang {
17namespace driver {
18namespace tools {
19namespace 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.
23class LLVM_LIBRARY_VISIBILITY Assembler final : public Tool {
24public:
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
38class LLVM_LIBRARY_VISIBILITY Linker final : public Tool {
39public:
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
53void getHexagonTargetFeatures(const Driver &D, const llvm::Triple &Triple,
54 const llvm::opt::ArgList &Args,
55 std::vector<StringRef> &Features);
56
57} // end namespace hexagon.
58} // end namespace tools
59
60namespace toolchains {
61
62class LLVM_LIBRARY_VISIBILITY HexagonToolChain : public Linux {
63protected:
65 Tool *buildAssembler() const override;
66 Tool *buildLinker() const override;
67
68 unsigned getOptimizationLevel(const llvm::opt::ArgList &DriverArgs) const;
69
70public:
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
85 void addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
86 llvm::opt::ArgStringList &CC1Args) const override;
87
88 const char *getDefaultLinker() const override {
89 return getTriple().isMusl() ? "ld.lld" : "hexagon-link";
90 }
91
92 CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
93
94 void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
95 llvm::opt::ArgStringList &CmdArgs) const override;
96
97 StringRef GetGCCLibAndIncVersion() const { return GCCLibAndIncVersion.Text; }
98
99 std::string getHexagonTargetDir(
100 const std::string &InstalledDir,
101 const SmallVectorImpl<std::string> &PrefixDirs) const;
102 void getHexagonLibraryPaths(const llvm::opt::ArgList &Args,
103 ToolChain::path_list &LibPaths) const;
104
105 std::string getCompilerRTPath() const override;
106
107 static bool isAutoHVXEnabled(const llvm::opt::ArgList &Args);
108 static StringRef GetDefaultCPU();
109 static StringRef GetTargetCPUVersion(const llvm::opt::ArgList &Args);
110
111 static std::optional<unsigned>
112 getSmallDataThreshold(const llvm::opt::ArgList &Args);
113};
114
115} // end namespace toolchains
116} // end namespace driver
117} // end namespace clang
118
119#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HEXAGON_H
const Decl * D
static unsigned getOptimizationLevel(ArgList &Args, InputKind IK, DiagnosticsEngine &Diags)
Compilation - A set of tasks to perform for a single driver invocation.
Definition: Compilation.h:45
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:77
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:22
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:92
Tool - Information on a specific compilation tool.
Definition: Tool.h:32
const char * getDefaultLinker() const override
GetDefaultLinker - Get the default linker to use.
Definition: Hexagon.h:88
bool hasIntegratedCPP() const override
Definition: Hexagon.h:28
Assembler(const ToolChain &TC)
Definition: Hexagon.h:25
bool hasIntegratedCPP() const override
Definition: Hexagon.h:42
Linker(const ToolChain &TC)
Definition: Hexagon.h:40
bool isLinkJob() const override
Definition: Hexagon.h:43
void getHexagonTargetFeatures(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args, std::vector< StringRef > &Features)
The JSON file list parser is used to communicate input to InstallAPI.
Struct to store and manipulate GCC versions.
Definition: Gnu.h:162
std::string Text
The unparsed text of the version.
Definition: Gnu.h:164