clang 23.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
16#include <optional>
17#include <string>
18
19namespace clang {
20namespace driver {
21namespace tools {
22namespace hexagon {
23// For Hexagon, we do not need to instantiate tools for PreProcess, PreCompile
24// and Compile.
25// We simply use "clang -cc1" for those actions.
26class LLVM_LIBRARY_VISIBILITY Assembler final : public Tool {
27public:
29 : Tool("hexagon::Assembler", "hexagon-as", TC) {}
30
31 bool hasIntegratedCPP() const override { return false; }
32
33 void RenderExtraToolArgs(const JobAction &JA,
34 llvm::opt::ArgStringList &CmdArgs) const;
35 void ConstructJob(Compilation &C, const JobAction &JA,
36 const InputInfo &Output, const InputInfoList &Inputs,
37 const llvm::opt::ArgList &TCArgs,
38 const char *LinkingOutput) const override;
39};
40
41class LLVM_LIBRARY_VISIBILITY Linker final : public Tool {
42public:
43 Linker(const ToolChain &TC) : Tool("hexagon::Linker", "hexagon-ld", TC) {}
44
45 bool hasIntegratedCPP() const override { return false; }
46 bool isLinkJob() const override { return true; }
47
48 void RenderExtraToolArgs(const JobAction &JA,
49 llvm::opt::ArgStringList &CmdArgs) const;
50 void ConstructJob(Compilation &C, const JobAction &JA,
51 const InputInfo &Output, const InputInfoList &Inputs,
52 const llvm::opt::ArgList &TCArgs,
53 const char *LinkingOutput) const override;
54};
55
56void getHexagonTargetFeatures(const Driver &D, const llvm::Triple &Triple,
57 const llvm::opt::ArgList &Args,
58 std::vector<StringRef> &Features);
59
60} // end namespace hexagon.
61} // end namespace tools
62
63namespace toolchains {
64
65class LLVM_LIBRARY_VISIBILITY HexagonToolChain : public Linux {
66protected:
68 Tool *buildAssembler() const override;
69 Tool *buildLinker() const override;
70
71 unsigned getOptimizationLevel(const llvm::opt::ArgList &DriverArgs) const;
72
73public:
74 HexagonToolChain(const Driver &D, const llvm::Triple &Triple,
75 const llvm::opt::ArgList &Args);
76 ~HexagonToolChain() override;
77
78 void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
79 llvm::opt::ArgStringList &CC1Args,
80 Action::OffloadKind DeviceOffloadKind) const override;
81 void
82 AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
83 llvm::opt::ArgStringList &CC1Args) const override;
85 const llvm::opt::ArgList &DriverArgs,
86 llvm::opt::ArgStringList &CC1Args) const override;
87
88 void addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
89 llvm::opt::ArgStringList &CC1Args) const override;
90
91 const char *getDefaultLinker() const override {
92 return getTriple().isMusl() ? "ld.lld" : "hexagon-link";
93 }
94
95 RuntimeLibType
96 GetRuntimeLibType(const llvm::opt::ArgList &Args) const override;
97
98 UnwindLibType GetUnwindLibType(const llvm::opt::ArgList &Args) const override;
99
100 CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
101
102 void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
103 llvm::opt::ArgStringList &CmdArgs) const override;
104
105 StringRef GetGCCLibAndIncVersion() const { return GCCLibAndIncVersion.Text; }
106
107 std::string getHexagonTargetDir(
108 const std::string &InstalledDir,
109 const SmallVectorImpl<std::string> &PrefixDirs) const;
110 SmallString<128> getEffectiveSysRoot(const llvm::opt::ArgList &Args) const;
111 void getBaseIncludeDir(const llvm::opt::ArgList &Args,
112 llvm::SmallString<128> &) const;
113 void getLibraryDir(const llvm::opt::ArgList &Args,
114 llvm::SmallString<128> &) const;
115 void getHexagonLibraryPaths(const llvm::opt::ArgList &Args,
116 ToolChain::path_list &LibPaths) const;
117
118 std::string getCompilerRTPath() const override;
119
120 static bool isAutoHVXEnabled(const llvm::opt::ArgList &Args);
121 static StringRef GetDefaultCPU();
122 static StringRef GetTargetCPUVersion(const llvm::opt::ArgList &Args);
123
124 static std::optional<unsigned>
125 getSmallDataThreshold(const llvm::opt::ArgList &Args);
126 static std::optional<std::string>
127 GetHVXVersion(const llvm::opt::ArgList &Args);
128};
129
130} // end namespace toolchains
131} // end namespace driver
132} // end namespace clang
133
134#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HEXAGON_H
static StringRef getTriple(const Command &Job)
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:99
InputInfo - Wrapper for information about an input source.
Definition InputInfo.h:22
ToolChain - Access to tools for a single platform.
Definition ToolChain.h:92
SmallVector< std::string, 16 > path_list
Definition ToolChain.h:94
Tool - Information on a specific compilation tool.
Definition Tool.h:32
Tool(const char *Name, const char *ShortName, const ToolChain &TC)
Definition Tool.cpp:14
void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, Action::OffloadKind DeviceOffloadKind) const override
Add options that need to be passed to cc1 for this target.
Definition Hexagon.cpp:770
const char * getDefaultLinker() const override
GetDefaultLinker - Get the default linker to use.
Definition Hexagon.h:91
void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Add the clang cc1 arguments for system include paths.
Definition Hexagon.cpp:791
unsigned getOptimizationLevel(const llvm::opt::ArgList &DriverArgs) const
Definition Hexagon.cpp:745
void addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Definition Hexagon.cpp:827
HexagonToolChain(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args)
Definition Hexagon.cpp:666
void addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Definition Hexagon.cpp:818
Linux(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args)
Definition Linux.cpp:225
bool hasIntegratedCPP() const override
Definition Hexagon.h:31
bool hasIntegratedCPP() const override
Definition Hexagon.h:45
Linker(const ToolChain &TC)
Definition Hexagon.h:43
bool isLinkJob() const override
Definition Hexagon.h:46
void getHexagonTargetFeatures(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args, std::vector< StringRef > &Features)
SmallVector< InputInfo, 4 > InputInfoList
Definition Driver.h:50
The JSON file list parser is used to communicate input to InstallAPI.
Struct to store and manipulate GCC versions.
Definition Gnu.h:163