clang 22.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;
40 void constructLlvmLinkCommand(Compilation &C, const JobAction &JA,
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, StringRef BoundArch,
66 Action::OffloadKind DeviceOffloadKind) const override;
67 void
68 addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
69 llvm::opt::ArgStringList &CC1Args,
70 Action::OffloadKind DeviceOffloadKind) const override;
71 void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) 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,
85 Action::OffloadKind DeviceOffloadKind) const override;
86
87 SanitizerMask getSupportedSanitizers() const override;
88
89 VersionTuple
90 computeMSVCVersion(const Driver *D,
91 const llvm::opt::ArgList &Args) const override;
92
93 unsigned GetDefaultDwarfVersion() const override { return 5; }
94
96 void checkTargetID(const llvm::opt::ArgList &DriverArgs) const override;
97
98protected:
99 Tool *buildLinker() const override;
100};
101
102class LLVM_LIBRARY_VISIBILITY SPIRVAMDToolChain final : public ROCMToolChain {
103public:
104 SPIRVAMDToolChain(const Driver &D, const llvm::Triple &Triple,
105 const llvm::opt::ArgList &Args);
106
107protected:
108 Tool *buildLinker() const override;
109};
110
111} // end namespace toolchains
112} // end namespace driver
113} // end namespace clang
114
115#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPAMD_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
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
Tool * buildLinker() const override
Definition HIPAMD.cpp:303
HIPAMDToolChain(const Driver &D, const llvm::Triple &Triple, const ToolChain &HostTC, const llvm::opt::ArgList &Args)
Definition HIPAMD.cpp:213
unsigned GetDefaultDwarfVersion() const override
Definition HIPAMD.h:93
void checkTargetID(const llvm::opt::ArgList &DriverArgs) const override
Check and diagnose invalid target ID specified by -mcpu.
Definition HIPAMD.cpp:419
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:843
SPIRVAMDToolChain(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args)
Definition HIPAMD.cpp:428
Linker(const ToolChain &TC)
Definition HIPAMD.h:27
bool hasIntegratedCPP() const override
Definition HIPAMD.h:29
SmallVector< InputInfo, 4 > InputInfoList
Definition Driver.h:50
The JSON file list parser is used to communicate input to InstallAPI.