clang 10.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
15 namespace clang {
16 namespace driver {
17
18 namespace tools {
19
20 namespace AMDGCN {
21 // Construct command for creating HIP fatbin.
22 void constructHIPFatbinCommand(Compilation &C, const JobAction &JA,
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,
62 bool OutputIsAsm = false) 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 4; }
117
118 const ToolChain &HostTC;
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
clang::driver::tools::AMDGCN::Linker::Linker
Linker(const ToolChain &TC)
Definition: HIP.h:30
Tool.h
clang::driver::toolchains::HIPToolChain::IsMathErrnoDefault
bool IsMathErrnoDefault() const override
IsMathErrnoDefault - Does this tool chain use -fmath-errno by default.
Definition: HIP.h:97
clang::driver::ToolChain::CXXStdlibType
CXXStdlibType
Definition: ToolChain.h:92
clang::driver::JobAction
Definition: Action.h:375
clang::driver::toolchains::HIPToolChain::getAuxTriple
const llvm::Triple * getAuxTriple() const override
Get the toolchain&#39;s aux triple, if it has one.
Definition: HIP.h:80
clang::driver::InputInfo
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:22
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:118
clang::driver::tools::AMDGCN::Linker
Definition: HIP.h:28
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:201
clang::driver::toolchains::HIPToolChain::isCrossCompiling
bool isCrossCompiling() const override
Returns true if the toolchain is targeting a non-native architecture.
Definition: HIP.h:92
clang::driver::toolchains::HIPToolChain::SupportsProfiling
bool SupportsProfiling() const override
SupportsProfiling - Does this tool chain support -pg.
Definition: HIP.h:96
clang::driver::toolchains::HIPToolChain::isPICDefault
bool isPICDefault() const override
Test whether this toolchain defaults to PIC.
Definition: HIP.h:93
ToolChain.h
clang::SanitizerMask
Definition: Sanitizers.h:29
llvm::SmallVector
Definition: LLVM.h:35
clang::driver::toolchains::HIPToolChain::isPICDefaultForced
bool isPICDefaultForced() const override
Tests whether this toolchain forces its default for PIC, PIE or non-PIC.
Definition: HIP.h:95
clang::driver::Action::OffloadKind
OffloadKind
Definition: Action.h:84
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:21
clang::driver::tools::AMDGCN::Linker::hasIntegratedCPP
bool hasIntegratedCPP() const override
Definition: HIP.h:32
clang::driver::Tool
Tool - Information on a specific compilation tool.
Definition: Tool.h:33
clang::driver::Compilation
Compilation - A set of tasks to perform for a single driver invocation.
Definition: Compilation.h:45
clang::driver::ToolChain::getTriple
const llvm::Triple & getTriple() const
Definition: ToolChain.h:201
clang::driver::toolchains::HIPToolChain::isPIEDefault
bool isPIEDefault() const override
Test whether this toolchain defaults to PIE.
Definition: HIP.h:94
clang::driver::toolchains::HIPToolChain::GetDefaultDwarfVersion
unsigned GetDefaultDwarfVersion() const override
Definition: HIP.h:116
clang::driver::toolchains::HIPToolChain
Definition: HIP.h:75
clang::driver::toolchains::HIPToolChain::useIntegratedAs
bool useIntegratedAs() const override
Check if the toolchain should use the integrated assembler.
Definition: HIP.h:91
clang::driver::ToolChain
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:88