xref: /freebsd/contrib/llvm-project/clang/lib/Driver/ToolChains/AMDGPUOpenMP.h (revision 18054d0220cfc8df9c9568c437bd6fbb59d53c3c)
1 //===- AMDGPUOpenMP.h - AMDGPUOpenMP ToolChain Implementation -*- 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_AMDGPUOPENMP_H
10 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AMDGPUOPENMP_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 toolchains {
20 class AMDGPUOpenMPToolChain;
21 }
22 
23 namespace tools {
24 
25 namespace AMDGCN {
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 OpenMPLinker : public Tool {
29 public:
30   OpenMPLinker(const ToolChain &TC)
31       : Tool("AMDGCN::OpenMPLinker", "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(
43       const toolchains::AMDGPUOpenMPToolChain &AMDGPUOpenMPTC, Compilation &C,
44       const JobAction &JA, const InputInfoList &Inputs,
45       const llvm::opt::ArgList &Args, llvm::StringRef SubArchName,
46       llvm::StringRef OutputFilePrefix) const;
47 
48   /// \return llc output file name.
49   const char *constructLlcCommand(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,
55                                   bool OutputIsAsm = false) const;
56 
57   void constructLldCommand(Compilation &C, const JobAction &JA,
58                            const InputInfoList &Inputs, const InputInfo &Output,
59                            const llvm::opt::ArgList &Args,
60                            const char *InputFileName) const;
61 };
62 
63 } // end namespace AMDGCN
64 } // end namespace tools
65 
66 namespace toolchains {
67 
68 class LLVM_LIBRARY_VISIBILITY AMDGPUOpenMPToolChain final
69     : public ROCMToolChain {
70 public:
71   AMDGPUOpenMPToolChain(const Driver &D, const llvm::Triple &Triple,
72                         const ToolChain &HostTC,
73                         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
83   addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
84                         llvm::opt::ArgStringList &CC1Args,
85                         Action::OffloadKind DeviceOffloadKind) const override;
86   void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override;
87   CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
88   void
89   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
90                             llvm::opt::ArgStringList &CC1Args) const override;
91   void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
92                            llvm::opt::ArgStringList &CC1Args) const override;
93 
94   SanitizerMask getSupportedSanitizers() const override;
95 
96   VersionTuple
97   computeMSVCVersion(const Driver *D,
98                      const llvm::opt::ArgList &Args) const override;
99 
100   const ToolChain &HostTC;
101 
102 protected:
103   Tool *buildLinker() const override;
104 };
105 
106 } // end namespace toolchains
107 } // end namespace driver
108 } // end namespace clang
109 
110 #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AMDGPUOPENMP_H
111