AMDGPUOpenMP.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //===- AMDGPUOpenMP.h - AMDGPUOpenMP ToolChain Implementation -*- 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_AMDGPUOPENMP_H
  9. #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AMDGPUOPENMP_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 toolchains {
  16. class AMDGPUOpenMPToolChain;
  17. }
  18. namespace tools {
  19. namespace AMDGCN {
  20. // Runs llvm-link/opt/llc/lld, which links multiple LLVM bitcode, together with
  21. // device library, then compiles it to ISA in a shared object.
  22. class LLVM_LIBRARY_VISIBILITY OpenMPLinker : public Tool {
  23. public:
  24. OpenMPLinker(const ToolChain &TC)
  25. : Tool("AMDGCN::OpenMPLinker", "amdgcn-link", TC) {}
  26. bool hasIntegratedCPP() const override { return false; }
  27. void ConstructJob(Compilation &C, const JobAction &JA,
  28. const InputInfo &Output, const InputInfoList &Inputs,
  29. const llvm::opt::ArgList &TCArgs,
  30. const char *LinkingOutput) const override;
  31. private:
  32. /// \return llvm-link output file name.
  33. const char *constructLLVMLinkCommand(
  34. const toolchains::AMDGPUOpenMPToolChain &AMDGPUOpenMPTC, Compilation &C,
  35. const JobAction &JA, const InputInfoList &Inputs,
  36. const llvm::opt::ArgList &Args, llvm::StringRef SubArchName,
  37. llvm::StringRef OutputFilePrefix) const;
  38. /// \return llc output file name.
  39. const char *constructLlcCommand(Compilation &C, const JobAction &JA,
  40. const InputInfoList &Inputs,
  41. const llvm::opt::ArgList &Args,
  42. llvm::StringRef SubArchName,
  43. llvm::StringRef OutputFilePrefix,
  44. const char *InputFileName,
  45. bool OutputIsAsm = false) const;
  46. void constructLldCommand(Compilation &C, const JobAction &JA,
  47. const InputInfoList &Inputs, const InputInfo &Output,
  48. const llvm::opt::ArgList &Args,
  49. const char *InputFileName) const;
  50. };
  51. } // end namespace AMDGCN
  52. } // end namespace tools
  53. namespace toolchains {
  54. class LLVM_LIBRARY_VISIBILITY AMDGPUOpenMPToolChain final
  55. : public ROCMToolChain {
  56. public:
  57. AMDGPUOpenMPToolChain(const Driver &D, const llvm::Triple &Triple,
  58. const ToolChain &HostTC,
  59. const llvm::opt::ArgList &Args);
  60. const llvm::Triple *getAuxTriple() const override {
  61. return &HostTC.getTriple();
  62. }
  63. llvm::opt::DerivedArgList *
  64. TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
  65. Action::OffloadKind DeviceOffloadKind) const override;
  66. void
  67. addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
  68. llvm::opt::ArgStringList &CC1Args,
  69. Action::OffloadKind DeviceOffloadKind) const override;
  70. void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override;
  71. CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
  72. void
  73. AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
  74. llvm::opt::ArgStringList &CC1Args) const override;
  75. void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
  76. llvm::opt::ArgStringList &CC1Args) const override;
  77. SanitizerMask getSupportedSanitizers() const override;
  78. VersionTuple
  79. computeMSVCVersion(const Driver *D,
  80. const llvm::opt::ArgList &Args) const override;
  81. const ToolChain &HostTC;
  82. protected:
  83. Tool *buildLinker() const override;
  84. };
  85. } // end namespace toolchains
  86. } // end namespace driver
  87. } // end namespace clang
  88. #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AMDGPUOPENMP_H