clang  8.0.0
HIP.h
Go to the documentation of this file.
1 //===--- HIP.h - HIP ToolChain Implementations ------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIP_H
11 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIP_H
12 
13 #include "clang/Driver/ToolChain.h"
14 #include "clang/Driver/Tool.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  /// \return llvm-link output file name.
42  const char *constructLLVMLinkCommand(Compilation &C, const JobAction &JA,
43  const InputInfoList &Inputs,
44  const llvm::opt::ArgList &Args,
45  llvm::StringRef SubArchName,
46  llvm::StringRef OutputFilePrefix) const;
47 
48  /// \return opt output file name.
49  const char *constructOptCommand(Compilation &C, const JobAction &JA,
50  const InputInfoList &Inputs,
51  const llvm::opt::ArgList &Args,
52  llvm::StringRef SubArchName,
53  llvm::StringRef OutputFilePrefix,
54  const char *InputFileName) const;
55 
56  /// \return llc output file name.
57  const char *constructLlcCommand(Compilation &C, const JobAction &JA,
58  const InputInfoList &Inputs,
59  const llvm::opt::ArgList &Args,
60  llvm::StringRef SubArchName,
61  llvm::StringRef OutputFilePrefix,
62  const char *InputFileName) const;
63 
64  void constructLldCommand(Compilation &C, const JobAction &JA,
65  const InputInfoList &Inputs, const InputInfo &Output,
66  const llvm::opt::ArgList &Args,
67  const char *InputFileName) const;
68 };
69 
70 } // end namespace AMDGCN
71 } // end namespace tools
72 
73 namespace toolchains {
74 
75 class LLVM_LIBRARY_VISIBILITY HIPToolChain : public ToolChain {
76 public:
77  HIPToolChain(const Driver &D, const llvm::Triple &Triple,
78  const ToolChain &HostTC, const llvm::opt::ArgList &Args);
79 
80  const llvm::Triple *getAuxTriple() const override {
81  return &HostTC.getTriple();
82  }
83 
84  llvm::opt::DerivedArgList *
85  TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
86  Action::OffloadKind DeviceOffloadKind) const override;
87  void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
88  llvm::opt::ArgStringList &CC1Args,
89  Action::OffloadKind DeviceOffloadKind) const override;
90 
91  bool useIntegratedAs() const override { return true; }
92  bool isCrossCompiling() const override { return true; }
93  bool isPICDefault() const override { return false; }
94  bool isPIEDefault() const override { return false; }
95  bool isPICDefaultForced() const override { return false; }
96  bool SupportsProfiling() const override { return false; }
97  bool IsMathErrnoDefault() const override { return false; }
98 
99  void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override;
100  CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
101  void
102  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
103  llvm::opt::ArgStringList &CC1Args) const override;
104  void AddClangCXXStdlibIncludeArgs(
105  const llvm::opt::ArgList &Args,
106  llvm::opt::ArgStringList &CC1Args) const override;
107  void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
108  llvm::opt::ArgStringList &CC1Args) const override;
109 
110  SanitizerMask getSupportedSanitizers() const override;
111 
112  VersionTuple
113  computeMSVCVersion(const Driver *D,
114  const llvm::opt::ArgList &Args) const override;
115 
116  unsigned GetDefaultDwarfVersion() const override { return 2; }
117 
119 
120 protected:
121  Tool *buildLinker() const override;
122 };
123 
124 } // end namespace toolchains
125 } // end namespace driver
126 } // end namespace clang
127 
128 #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:97
const llvm::Triple * getAuxTriple() const override
Get the toolchain's aux triple, if it has one.
Definition: HIP.h:80
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:23
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:58
void constructHIPFatbinCommand(Compilation &C, const JobAction &JA, StringRef OutputFileName, const InputInfoList &Inputs, const llvm::opt::ArgList &TCArgs, const Tool &T)
Definition: HIP.cpp:195
bool isCrossCompiling() const override
Returns true if the toolchain is targeting a non-native architecture.
Definition: HIP.h:92
bool SupportsProfiling() const override
SupportsProfiling - Does this tool chain support -pg.
Definition: HIP.h:96
bool isPICDefault() const override
Test whether this toolchain defaults to PIC.
Definition: HIP.h:93
bool isPICDefaultForced() const override
Tests whether this toolchain forces its default for PIC, PIE or non-PIC.
Definition: HIP.h:95
Dataflow Directional Tag Classes.
bool hasIntegratedCPP() const override
Definition: HIP.h:33
Tool - Information on a specific compilation tool.
Definition: Tool.h:34
uint64_t SanitizerMask
Definition: Sanitizers.h:26
Compilation - A set of tasks to perform for a single driver invocation.
Definition: Compilation.h:46
const llvm::Triple & getTriple() const
Definition: ToolChain.h:188
bool isPIEDefault() const override
Test whether this toolchain defaults to PIE.
Definition: HIP.h:94
unsigned GetDefaultDwarfVersion() const override
Definition: HIP.h:116
bool useIntegratedAs() const override
Check if the toolchain should use the integrated assembler.
Definition: HIP.h:91
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:89