1 //===--- HIPAMD.h - HIP 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_HIPAMD_H
10 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPAMD_H
13 #include "clang/Driver/Tool.h"
14 #include "clang/Driver/ToolChain.h"
22 // Runs llvm-link/opt/llc/lld, which links multiple LLVM bitcode, together with
23 // device library, then compiles it to ISA in a shared object.
24 class LLVM_LIBRARY_VISIBILITY Linker final
: public Tool
{
26 Linker(const ToolChain
&TC
) : Tool("AMDGCN::Linker", "amdgcn-link", TC
) {}
28 bool hasIntegratedCPP() const override
{ return false; }
30 void ConstructJob(Compilation
&C
, const JobAction
&JA
,
31 const InputInfo
&Output
, const InputInfoList
&Inputs
,
32 const llvm::opt::ArgList
&TCArgs
,
33 const char *LinkingOutput
) const override
;
36 void constructLldCommand(Compilation
&C
, const JobAction
&JA
,
37 const InputInfoList
&Inputs
, const InputInfo
&Output
,
38 const llvm::opt::ArgList
&Args
) const;
39 void constructLlvmLinkCommand(Compilation
&C
, const JobAction
&JA
,
40 const InputInfoList
&Inputs
,
41 const InputInfo
&Output
,
42 const llvm::opt::ArgList
&Args
) const;
45 } // end namespace AMDGCN
46 } // end namespace tools
48 namespace toolchains
{
50 class LLVM_LIBRARY_VISIBILITY HIPAMDToolChain final
: public ROCMToolChain
{
52 HIPAMDToolChain(const Driver
&D
, const llvm::Triple
&Triple
,
53 const ToolChain
&HostTC
, const llvm::opt::ArgList
&Args
);
55 const llvm::Triple
*getAuxTriple() const override
{
56 return &HostTC
.getTriple();
59 llvm::opt::DerivedArgList
*
60 TranslateArgs(const llvm::opt::DerivedArgList
&Args
, StringRef BoundArch
,
61 Action::OffloadKind DeviceOffloadKind
) const override
;
63 addClangTargetOptions(const llvm::opt::ArgList
&DriverArgs
,
64 llvm::opt::ArgStringList
&CC1Args
,
65 Action::OffloadKind DeviceOffloadKind
) const override
;
66 void addClangWarningOptions(llvm::opt::ArgStringList
&CC1Args
) const override
;
67 CXXStdlibType
GetCXXStdlibType(const llvm::opt::ArgList
&Args
) const override
;
69 AddClangSystemIncludeArgs(const llvm::opt::ArgList
&DriverArgs
,
70 llvm::opt::ArgStringList
&CC1Args
) const override
;
71 void AddClangCXXStdlibIncludeArgs(
72 const llvm::opt::ArgList
&Args
,
73 llvm::opt::ArgStringList
&CC1Args
) const override
;
74 void AddIAMCUIncludeArgs(const llvm::opt::ArgList
&DriverArgs
,
75 llvm::opt::ArgStringList
&CC1Args
) const override
;
76 void AddHIPIncludeArgs(const llvm::opt::ArgList
&DriverArgs
,
77 llvm::opt::ArgStringList
&CC1Args
) const override
;
78 llvm::SmallVector
<BitCodeLibraryInfo
, 12>
79 getDeviceLibs(const llvm::opt::ArgList
&Args
) const override
;
81 SanitizerMask
getSupportedSanitizers() const override
;
84 computeMSVCVersion(const Driver
*D
,
85 const llvm::opt::ArgList
&Args
) const override
;
87 unsigned GetDefaultDwarfVersion() const override
{ return 5; }
89 const ToolChain
&HostTC
;
90 void checkTargetID(const llvm::opt::ArgList
&DriverArgs
) const override
;
93 Tool
*buildLinker() const override
;
96 } // end namespace toolchains
97 } // end namespace driver
98 } // end namespace clang
100 #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPAMD_H