SPIRV.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 useIntegratedBackend() const override { return false; }
  54. bool IsMathErrnoDefault() const override { return false; }
  55. bool isCrossCompiling() const override { return true; }
  56. bool isPICDefault() const override { return false; }
  57. bool isPIEDefault(const llvm::opt::ArgList &Args) const override {
  58. return false;
  59. }
  60. bool isPICDefaultForced() const override { return false; }
  61. bool SupportsProfiling() const override { return false; }
  62. clang::driver::Tool *SelectTool(const JobAction &JA) const override;
  63. protected:
  64. clang::driver::Tool *getTool(Action::ActionClass AC) const override;
  65. Tool *buildLinker() const override;
  66. private:
  67. clang::driver::Tool *getTranslator() const;
  68. };
  69. } // namespace toolchains
  70. } // namespace driver
  71. } // namespace clang
  72. #endif