clang 23.0.0git
HIPAMD.h
Go to the documentation of this file.
1//===--- HIPAMD.h - HIP 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_HIPAMD_H
10#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPAMD_H
11
12#include "AMDGPU.h"
14#include "clang/Driver/Tool.h"
16
17namespace clang {
18namespace driver {
19
20namespace tools {
21
22namespace AMDGCN {
23// Runs llvm-link/opt/llc/lld, which links multiple LLVM bitcode, together with
24// device library, then compiles it to ISA in a shared object.
25class LLVM_LIBRARY_VISIBILITY Linker final : public Tool {
26public:
27 Linker(const ToolChain &TC) : Tool("AMDGCN::Linker", "amdgcn-link", TC) {}
28
29 bool hasIntegratedCPP() const override { return false; }
30
31 void ConstructJob(Compilation &C, const JobAction &JA,
32 const InputInfo &Output, const InputInfoList &Inputs,
33 const llvm::opt::ArgList &TCArgs,
34 const char *LinkingOutput) const override;
35
36private:
37 void constructLldCommand(Compilation &C, const JobAction &JA,
38 const InputInfoList &Inputs, const InputInfo &Output,
39 const llvm::opt::ArgList &Args) const;
41 const InputInfoList &Inputs,
42 const InputInfo &Output,
43 const llvm::opt::ArgList &Args) const;
44 void constructLinkAndEmitSpirvCommand(Compilation &C, const JobAction &JA,
45 const InputInfoList &Inputs,
46 const InputInfo &Output,
47 const llvm::opt::ArgList &Args) const;
48};
49
50} // end namespace AMDGCN
51} // end namespace tools
52
53namespace toolchains {
54
55class LLVM_LIBRARY_VISIBILITY HIPAMDToolChain final : public ROCMToolChain {
56public:
57 HIPAMDToolChain(const Driver &D, const llvm::Triple &Triple,
58 const ToolChain &HostTC, const llvm::opt::ArgList &Args);
59
60 const llvm::Triple *getAuxTriple() const override {
61 return &HostTC.getTriple();
62 }
63
64 llvm::opt::DerivedArgList *
65 TranslateArgs(const llvm::opt::DerivedArgList &Args, BoundArch BA,
66 Action::OffloadKind DeviceOffloadKind) const override;
67
68 void
69 addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
70 llvm::opt::ArgStringList &CC1Args, BoundArch BA,
71 Action::OffloadKind DeviceOffloadKind) const override;
72 CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
73 void
74 AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
75 llvm::opt::ArgStringList &CC1Args) const override;
76 void AddClangCXXStdlibIncludeArgs(
77 const llvm::opt::ArgList &Args,
78 llvm::opt::ArgStringList &CC1Args) const override;
79 void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
80 llvm::opt::ArgStringList &CC1Args) const override;
81 void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
82 llvm::opt::ArgStringList &CC1Args) const override;
84 getDeviceLibs(const llvm::opt::ArgList &Args, BoundArch BA,
85 Action::OffloadKind DeviceOffloadKind) const override;
86
87 VersionTuple
88 computeMSVCVersion(const Driver *D,
89 const llvm::opt::ArgList &Args) const override;
90
91 unsigned GetDefaultDwarfVersion() const override { return 5; }
92
93 /// HIP uses LTO by default to link device bitcode.
94 LTOKind getDefaultLTOMode() const override { return LTOK_Full; }
95
98 checkTargetID(const llvm::opt::ArgList &DriverArgs) const override;
99
100protected:
101 Tool *buildLinker() const override;
102};
103
104class LLVM_LIBRARY_VISIBILITY SPIRVAMDToolChain final : public ROCMToolChain {
105public:
106 SPIRVAMDToolChain(const Driver &D, const llvm::Triple &Triple,
107 const llvm::opt::ArgList &Args);
108
109 /// SPIR-V uses LTO by default to link device bitcode.
110 LTOKind getDefaultLTOMode() const override { return LTOK_Full; }
111
112protected:
113 Tool *buildLinker() const override;
114};
115
116} // end namespace toolchains
117} // end namespace driver
118} // end namespace clang
119
120#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPAMD_H
Compilation - A set of tasks to perform for a single driver invocation.
Definition Compilation.h:46
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition Driver.h:95
InputInfo - Wrapper for information about an input source.
Definition InputInfo.h:22
ToolChain - Access to tools for a single platform.
Definition ToolChain.h:96
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
ParsedTargetIDType checkTargetID(const llvm::opt::ArgList &DriverArgs) const override
Check and diagnose invalid target ID specified by -mcpu.
Definition HIPAMD.cpp:406
Tool * buildLinker() const override
Definition HIPAMD.cpp:299
HIPAMDToolChain(const Driver &D, const llvm::Triple &Triple, const ToolChain &HostTC, const llvm::opt::ArgList &Args)
Definition HIPAMD.cpp:227
unsigned GetDefaultDwarfVersion() const override
Definition HIPAMD.h:91
LTOKind getDefaultLTOMode() const override
HIP uses LTO by default to link device bitcode.
Definition HIPAMD.h:94
const llvm::Triple * getAuxTriple() const override
Get the toolchain's aux triple, if it has one.
Definition HIPAMD.h:60
ROCMToolChain(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args)
ROCM Toolchain.
Definition AMDGPU.cpp:839
SPIRVAMDToolChain(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args)
Definition HIPAMD.cpp:415
LTOKind getDefaultLTOMode() const override
SPIR-V uses LTO by default to link device bitcode.
Definition HIPAMD.h:110
Linker(const ToolChain &TC)
Definition HIPAMD.h:27
bool hasIntegratedCPP() const override
Definition HIPAMD.h:29
void constructLLVMLinkCommand(Compilation &C, const Tool &T, const JobAction &JA, const InputInfoList &JobInputs, const llvm::opt::ArgStringList &LinkerInputs, const InputInfo &Output, const llvm::opt::ArgList &Args, const char *OutputFilename=nullptr)
LTOKind
Describes the kind of LTO mode selected via -f(no-)?lto(=.*)? options.
Definition Driver.h:59
SmallVector< InputInfo, 4 > InputInfoList
Definition Driver.h:51
The JSON file list parser is used to communicate input to InstallAPI.
Represents a bound architecture for offload / multiple architecture compilation.
The struct type returned by getParsedTargetID.
Definition AMDGPU.h:113