10eae32dcSDimitry Andric //===--- HIPAMD.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_HIPAMD_H 100eae32dcSDimitry Andric #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPAMD_H 110eae32dcSDimitry Andric 120eae32dcSDimitry Andric #include "AMDGPU.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 190eae32dcSDimitry Andric namespace tools { 200eae32dcSDimitry Andric 210eae32dcSDimitry Andric namespace AMDGCN { 220eae32dcSDimitry Andric // Runs llvm-link/opt/llc/lld, which links multiple LLVM bitcode, together with 230eae32dcSDimitry Andric // device library, then compiles it to ISA in a shared object. 245f757f3fSDimitry Andric class LLVM_LIBRARY_VISIBILITY Linker final : public Tool { 250eae32dcSDimitry Andric public: Linker(const ToolChain & TC)260eae32dcSDimitry Andric Linker(const ToolChain &TC) : Tool("AMDGCN::Linker", "amdgcn-link", TC) {} 270eae32dcSDimitry Andric hasIntegratedCPP()280eae32dcSDimitry Andric bool hasIntegratedCPP() const override { return false; } 290eae32dcSDimitry Andric 300eae32dcSDimitry Andric void ConstructJob(Compilation &C, const JobAction &JA, 310eae32dcSDimitry Andric const InputInfo &Output, const InputInfoList &Inputs, 320eae32dcSDimitry Andric const llvm::opt::ArgList &TCArgs, 330eae32dcSDimitry Andric const char *LinkingOutput) const override; 340eae32dcSDimitry Andric 350eae32dcSDimitry Andric private: 360eae32dcSDimitry Andric void constructLldCommand(Compilation &C, const JobAction &JA, 370eae32dcSDimitry Andric const InputInfoList &Inputs, const InputInfo &Output, 380eae32dcSDimitry Andric const llvm::opt::ArgList &Args) const; 3981ad6265SDimitry Andric void constructLlvmLinkCommand(Compilation &C, const JobAction &JA, 4081ad6265SDimitry Andric const InputInfoList &Inputs, 4181ad6265SDimitry Andric const InputInfo &Output, 4281ad6265SDimitry Andric const llvm::opt::ArgList &Args) const; 43*0fca6ea1SDimitry Andric void constructLinkAndEmitSpirvCommand(Compilation &C, const JobAction &JA, 44*0fca6ea1SDimitry Andric const InputInfoList &Inputs, 45*0fca6ea1SDimitry Andric const InputInfo &Output, 46*0fca6ea1SDimitry Andric const llvm::opt::ArgList &Args) const; 470eae32dcSDimitry Andric }; 480eae32dcSDimitry Andric 490eae32dcSDimitry Andric } // end namespace AMDGCN 500eae32dcSDimitry Andric } // end namespace tools 510eae32dcSDimitry Andric 520eae32dcSDimitry Andric namespace toolchains { 530eae32dcSDimitry Andric 540eae32dcSDimitry Andric class LLVM_LIBRARY_VISIBILITY HIPAMDToolChain final : public ROCMToolChain { 550eae32dcSDimitry Andric public: 560eae32dcSDimitry Andric HIPAMDToolChain(const Driver &D, const llvm::Triple &Triple, 570eae32dcSDimitry Andric const ToolChain &HostTC, const llvm::opt::ArgList &Args); 580eae32dcSDimitry Andric getAuxTriple()590eae32dcSDimitry Andric const llvm::Triple *getAuxTriple() const override { 600eae32dcSDimitry Andric return &HostTC.getTriple(); 610eae32dcSDimitry Andric } 620eae32dcSDimitry Andric 630eae32dcSDimitry Andric llvm::opt::DerivedArgList * 640eae32dcSDimitry Andric TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch, 650eae32dcSDimitry Andric Action::OffloadKind DeviceOffloadKind) const override; 660eae32dcSDimitry Andric void 670eae32dcSDimitry Andric addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, 680eae32dcSDimitry Andric llvm::opt::ArgStringList &CC1Args, 690eae32dcSDimitry Andric Action::OffloadKind DeviceOffloadKind) const override; 700eae32dcSDimitry Andric void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override; 710eae32dcSDimitry Andric CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override; 720eae32dcSDimitry Andric void 730eae32dcSDimitry Andric AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, 740eae32dcSDimitry Andric llvm::opt::ArgStringList &CC1Args) const override; 750eae32dcSDimitry Andric void AddClangCXXStdlibIncludeArgs( 760eae32dcSDimitry Andric const llvm::opt::ArgList &Args, 770eae32dcSDimitry Andric llvm::opt::ArgStringList &CC1Args) const override; 780eae32dcSDimitry Andric void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs, 790eae32dcSDimitry Andric llvm::opt::ArgStringList &CC1Args) const override; 800eae32dcSDimitry Andric void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs, 810eae32dcSDimitry Andric llvm::opt::ArgStringList &CC1Args) const override; 820eae32dcSDimitry Andric llvm::SmallVector<BitCodeLibraryInfo, 12> 83bdd1243dSDimitry Andric getDeviceLibs(const llvm::opt::ArgList &Args) const override; 840eae32dcSDimitry Andric 850eae32dcSDimitry Andric SanitizerMask getSupportedSanitizers() const override; 860eae32dcSDimitry Andric 870eae32dcSDimitry Andric VersionTuple 880eae32dcSDimitry Andric computeMSVCVersion(const Driver *D, 890eae32dcSDimitry Andric const llvm::opt::ArgList &Args) const override; 900eae32dcSDimitry Andric GetDefaultDwarfVersion()910eae32dcSDimitry Andric unsigned GetDefaultDwarfVersion() const override { return 5; } 920eae32dcSDimitry Andric 930eae32dcSDimitry Andric const ToolChain &HostTC; 940eae32dcSDimitry Andric void checkTargetID(const llvm::opt::ArgList &DriverArgs) const override; 950eae32dcSDimitry Andric 960eae32dcSDimitry Andric protected: 970eae32dcSDimitry Andric Tool *buildLinker() const override; 980eae32dcSDimitry Andric }; 990eae32dcSDimitry Andric 1000eae32dcSDimitry Andric } // end namespace toolchains 1010eae32dcSDimitry Andric } // end namespace driver 1020eae32dcSDimitry Andric } // end namespace clang 1030eae32dcSDimitry Andric 1040eae32dcSDimitry Andric #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPAMD_H 105