17330f729Sjoerg //===--- HIP.h - HIP ToolChain Implementations ------------------*- C++ -*-===// 27330f729Sjoerg // 37330f729Sjoerg // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 47330f729Sjoerg // See https://llvm.org/LICENSE.txt for license information. 57330f729Sjoerg // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 67330f729Sjoerg // 77330f729Sjoerg //===----------------------------------------------------------------------===// 87330f729Sjoerg 97330f729Sjoerg #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIP_H 107330f729Sjoerg #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIP_H 117330f729Sjoerg 127330f729Sjoerg #include "clang/Driver/ToolChain.h" 137330f729Sjoerg #include "clang/Driver/Tool.h" 14*e038c9c4Sjoerg #include "AMDGPU.h" 157330f729Sjoerg 167330f729Sjoerg namespace clang { 177330f729Sjoerg namespace driver { 187330f729Sjoerg 197330f729Sjoerg namespace tools { 207330f729Sjoerg 217330f729Sjoerg namespace AMDGCN { 227330f729Sjoerg // Construct command for creating HIP fatbin. 237330f729Sjoerg void constructHIPFatbinCommand(Compilation &C, const JobAction &JA, 247330f729Sjoerg StringRef OutputFileName, const InputInfoList &Inputs, 257330f729Sjoerg const llvm::opt::ArgList &TCArgs, const Tool& T); 267330f729Sjoerg 277330f729Sjoerg // Runs llvm-link/opt/llc/lld, which links multiple LLVM bitcode, together with 287330f729Sjoerg // device library, then compiles it to ISA in a shared object. 297330f729Sjoerg class LLVM_LIBRARY_VISIBILITY Linker : public Tool { 307330f729Sjoerg public: Linker(const ToolChain & TC)317330f729Sjoerg Linker(const ToolChain &TC) : Tool("AMDGCN::Linker", "amdgcn-link", TC) {} 327330f729Sjoerg hasIntegratedCPP()337330f729Sjoerg bool hasIntegratedCPP() const override { return false; } 347330f729Sjoerg 357330f729Sjoerg void ConstructJob(Compilation &C, const JobAction &JA, 367330f729Sjoerg const InputInfo &Output, const InputInfoList &Inputs, 377330f729Sjoerg const llvm::opt::ArgList &TCArgs, 387330f729Sjoerg const char *LinkingOutput) const override; 397330f729Sjoerg 407330f729Sjoerg private: 417330f729Sjoerg 427330f729Sjoerg void constructLldCommand(Compilation &C, const JobAction &JA, 437330f729Sjoerg const InputInfoList &Inputs, const InputInfo &Output, 44*e038c9c4Sjoerg const llvm::opt::ArgList &Args) const; 45*e038c9c4Sjoerg 46*e038c9c4Sjoerg // Construct command for creating Object from HIP fatbin. 47*e038c9c4Sjoerg void constructGenerateObjFileFromHIPFatBinary(Compilation &C, 48*e038c9c4Sjoerg const InputInfo &Output, 49*e038c9c4Sjoerg const InputInfoList &Inputs, 507330f729Sjoerg const llvm::opt::ArgList &Args, 51*e038c9c4Sjoerg const JobAction &JA) const; 527330f729Sjoerg }; 537330f729Sjoerg 547330f729Sjoerg } // end namespace AMDGCN 557330f729Sjoerg } // end namespace tools 567330f729Sjoerg 577330f729Sjoerg namespace toolchains { 587330f729Sjoerg 59*e038c9c4Sjoerg class LLVM_LIBRARY_VISIBILITY HIPToolChain final : public ROCMToolChain { 607330f729Sjoerg public: 617330f729Sjoerg HIPToolChain(const Driver &D, const llvm::Triple &Triple, 627330f729Sjoerg const ToolChain &HostTC, const llvm::opt::ArgList &Args); 637330f729Sjoerg getAuxTriple()647330f729Sjoerg const llvm::Triple *getAuxTriple() const override { 657330f729Sjoerg return &HostTC.getTriple(); 667330f729Sjoerg } 677330f729Sjoerg 687330f729Sjoerg llvm::opt::DerivedArgList * 697330f729Sjoerg TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch, 707330f729Sjoerg Action::OffloadKind DeviceOffloadKind) const override; 717330f729Sjoerg void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, 727330f729Sjoerg llvm::opt::ArgStringList &CC1Args, 737330f729Sjoerg Action::OffloadKind DeviceOffloadKind) const override; 747330f729Sjoerg void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override; 757330f729Sjoerg CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override; 767330f729Sjoerg void 777330f729Sjoerg AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, 787330f729Sjoerg llvm::opt::ArgStringList &CC1Args) const override; 797330f729Sjoerg void AddClangCXXStdlibIncludeArgs( 807330f729Sjoerg const llvm::opt::ArgList &Args, 817330f729Sjoerg llvm::opt::ArgStringList &CC1Args) const override; 827330f729Sjoerg void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs, 837330f729Sjoerg llvm::opt::ArgStringList &CC1Args) const override; 84*e038c9c4Sjoerg void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs, 85*e038c9c4Sjoerg llvm::opt::ArgStringList &CC1Args) const override; 86*e038c9c4Sjoerg llvm::SmallVector<std::string, 12> 87*e038c9c4Sjoerg getHIPDeviceLibs(const llvm::opt::ArgList &Args) const override; 887330f729Sjoerg 897330f729Sjoerg SanitizerMask getSupportedSanitizers() const override; 907330f729Sjoerg 917330f729Sjoerg VersionTuple 927330f729Sjoerg computeMSVCVersion(const Driver *D, 937330f729Sjoerg const llvm::opt::ArgList &Args) const override; 947330f729Sjoerg GetDefaultDwarfVersion()95*e038c9c4Sjoerg unsigned GetDefaultDwarfVersion() const override { return 4; } 967330f729Sjoerg 977330f729Sjoerg const ToolChain &HostTC; 987330f729Sjoerg 997330f729Sjoerg protected: 1007330f729Sjoerg Tool *buildLinker() const override; 1017330f729Sjoerg }; 1027330f729Sjoerg 1037330f729Sjoerg } // end namespace toolchains 1047330f729Sjoerg } // end namespace driver 1057330f729Sjoerg } // end namespace clang 1067330f729Sjoerg 1077330f729Sjoerg #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIP_H 108