xref: /freebsd/contrib/llvm-project/clang/lib/Driver/ToolChains/HIPAMD.h (revision 38a52bd3b5cac3da6f7f6eef3dd050e6aa08ebb3)
1 //===--- HIPAMD.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_HIPAMD_H
10 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPAMD_H
11 
12 #include "AMDGPU.h"
13 #include "clang/Driver/Tool.h"
14 #include "clang/Driver/ToolChain.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   void constructLldCommand(Compilation &C, const JobAction &JA,
37                            const InputInfoList &Inputs, const InputInfo &Output,
38                            const llvm::opt::ArgList &Args) const;
39 };
40 
41 } // end namespace AMDGCN
42 } // end namespace tools
43 
44 namespace toolchains {
45 
46 class LLVM_LIBRARY_VISIBILITY HIPAMDToolChain final : public ROCMToolChain {
47 public:
48   HIPAMDToolChain(const Driver &D, const llvm::Triple &Triple,
49                   const ToolChain &HostTC, const llvm::opt::ArgList &Args);
50 
51   const llvm::Triple *getAuxTriple() const override {
52     return &HostTC.getTriple();
53   }
54 
55   llvm::opt::DerivedArgList *
56   TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
57                 Action::OffloadKind DeviceOffloadKind) const override;
58   void
59   addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
60                         llvm::opt::ArgStringList &CC1Args,
61                         Action::OffloadKind DeviceOffloadKind) const override;
62   void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override;
63   CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
64   void
65   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
66                             llvm::opt::ArgStringList &CC1Args) const override;
67   void AddClangCXXStdlibIncludeArgs(
68       const llvm::opt::ArgList &Args,
69       llvm::opt::ArgStringList &CC1Args) const override;
70   void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
71                            llvm::opt::ArgStringList &CC1Args) const override;
72   void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
73                          llvm::opt::ArgStringList &CC1Args) const override;
74   llvm::SmallVector<BitCodeLibraryInfo, 12>
75   getHIPDeviceLibs(const llvm::opt::ArgList &Args) const override;
76 
77   SanitizerMask getSupportedSanitizers() const override;
78 
79   VersionTuple
80   computeMSVCVersion(const Driver *D,
81                      const llvm::opt::ArgList &Args) const override;
82 
83   unsigned GetDefaultDwarfVersion() const override { return 5; }
84 
85   const ToolChain &HostTC;
86   void checkTargetID(const llvm::opt::ArgList &DriverArgs) const override;
87 
88 protected:
89   Tool *buildLinker() const override;
90 };
91 
92 } // end namespace toolchains
93 } // end namespace driver
94 } // end namespace clang
95 
96 #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPAMD_H
97