clang  14.0.0git
HIP.h
Go to the documentation of this file.
1 //===--- HIP.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_HIP_H
10 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIP_H
11 
12 #include "clang/Driver/ToolChain.h"
13 #include "clang/Driver/Tool.h"
14 #include "AMDGPU.h"
15 
16 namespace clang {
17 namespace driver {
18 
19 namespace tools {
20 
21 namespace AMDGCN {
22  // Construct command for creating HIP fatbin.
23  void constructHIPFatbinCommand(Compilation &C, const JobAction &JA,
24  StringRef OutputFileName, const InputInfoList &Inputs,
25  const llvm::opt::ArgList &TCArgs, const Tool& T);
26 
27 // Runs llvm-link/opt/llc/lld, which links multiple LLVM bitcode, together with
28 // device library, then compiles it to ISA in a shared object.
29 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
30 public:
31  Linker(const ToolChain &TC) : Tool("AMDGCN::Linker", "amdgcn-link", TC) {}
32 
33  bool hasIntegratedCPP() const override { return false; }
34 
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 private:
41 
42  void constructLldCommand(Compilation &C, const JobAction &JA,
43  const InputInfoList &Inputs, const InputInfo &Output,
44  const llvm::opt::ArgList &Args) const;
45 
46  // Construct command for creating Object from HIP fatbin.
47  void constructGenerateObjFileFromHIPFatBinary(Compilation &C,
48  const InputInfo &Output,
49  const InputInfoList &Inputs,
50  const llvm::opt::ArgList &Args,
51  const JobAction &JA) const;
52 };
53 
54 } // end namespace AMDGCN
55 } // end namespace tools
56 
57 namespace toolchains {
58 
59 class LLVM_LIBRARY_VISIBILITY HIPToolChain final : public ROCMToolChain {
60 public:
61  HIPToolChain(const Driver &D, const llvm::Triple &Triple,
62  const ToolChain &HostTC, const llvm::opt::ArgList &Args);
63 
64  const llvm::Triple *getAuxTriple() const override {
65  return &HostTC.getTriple();
66  }
67 
68  llvm::opt::DerivedArgList *
69  TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
70  Action::OffloadKind DeviceOffloadKind) const override;
71  void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
72  llvm::opt::ArgStringList &CC1Args,
73  Action::OffloadKind DeviceOffloadKind) const override;
74  void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override;
75  CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
76  void
77  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
78  llvm::opt::ArgStringList &CC1Args) const override;
79  void AddClangCXXStdlibIncludeArgs(
80  const llvm::opt::ArgList &Args,
81  llvm::opt::ArgStringList &CC1Args) const override;
82  void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
83  llvm::opt::ArgStringList &CC1Args) const override;
84  void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
85  llvm::opt::ArgStringList &CC1Args) const override;
87  getHIPDeviceLibs(const llvm::opt::ArgList &Args) const override;
88 
89  SanitizerMask getSupportedSanitizers() const override;
90 
91  VersionTuple
92  computeMSVCVersion(const Driver *D,
93  const llvm::opt::ArgList &Args) const override;
94 
95  unsigned GetDefaultDwarfVersion() const override { return 5; }
96 
97  const ToolChain &HostTC;
98  void checkTargetID(const llvm::opt::ArgList &DriverArgs) const override;
99 
100 protected:
101  Tool *buildLinker() const override;
102 };
103 
104 } // end namespace toolchains
105 } // end namespace driver
106 } // end namespace clang
107 
108 #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIP_H
clang::driver::tools::AMDGCN::Linker::Linker
Linker(const ToolChain &TC)
Definition: HIP.h:31
clang::driver::toolchains::HIPToolChain
Definition: HIP.h:59
clang::driver::tools::AMDGCN::constructHIPFatbinCommand
void constructHIPFatbinCommand(Compilation &C, const JobAction &JA, StringRef OutputFileName, const InputInfoList &Inputs, const llvm::opt::ArgList &TCArgs, const Tool &T)
Definition: HIP.cpp:102
llvm::SmallVector
Definition: LLVM.h:38
clang::driver::InputInfoList
SmallVector< InputInfo, 4 > InputInfoList
Definition: Tool.h:27
clang::driver::InputInfo
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:22
clang::driver::Tool
Tool - Information on a specific compilation tool.
Definition: Tool.h:32
Tool.h
clang::driver::ToolChain::getTriple
const llvm::Triple & getTriple() const
Definition: ToolChain.h:223
AMDGPU.h
ToolChain.h
clang::driver::ToolChain
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:91
clang::driver::Compilation
Compilation - A set of tasks to perform for a single driver invocation.
Definition: Compilation.h:45
clang::driver::toolchains::HIPToolChain::getAuxTriple
const llvm::Triple * getAuxTriple() const override
Get the toolchain's aux triple, if it has one.
Definition: HIP.h:64
clang
Definition: CalledOnceCheck.h:17
clang::driver::Driver
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:59
clang::driver::toolchains::HIPToolChain::HostTC
const ToolChain & HostTC
Definition: HIP.h:97
clang::driver::toolchains::ROCMToolChain
Definition: AMDGPU.h:131
clang::driver::tools::AMDGCN::Linker::hasIntegratedCPP
bool hasIntegratedCPP() const override
Definition: HIP.h:33
clang::driver::Action::OffloadKind
OffloadKind
Definition: Action.h:85
clang::driver::JobAction
Definition: Action.h:380
clang::driver::tools::AMDGCN::Linker
Definition: HIP.h:29
clang::SanitizerMask
Definition: Sanitizers.h:30
clang::driver::toolchains::HIPToolChain::GetDefaultDwarfVersion
unsigned GetDefaultDwarfVersion() const override
Definition: HIP.h:95