clang  9.0.0
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 
15 namespace clang {
16 namespace driver {
17 
18 namespace tools {
19 
20 namespace AMDGCN {
21  // Construct command for creating HIP fatbin.
23  StringRef OutputFileName, const InputInfoList &Inputs,
24  const llvm::opt::ArgList &TCArgs, const Tool& T);
25 
26 // Runs llvm-link/opt/llc/lld, which links multiple LLVM bitcode, together with
27 // device library, then compiles it to ISA in a shared object.
28 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
29 public:
30  Linker(const ToolChain &TC) : Tool("AMDGCN::Linker", "amdgcn-link", TC) {}
31 
32  bool hasIntegratedCPP() const override { return false; }
33 
34  void ConstructJob(Compilation &C, const JobAction &JA,
35  const InputInfo &Output, const InputInfoList &Inputs,
36  const llvm::opt::ArgList &TCArgs,
37  const char *LinkingOutput) const override;
38 
39 private:
40  /// \return llvm-link output file name.
41  const char *constructLLVMLinkCommand(Compilation &C, const JobAction &JA,
42  const InputInfoList &Inputs,
43  const llvm::opt::ArgList &Args,
44  llvm::StringRef SubArchName,
45  llvm::StringRef OutputFilePrefix) const;
46 
47  /// \return opt output file name.
48  const char *constructOptCommand(Compilation &C, const JobAction &JA,
49  const InputInfoList &Inputs,
50  const llvm::opt::ArgList &Args,
51  llvm::StringRef SubArchName,
52  llvm::StringRef OutputFilePrefix,
53  const char *InputFileName) const;
54 
55  /// \return llc output file name.
56  const char *constructLlcCommand(Compilation &C, const JobAction &JA,
57  const InputInfoList &Inputs,
58  const llvm::opt::ArgList &Args,
59  llvm::StringRef SubArchName,
60  llvm::StringRef OutputFilePrefix,
61  const char *InputFileName) const;
62 
63  void constructLldCommand(Compilation &C, const JobAction &JA,
64  const InputInfoList &Inputs, const InputInfo &Output,
65  const llvm::opt::ArgList &Args,
66  const char *InputFileName) const;
67 };
68 
69 } // end namespace AMDGCN
70 } // end namespace tools
71 
72 namespace toolchains {
73 
74 class LLVM_LIBRARY_VISIBILITY HIPToolChain : public ToolChain {
75 public:
76  HIPToolChain(const Driver &D, const llvm::Triple &Triple,
77  const ToolChain &HostTC, const llvm::opt::ArgList &Args);
78 
79  const llvm::Triple *getAuxTriple() const override {
80  return &HostTC.getTriple();
81  }
82 
83  llvm::opt::DerivedArgList *
84  TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
85  Action::OffloadKind DeviceOffloadKind) const override;
86  void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
87  llvm::opt::ArgStringList &CC1Args,
88  Action::OffloadKind DeviceOffloadKind) const override;
89 
90  bool useIntegratedAs() const override { return true; }
91  bool isCrossCompiling() const override { return true; }
92  bool isPICDefault() const override { return false; }
93  bool isPIEDefault() const override { return false; }
94  bool isPICDefaultForced() const override { return false; }
95  bool SupportsProfiling() const override { return false; }
96  bool IsMathErrnoDefault() const override { return false; }
97 
98  void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override;
99  CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
100  void
101  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
102  llvm::opt::ArgStringList &CC1Args) const override;
103  void AddClangCXXStdlibIncludeArgs(
104  const llvm::opt::ArgList &Args,
105  llvm::opt::ArgStringList &CC1Args) const override;
106  void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
107  llvm::opt::ArgStringList &CC1Args) const override;
108 
109  SanitizerMask getSupportedSanitizers() const override;
110 
111  VersionTuple
112  computeMSVCVersion(const Driver *D,
113  const llvm::opt::ArgList &Args) const override;
114 
115  unsigned GetDefaultDwarfVersion() const override { return 2; }
116 
118 
119 protected:
120  Tool *buildLinker() const override;
121 };
122 
123 } // end namespace toolchains
124 } // end namespace driver
125 } // end namespace clang
126 
127 #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIP_H
Linker(const ToolChain &TC)
Definition: HIP.h:30
bool IsMathErrnoDefault() const override
IsMathErrnoDefault - Does this tool chain use -fmath-errno by default.
Definition: HIP.h:96
const llvm::Triple * getAuxTriple() const override
Get the toolchain's aux triple, if it has one.
Definition: HIP.h:79
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:57
void constructHIPFatbinCommand(Compilation &C, const JobAction &JA, StringRef OutputFileName, const InputInfoList &Inputs, const llvm::opt::ArgList &TCArgs, const Tool &T)
Definition: HIP.cpp:183
bool isCrossCompiling() const override
Returns true if the toolchain is targeting a non-native architecture.
Definition: HIP.h:91
bool SupportsProfiling() const override
SupportsProfiling - Does this tool chain support -pg.
Definition: HIP.h:95
bool isPICDefault() const override
Test whether this toolchain defaults to PIC.
Definition: HIP.h:92
bool isPICDefaultForced() const override
Tests whether this toolchain forces its default for PIC, PIE or non-PIC.
Definition: HIP.h:94
Dataflow Directional Tag Classes.
bool hasIntegratedCPP() const override
Definition: HIP.h:32
Tool - Information on a specific compilation tool.
Definition: Tool.h:33
Compilation - A set of tasks to perform for a single driver invocation.
Definition: Compilation.h:45
const llvm::Triple & getTriple() const
Definition: ToolChain.h:195
bool isPIEDefault() const override
Test whether this toolchain defaults to PIE.
Definition: HIP.h:93
unsigned GetDefaultDwarfVersion() const override
Definition: HIP.h:115
bool useIntegratedAs() const override
Check if the toolchain should use the integrated assembler.
Definition: HIP.h:90
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:88