clang  12.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.
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 
75  bool useIntegratedAs() const override { return true; }
76  bool isCrossCompiling() const override { return true; }
77  bool isPICDefault() const override { return false; }
78  bool isPIEDefault() const override { return false; }
79  bool isPICDefaultForced() const override { return false; }
80  bool SupportsProfiling() const override { return false; }
81  bool IsMathErrnoDefault() const override { return false; }
82 
83  void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override;
84  CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
85  void
86  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
87  llvm::opt::ArgStringList &CC1Args) const override;
88  void AddClangCXXStdlibIncludeArgs(
89  const llvm::opt::ArgList &Args,
90  llvm::opt::ArgStringList &CC1Args) const override;
91  void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
92  llvm::opt::ArgStringList &CC1Args) const override;
93  void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
94  llvm::opt::ArgStringList &CC1Args) const override;
95 
96  SanitizerMask getSupportedSanitizers() const override;
97 
98  VersionTuple
99  computeMSVCVersion(const Driver *D,
100  const llvm::opt::ArgList &Args) const override;
101 
102  unsigned GetDefaultDwarfVersion() const override { return 4; }
103 
105 
106 protected:
107  Tool *buildLinker() const override;
108 };
109 
110 } // end namespace toolchains
111 } // end namespace driver
112 } // end namespace clang
113 
114 #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIP_H
Linker(const ToolChain &TC)
Definition: HIP.h:31
bool IsMathErrnoDefault() const override
IsMathErrnoDefault - Does this tool chain use -fmath-errno by default.
Definition: HIP.h:81
const llvm::Triple * getAuxTriple() const override
Get the toolchain's aux triple, if it has one.
Definition: HIP.h:64
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:22
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:59
void constructHIPFatbinCommand(Compilation &C, const JobAction &JA, StringRef OutputFileName, const InputInfoList &Inputs, const llvm::opt::ArgList &TCArgs, const Tool &T)
Definition: HIP.cpp:101
bool isCrossCompiling() const override
Returns true if the toolchain is targeting a non-native architecture.
Definition: HIP.h:76
bool SupportsProfiling() const override
SupportsProfiling - Does this tool chain support -pg.
Definition: HIP.h:80
bool isPICDefault() const override
Test whether this toolchain defaults to PIC.
Definition: HIP.h:77
bool isPICDefaultForced() const override
Tests whether this toolchain forces its default for PIC, PIE or non-PIC.
Definition: HIP.h:79
Dataflow Directional Tag Classes.
bool hasIntegratedCPP() const override
Definition: HIP.h:33
Tool - Information on a specific compilation tool.
Definition: Tool.h:32
Compilation - A set of tasks to perform for a single driver invocation.
Definition: Compilation.h:45
const llvm::Triple & getTriple() const
Definition: ToolChain.h:206
bool isPIEDefault() const override
Test whether this toolchain defaults to PIE.
Definition: HIP.h:78
unsigned GetDefaultDwarfVersion() const override
Definition: HIP.h:102
bool useIntegratedAs() const override
Check if the toolchain should use the integrated assembler.
Definition: HIP.h:75
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:90