1 //===--- Hexagon.h - Hexagon ToolChain Implementations ----------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HEXAGON_H
10 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HEXAGON_H
13 #include "clang/Driver/Tool.h"
14 #include "clang/Driver/ToolChain.h"
20 // For Hexagon, we do not need to instantiate tools for PreProcess, PreCompile
22 // We simply use "clang -cc1" for those actions.
23 class LLVM_LIBRARY_VISIBILITY Assembler
: public Tool
{
25 Assembler(const ToolChain
&TC
)
26 : Tool("hexagon::Assembler", "hexagon-as", TC
) {}
28 bool hasIntegratedCPP() const override
{ return false; }
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
;
38 class LLVM_LIBRARY_VISIBILITY Linker
: public Tool
{
40 Linker(const ToolChain
&TC
) : Tool("hexagon::Linker", "hexagon-ld", TC
) {}
42 bool hasIntegratedCPP() const override
{ return false; }
43 bool isLinkJob() const override
{ return true; }
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
;
53 void getHexagonTargetFeatures(const Driver
&D
, const llvm::opt::ArgList
&Args
,
54 std::vector
<StringRef
> &Features
);
56 } // end namespace hexagon.
57 } // end namespace tools
59 namespace toolchains
{
61 class LLVM_LIBRARY_VISIBILITY HexagonToolChain
: public Linux
{
63 GCCVersion GCCLibAndIncVersion
;
64 Tool
*buildAssembler() const override
;
65 Tool
*buildLinker() const override
;
67 unsigned getOptimizationLevel(const llvm::opt::ArgList
&DriverArgs
) const;
70 HexagonToolChain(const Driver
&D
, const llvm::Triple
&Triple
,
71 const llvm::opt::ArgList
&Args
);
72 ~HexagonToolChain() override
;
74 void addClangTargetOptions(const llvm::opt::ArgList
&DriverArgs
,
75 llvm::opt::ArgStringList
&CC1Args
,
76 Action::OffloadKind DeviceOffloadKind
) const override
;
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
;
84 void addLibCxxIncludePaths(const llvm::opt::ArgList
&DriverArgs
,
85 llvm::opt::ArgStringList
&CC1Args
) const override
;
87 const char *getDefaultLinker() const override
{
88 return getTriple().isMusl() ? "ld.lld" : "hexagon-link";
91 CXXStdlibType
GetCXXStdlibType(const llvm::opt::ArgList
&Args
) const override
;
93 void AddCXXStdlibLibArgs(const llvm::opt::ArgList
&Args
,
94 llvm::opt::ArgStringList
&CmdArgs
) const override
;
96 StringRef
GetGCCLibAndIncVersion() const { return GCCLibAndIncVersion
.Text
; }
98 std::string
getHexagonTargetDir(
99 const std::string
&InstalledDir
,
100 const SmallVectorImpl
<std::string
> &PrefixDirs
) const;
101 void getHexagonLibraryPaths(const llvm::opt::ArgList
&Args
,
102 ToolChain::path_list
&LibPaths
) const;
104 std::string
getCompilerRTPath() const override
;
106 static bool isAutoHVXEnabled(const llvm::opt::ArgList
&Args
);
107 static StringRef
GetDefaultCPU();
108 static StringRef
GetTargetCPUVersion(const llvm::opt::ArgList
&Args
);
110 static Optional
<unsigned> getSmallDataThreshold(
111 const llvm::opt::ArgList
&Args
);
114 } // end namespace toolchains
115 } // end namespace driver
116 } // end namespace clang
118 #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HEXAGON_H