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 CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
96
97 void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
98 llvm::opt::ArgStringList &CmdArgs) const override;
99
100 StringRef GetGCCLibAndIncVersion() const { return GCCLibAndIncVersion.Text; }
101
102 std::string getHexagonTargetDir(
103 const std::string &InstalledDir,
104 const SmallVectorImpl<std::string> &PrefixDirs) const;
105 void getHexagonLibraryPaths(const llvm::opt::ArgList &Args,
106 ToolChain::path_list &LibPaths) const;
107
108 std::string getCompilerRTPath() const override;
109
110 static bool isAutoHVXEnabled(const llvm::opt::ArgList &Args);
111 static StringRef GetDefaultCPU();
112 static StringRef GetTargetCPUVersion(const llvm::opt::ArgList &Args);
113
114 static std::optional<unsigned>
115 getSmallDataThreshold(const llvm::opt::ArgList &Args);
116 static std::optional<std::string>
117 GetHVXVersion(const llvm::opt::ArgList &Args);
118};
119
120} // end namespace toolchains
121} // end namespace driver
122} // end namespace clang
123
124#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HEXAGON_H
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
const llvm::Triple & getTriple() const
Definition ToolChain.h:263
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:669
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:690
unsigned getOptimizationLevel(const llvm::opt::ArgList &DriverArgs) const
Definition Hexagon.cpp:644
void addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Definition Hexagon.cpp:749
HexagonToolChain(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args)
Definition Hexagon.cpp:585
void addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Definition Hexagon.cpp:733
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