Coverage Report

Created: 2021-04-13 08:44

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Driver/ToolChains/HIP.h
Line
Count
Source
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
143
  Linker(const ToolChain &TC) : Tool("AMDGCN::Linker", "amdgcn-link", TC) {}
32
33
325
  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
772
  const llvm::Triple *getAuxTriple() const override {
65
772
    return &HostTC.getTriple();
66
772
  }
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;
86
  llvm::SmallVector<std::string, 12>
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
18
  unsigned GetDefaultDwarfVersion() const override { return 4; }
96
97
  const ToolChain &HostTC;
98
99
protected:
100
  Tool *buildLinker() const override;
101
};
102
103
} // end namespace toolchains
104
} // end namespace driver
105
} // end namespace clang
106
107
#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIP_H