xref: /netbsd-src/external/apache2/llvm/dist/clang/lib/Driver/ToolChains/AMDGPUOpenMP.h (revision e038c9c4676b0f19b1b7dd08a940c6ed64a6d5ae)
1*e038c9c4Sjoerg //===- AMDGPUOpenMP.h - AMDGPUOpenMP ToolChain Implementation -*- C++ -*---===//
2*e038c9c4Sjoerg //
3*e038c9c4Sjoerg // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*e038c9c4Sjoerg // See https://llvm.org/LICENSE.txt for license information.
5*e038c9c4Sjoerg // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*e038c9c4Sjoerg //
7*e038c9c4Sjoerg //===----------------------------------------------------------------------===//
8*e038c9c4Sjoerg 
9*e038c9c4Sjoerg #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AMDGPUOPENMP_H
10*e038c9c4Sjoerg #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AMDGPUOPENMP_H
11*e038c9c4Sjoerg 
12*e038c9c4Sjoerg #include "AMDGPU.h"
13*e038c9c4Sjoerg #include "clang/Driver/Tool.h"
14*e038c9c4Sjoerg #include "clang/Driver/ToolChain.h"
15*e038c9c4Sjoerg 
16*e038c9c4Sjoerg namespace clang {
17*e038c9c4Sjoerg namespace driver {
18*e038c9c4Sjoerg 
19*e038c9c4Sjoerg namespace tools {
20*e038c9c4Sjoerg 
21*e038c9c4Sjoerg namespace AMDGCN {
22*e038c9c4Sjoerg // Runs llvm-link/opt/llc/lld, which links multiple LLVM bitcode, together with
23*e038c9c4Sjoerg // device library, then compiles it to ISA in a shared object.
24*e038c9c4Sjoerg class LLVM_LIBRARY_VISIBILITY OpenMPLinker : public Tool {
25*e038c9c4Sjoerg public:
OpenMPLinker(const ToolChain & TC)26*e038c9c4Sjoerg   OpenMPLinker(const ToolChain &TC)
27*e038c9c4Sjoerg       : Tool("AMDGCN::OpenMPLinker", "amdgcn-link", TC) {}
28*e038c9c4Sjoerg 
hasIntegratedCPP()29*e038c9c4Sjoerg   bool hasIntegratedCPP() const override { return false; }
30*e038c9c4Sjoerg 
31*e038c9c4Sjoerg   void ConstructJob(Compilation &C, const JobAction &JA,
32*e038c9c4Sjoerg                     const InputInfo &Output, const InputInfoList &Inputs,
33*e038c9c4Sjoerg                     const llvm::opt::ArgList &TCArgs,
34*e038c9c4Sjoerg                     const char *LinkingOutput) const override;
35*e038c9c4Sjoerg 
36*e038c9c4Sjoerg private:
37*e038c9c4Sjoerg   /// \return llvm-link output file name.
38*e038c9c4Sjoerg   const char *constructLLVMLinkCommand(Compilation &C, const JobAction &JA,
39*e038c9c4Sjoerg                                        const InputInfoList &Inputs,
40*e038c9c4Sjoerg                                        const llvm::opt::ArgList &Args,
41*e038c9c4Sjoerg                                        llvm::StringRef SubArchName,
42*e038c9c4Sjoerg                                        llvm::StringRef OutputFilePrefix) const;
43*e038c9c4Sjoerg 
44*e038c9c4Sjoerg   /// \return llc output file name.
45*e038c9c4Sjoerg   const char *constructLlcCommand(Compilation &C, const JobAction &JA,
46*e038c9c4Sjoerg                                   const InputInfoList &Inputs,
47*e038c9c4Sjoerg                                   const llvm::opt::ArgList &Args,
48*e038c9c4Sjoerg                                   llvm::StringRef SubArchName,
49*e038c9c4Sjoerg                                   llvm::StringRef OutputFilePrefix,
50*e038c9c4Sjoerg                                   const char *InputFileName,
51*e038c9c4Sjoerg                                   bool OutputIsAsm = false) const;
52*e038c9c4Sjoerg 
53*e038c9c4Sjoerg   void constructLldCommand(Compilation &C, const JobAction &JA,
54*e038c9c4Sjoerg                            const InputInfoList &Inputs, const InputInfo &Output,
55*e038c9c4Sjoerg                            const llvm::opt::ArgList &Args,
56*e038c9c4Sjoerg                            const char *InputFileName) const;
57*e038c9c4Sjoerg };
58*e038c9c4Sjoerg 
59*e038c9c4Sjoerg } // end namespace AMDGCN
60*e038c9c4Sjoerg } // end namespace tools
61*e038c9c4Sjoerg 
62*e038c9c4Sjoerg namespace toolchains {
63*e038c9c4Sjoerg 
64*e038c9c4Sjoerg class LLVM_LIBRARY_VISIBILITY AMDGPUOpenMPToolChain final
65*e038c9c4Sjoerg     : public ROCMToolChain {
66*e038c9c4Sjoerg public:
67*e038c9c4Sjoerg   AMDGPUOpenMPToolChain(const Driver &D, const llvm::Triple &Triple,
68*e038c9c4Sjoerg                         const ToolChain &HostTC,
69*e038c9c4Sjoerg                         const llvm::opt::ArgList &Args);
70*e038c9c4Sjoerg 
getAuxTriple()71*e038c9c4Sjoerg   const llvm::Triple *getAuxTriple() const override {
72*e038c9c4Sjoerg     return &HostTC.getTriple();
73*e038c9c4Sjoerg   }
74*e038c9c4Sjoerg 
75*e038c9c4Sjoerg   llvm::opt::DerivedArgList *
76*e038c9c4Sjoerg   TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
77*e038c9c4Sjoerg                 Action::OffloadKind DeviceOffloadKind) const override;
78*e038c9c4Sjoerg   void
79*e038c9c4Sjoerg   addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
80*e038c9c4Sjoerg                         llvm::opt::ArgStringList &CC1Args,
81*e038c9c4Sjoerg                         Action::OffloadKind DeviceOffloadKind) const override;
82*e038c9c4Sjoerg   void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override;
83*e038c9c4Sjoerg   CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
84*e038c9c4Sjoerg   void
85*e038c9c4Sjoerg   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
86*e038c9c4Sjoerg                             llvm::opt::ArgStringList &CC1Args) const override;
87*e038c9c4Sjoerg   void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
88*e038c9c4Sjoerg                            llvm::opt::ArgStringList &CC1Args) const override;
89*e038c9c4Sjoerg 
90*e038c9c4Sjoerg   SanitizerMask getSupportedSanitizers() const override;
91*e038c9c4Sjoerg 
92*e038c9c4Sjoerg   VersionTuple
93*e038c9c4Sjoerg   computeMSVCVersion(const Driver *D,
94*e038c9c4Sjoerg                      const llvm::opt::ArgList &Args) const override;
95*e038c9c4Sjoerg 
96*e038c9c4Sjoerg   const ToolChain &HostTC;
97*e038c9c4Sjoerg 
98*e038c9c4Sjoerg protected:
99*e038c9c4Sjoerg   Tool *buildLinker() const override;
100*e038c9c4Sjoerg };
101*e038c9c4Sjoerg 
102*e038c9c4Sjoerg } // end namespace toolchains
103*e038c9c4Sjoerg } // end namespace driver
104*e038c9c4Sjoerg } // end namespace clang
105*e038c9c4Sjoerg 
106*e038c9c4Sjoerg #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AMDGPUOPENMP_H
107