HIPSPV.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //===--- HIPSPV.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_HIPSPV_H
  9. #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPSPV_H
  10. #include "SPIRV.h"
  11. #include "clang/Driver/Tool.h"
  12. #include "clang/Driver/ToolChain.h"
  13. namespace clang {
  14. namespace driver {
  15. namespace tools {
  16. namespace HIPSPV {
  17. // Runs llvm-link/opt/llc/lld, which links multiple LLVM bitcode, together with
  18. // device library, then compiles it to SPIR-V in a shared object.
  19. class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
  20. public:
  21. Linker(const ToolChain &TC) : Tool("HIPSPV::Linker", "hipspv-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 constructLinkAndEmitSpirvCommand(Compilation &C, const JobAction &JA,
  29. const InputInfoList &Inputs,
  30. const InputInfo &Output,
  31. const llvm::opt::ArgList &Args) const;
  32. };
  33. } // namespace HIPSPV
  34. } // namespace tools
  35. namespace toolchains {
  36. class LLVM_LIBRARY_VISIBILITY HIPSPVToolChain final : public ToolChain {
  37. public:
  38. HIPSPVToolChain(const Driver &D, const llvm::Triple &Triple,
  39. const ToolChain &HostTC, const llvm::opt::ArgList &Args);
  40. const llvm::Triple *getAuxTriple() const override {
  41. return &HostTC.getTriple();
  42. }
  43. void
  44. addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
  45. llvm::opt::ArgStringList &CC1Args,
  46. Action::OffloadKind DeviceOffloadKind) const override;
  47. void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override;
  48. CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
  49. void
  50. AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
  51. llvm::opt::ArgStringList &CC1Args) const override;
  52. void AddClangCXXStdlibIncludeArgs(
  53. const llvm::opt::ArgList &Args,
  54. llvm::opt::ArgStringList &CC1Args) const override;
  55. void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
  56. llvm::opt::ArgStringList &CC1Args) const override;
  57. void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
  58. llvm::opt::ArgStringList &CC1Args) const override;
  59. llvm::SmallVector<BitCodeLibraryInfo, 12>
  60. getDeviceLibs(const llvm::opt::ArgList &Args) const override;
  61. SanitizerMask getSupportedSanitizers() const override;
  62. VersionTuple
  63. computeMSVCVersion(const Driver *D,
  64. const llvm::opt::ArgList &Args) const override;
  65. void adjustDebugInfoKind(codegenoptions::DebugInfoKind &DebugInfoKind,
  66. const llvm::opt::ArgList &Args) const override;
  67. bool IsIntegratedAssemblerDefault() const override { return true; }
  68. bool IsMathErrnoDefault() const override { return false; }
  69. bool useIntegratedAs() const override { return true; }
  70. bool isCrossCompiling() const override { return true; }
  71. bool isPICDefault() const override { return false; }
  72. bool isPIEDefault(const llvm::opt::ArgList &Args) const override {
  73. return false;
  74. }
  75. bool isPICDefaultForced() const override { return false; }
  76. bool SupportsProfiling() const override { return false; }
  77. const ToolChain &HostTC;
  78. protected:
  79. Tool *buildLinker() const override;
  80. };
  81. } // end namespace toolchains
  82. } // end namespace driver
  83. } // end namespace clang
  84. #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPSPV_H