xref: /freebsd/contrib/llvm-project/clang/lib/Driver/ToolChains/HIPSPV.h (revision 5f757f3ff9144b609b3c433dfd370cc6bdc191ad)
10eae32dcSDimitry Andric //===--- HIPSPV.h - HIP ToolChain Implementations ---------------*- C++ -*-===//
20eae32dcSDimitry Andric //
30eae32dcSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40eae32dcSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50eae32dcSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60eae32dcSDimitry Andric //
70eae32dcSDimitry Andric //===----------------------------------------------------------------------===//
80eae32dcSDimitry Andric 
90eae32dcSDimitry Andric #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPSPV_H
100eae32dcSDimitry Andric #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPSPV_H
110eae32dcSDimitry Andric 
120eae32dcSDimitry Andric #include "SPIRV.h"
130eae32dcSDimitry Andric #include "clang/Driver/Tool.h"
140eae32dcSDimitry Andric #include "clang/Driver/ToolChain.h"
150eae32dcSDimitry Andric 
160eae32dcSDimitry Andric namespace clang {
170eae32dcSDimitry Andric namespace driver {
180eae32dcSDimitry Andric namespace tools {
190eae32dcSDimitry Andric namespace HIPSPV {
200eae32dcSDimitry Andric 
210eae32dcSDimitry Andric // Runs llvm-link/opt/llc/lld, which links multiple LLVM bitcode, together with
220eae32dcSDimitry Andric // device library, then compiles it to SPIR-V in a shared object.
23*5f757f3fSDimitry Andric class LLVM_LIBRARY_VISIBILITY Linker final : public Tool {
240eae32dcSDimitry Andric public:
250eae32dcSDimitry Andric   Linker(const ToolChain &TC) : Tool("HIPSPV::Linker", "hipspv-link", TC) {}
260eae32dcSDimitry Andric 
270eae32dcSDimitry Andric   bool hasIntegratedCPP() const override { return false; }
280eae32dcSDimitry Andric 
290eae32dcSDimitry Andric   void ConstructJob(Compilation &C, const JobAction &JA,
300eae32dcSDimitry Andric                     const InputInfo &Output, const InputInfoList &Inputs,
310eae32dcSDimitry Andric                     const llvm::opt::ArgList &TCArgs,
320eae32dcSDimitry Andric                     const char *LinkingOutput) const override;
330eae32dcSDimitry Andric 
340eae32dcSDimitry Andric private:
350eae32dcSDimitry Andric   void constructLinkAndEmitSpirvCommand(Compilation &C, const JobAction &JA,
360eae32dcSDimitry Andric                                         const InputInfoList &Inputs,
370eae32dcSDimitry Andric                                         const InputInfo &Output,
380eae32dcSDimitry Andric                                         const llvm::opt::ArgList &Args) const;
390eae32dcSDimitry Andric };
400eae32dcSDimitry Andric 
410eae32dcSDimitry Andric } // namespace HIPSPV
420eae32dcSDimitry Andric } // namespace tools
430eae32dcSDimitry Andric 
440eae32dcSDimitry Andric namespace toolchains {
450eae32dcSDimitry Andric 
460eae32dcSDimitry Andric class LLVM_LIBRARY_VISIBILITY HIPSPVToolChain final : public ToolChain {
470eae32dcSDimitry Andric public:
480eae32dcSDimitry Andric   HIPSPVToolChain(const Driver &D, const llvm::Triple &Triple,
490eae32dcSDimitry Andric                   const ToolChain &HostTC, const llvm::opt::ArgList &Args);
500eae32dcSDimitry Andric 
510eae32dcSDimitry Andric   const llvm::Triple *getAuxTriple() const override {
520eae32dcSDimitry Andric     return &HostTC.getTriple();
530eae32dcSDimitry Andric   }
540eae32dcSDimitry Andric 
550eae32dcSDimitry Andric   void
560eae32dcSDimitry Andric   addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
570eae32dcSDimitry Andric                         llvm::opt::ArgStringList &CC1Args,
580eae32dcSDimitry Andric                         Action::OffloadKind DeviceOffloadKind) const override;
590eae32dcSDimitry Andric   void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override;
600eae32dcSDimitry Andric   CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
610eae32dcSDimitry Andric   void
620eae32dcSDimitry Andric   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
630eae32dcSDimitry Andric                             llvm::opt::ArgStringList &CC1Args) const override;
640eae32dcSDimitry Andric   void AddClangCXXStdlibIncludeArgs(
650eae32dcSDimitry Andric       const llvm::opt::ArgList &Args,
660eae32dcSDimitry Andric       llvm::opt::ArgStringList &CC1Args) const override;
670eae32dcSDimitry Andric   void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
680eae32dcSDimitry Andric                            llvm::opt::ArgStringList &CC1Args) const override;
690eae32dcSDimitry Andric   void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
700eae32dcSDimitry Andric                          llvm::opt::ArgStringList &CC1Args) const override;
710eae32dcSDimitry Andric   llvm::SmallVector<BitCodeLibraryInfo, 12>
72bdd1243dSDimitry Andric   getDeviceLibs(const llvm::opt::ArgList &Args) const override;
730eae32dcSDimitry Andric 
740eae32dcSDimitry Andric   SanitizerMask getSupportedSanitizers() const override;
750eae32dcSDimitry Andric 
760eae32dcSDimitry Andric   VersionTuple
770eae32dcSDimitry Andric   computeMSVCVersion(const Driver *D,
780eae32dcSDimitry Andric                      const llvm::opt::ArgList &Args) const override;
790eae32dcSDimitry Andric 
8006c3fb27SDimitry Andric   void adjustDebugInfoKind(llvm::codegenoptions::DebugInfoKind &DebugInfoKind,
810eae32dcSDimitry Andric                            const llvm::opt::ArgList &Args) const override;
820eae32dcSDimitry Andric   bool IsMathErrnoDefault() const override { return false; }
830eae32dcSDimitry Andric   bool useIntegratedAs() const override { return true; }
840eae32dcSDimitry Andric   bool isCrossCompiling() const override { return true; }
850eae32dcSDimitry Andric   bool isPICDefault() const override { return false; }
860eae32dcSDimitry Andric   bool isPIEDefault(const llvm::opt::ArgList &Args) const override {
870eae32dcSDimitry Andric     return false;
880eae32dcSDimitry Andric   }
890eae32dcSDimitry Andric   bool isPICDefaultForced() const override { return false; }
900eae32dcSDimitry Andric   bool SupportsProfiling() const override { return false; }
910eae32dcSDimitry Andric 
920eae32dcSDimitry Andric   const ToolChain &HostTC;
930eae32dcSDimitry Andric 
940eae32dcSDimitry Andric protected:
950eae32dcSDimitry Andric   Tool *buildLinker() const override;
960eae32dcSDimitry Andric };
970eae32dcSDimitry Andric 
980eae32dcSDimitry Andric } // end namespace toolchains
990eae32dcSDimitry Andric } // end namespace driver
1000eae32dcSDimitry Andric } // end namespace clang
1010eae32dcSDimitry Andric 
1020eae32dcSDimitry Andric #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPSPV_H
103