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