SPIRV.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //===--- SPIRV.h - SPIR-V Tool 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_SPIRV_H
  9. #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_SPIRV_H
  10. #include "clang/Driver/Tool.h"
  11. #include "clang/Driver/ToolChain.h"
  12. namespace clang {
  13. namespace driver {
  14. namespace tools {
  15. namespace SPIRV {
  16. void addTranslatorArgs(const llvm::opt::ArgList &InArgs,
  17. llvm::opt::ArgStringList &OutArgs);
  18. void constructTranslateCommand(Compilation &C, const Tool &T,
  19. const JobAction &JA, const InputInfo &Output,
  20. const InputInfo &Input,
  21. const llvm::opt::ArgStringList &Args);
  22. class LLVM_LIBRARY_VISIBILITY Translator : public Tool {
  23. public:
  24. Translator(const ToolChain &TC)
  25. : Tool("SPIR-V::Translator", "llvm-spirv", TC) {}
  26. bool hasIntegratedCPP() const override { return false; }
  27. bool hasIntegratedAssembler() const override { return true; }
  28. void ConstructJob(Compilation &C, const JobAction &JA,
  29. const InputInfo &Output, const InputInfoList &Inputs,
  30. const llvm::opt::ArgList &TCArgs,
  31. const char *LinkingOutput) const override;
  32. };
  33. class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
  34. public:
  35. Linker(const ToolChain &TC) : Tool("SPIRV::Linker", "spirv-link", TC) {}
  36. bool hasIntegratedCPP() const override { return false; }
  37. bool isLinkJob() const override { return true; }
  38. void ConstructJob(Compilation &C, const JobAction &JA,
  39. const InputInfo &Output, const InputInfoList &Inputs,
  40. const llvm::opt::ArgList &TCArgs,
  41. const char *LinkingOutput) const override;
  42. };
  43. } // namespace SPIRV
  44. } // namespace tools
  45. namespace toolchains {
  46. class LLVM_LIBRARY_VISIBILITY SPIRVToolChain final : public ToolChain {
  47. mutable std::unique_ptr<Tool> Translator;
  48. public:
  49. SPIRVToolChain(const Driver &D, const llvm::Triple &Triple,
  50. const llvm::opt::ArgList &Args)
  51. : ToolChain(D, Triple, Args) {}
  52. bool useIntegratedAs() const override { return true; }
  53. bool IsIntegratedBackendDefault() const override { return false; }
  54. bool IsNonIntegratedBackendSupported() const override { return true; }
  55. bool IsMathErrnoDefault() const override { return false; }
  56. bool isCrossCompiling() const override { return true; }
  57. bool isPICDefault() const override { return false; }
  58. bool isPIEDefault(const llvm::opt::ArgList &Args) const override {
  59. return false;
  60. }
  61. bool isPICDefaultForced() const override { return false; }
  62. bool SupportsProfiling() const override { return false; }
  63. clang::driver::Tool *SelectTool(const JobAction &JA) const override;
  64. protected:
  65. clang::driver::Tool *getTool(Action::ActionClass AC) const override;
  66. Tool *buildLinker() const override;
  67. private:
  68. clang::driver::Tool *getTranslator() const;
  69. };
  70. } // namespace toolchains
  71. } // namespace driver
  72. } // namespace clang
  73. #endif