HIPAMD.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //===--- HIPAMD.h - HIP ToolChain Implementations ---------------*- 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. #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPAMD_H
  9. #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPAMD_H
  10. #include "AMDGPU.h"
  11. #include "clang/Driver/Tool.h"
  12. #include "clang/Driver/ToolChain.h"
  13. namespace clang {
  14. namespace driver {
  15. namespace tools {
  16. namespace AMDGCN {
  17. // Runs llvm-link/opt/llc/lld, which links multiple LLVM bitcode, together with
  18. // device library, then compiles it to ISA in a shared object.
  19. class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
  20. public:
  21. Linker(const ToolChain &TC) : Tool("AMDGCN::Linker", "amdgcn-link", TC) {}
  22. bool hasIntegratedCPP() const override { return false; }
  23. void ConstructJob(Compilation &C, const JobAction &JA,
  24. const InputInfo &Output, const InputInfoList &Inputs,
  25. const llvm::opt::ArgList &TCArgs,
  26. const char *LinkingOutput) const override;
  27. private:
  28. void constructLldCommand(Compilation &C, const JobAction &JA,
  29. const InputInfoList &Inputs, const InputInfo &Output,
  30. const llvm::opt::ArgList &Args) const;
  31. };
  32. } // end namespace AMDGCN
  33. } // end namespace tools
  34. namespace toolchains {
  35. class LLVM_LIBRARY_VISIBILITY HIPAMDToolChain final : public ROCMToolChain {
  36. public:
  37. HIPAMDToolChain(const Driver &D, const llvm::Triple &Triple,
  38. const ToolChain &HostTC, const llvm::opt::ArgList &Args);
  39. const llvm::Triple *getAuxTriple() const override {
  40. return &HostTC.getTriple();
  41. }
  42. llvm::opt::DerivedArgList *
  43. TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
  44. Action::OffloadKind DeviceOffloadKind) const override;
  45. void
  46. addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
  47. llvm::opt::ArgStringList &CC1Args,
  48. Action::OffloadKind DeviceOffloadKind) const override;
  49. void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override;
  50. CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
  51. void
  52. AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
  53. llvm::opt::ArgStringList &CC1Args) const override;
  54. void AddClangCXXStdlibIncludeArgs(
  55. const llvm::opt::ArgList &Args,
  56. llvm::opt::ArgStringList &CC1Args) const override;
  57. void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
  58. llvm::opt::ArgStringList &CC1Args) const override;
  59. void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
  60. llvm::opt::ArgStringList &CC1Args) const override;
  61. llvm::SmallVector<BitCodeLibraryInfo, 12>
  62. getHIPDeviceLibs(const llvm::opt::ArgList &Args) const override;
  63. SanitizerMask getSupportedSanitizers() const override;
  64. VersionTuple
  65. computeMSVCVersion(const Driver *D,
  66. const llvm::opt::ArgList &Args) const override;
  67. unsigned GetDefaultDwarfVersion() const override { return 5; }
  68. const ToolChain &HostTC;
  69. void checkTargetID(const llvm::opt::ArgList &DriverArgs) const override;
  70. protected:
  71. Tool *buildLinker() const override;
  72. };
  73. } // end namespace toolchains
  74. } // end namespace driver
  75. } // end namespace clang
  76. #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPAMD_H