1349cc55cSDimitry Andric //===--- SPIRV.h - SPIR-V Tool Implementations ------------------*- C++ -*-===// 2349cc55cSDimitry Andric // 3349cc55cSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4349cc55cSDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5349cc55cSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6349cc55cSDimitry Andric // 7349cc55cSDimitry Andric //===----------------------------------------------------------------------===// 8349cc55cSDimitry Andric 9349cc55cSDimitry Andric #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_SPIRV_H 10349cc55cSDimitry Andric #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_SPIRV_H 11349cc55cSDimitry Andric 12349cc55cSDimitry Andric #include "clang/Driver/Tool.h" 13349cc55cSDimitry Andric #include "clang/Driver/ToolChain.h" 14349cc55cSDimitry Andric 15349cc55cSDimitry Andric namespace clang { 16349cc55cSDimitry Andric namespace driver { 17349cc55cSDimitry Andric namespace tools { 18349cc55cSDimitry Andric namespace SPIRV { 19349cc55cSDimitry Andric 20349cc55cSDimitry Andric void constructTranslateCommand(Compilation &C, const Tool &T, 21349cc55cSDimitry Andric const JobAction &JA, const InputInfo &Output, 22349cc55cSDimitry Andric const InputInfo &Input, 23349cc55cSDimitry Andric const llvm::opt::ArgStringList &Args); 24349cc55cSDimitry Andric 25349cc55cSDimitry Andric class LLVM_LIBRARY_VISIBILITY Translator : public Tool { 26349cc55cSDimitry Andric public: Translator(const ToolChain & TC)27349cc55cSDimitry Andric Translator(const ToolChain &TC) 28349cc55cSDimitry Andric : Tool("SPIR-V::Translator", "llvm-spirv", TC) {} 29349cc55cSDimitry Andric hasIntegratedCPP()30349cc55cSDimitry Andric bool hasIntegratedCPP() const override { return false; } hasIntegratedAssembler()31349cc55cSDimitry Andric bool hasIntegratedAssembler() const override { return true; } 32349cc55cSDimitry Andric 33349cc55cSDimitry Andric void ConstructJob(Compilation &C, const JobAction &JA, 34349cc55cSDimitry Andric const InputInfo &Output, const InputInfoList &Inputs, 35349cc55cSDimitry Andric const llvm::opt::ArgList &TCArgs, 36349cc55cSDimitry Andric const char *LinkingOutput) const override; 37349cc55cSDimitry Andric }; 38349cc55cSDimitry Andric 39*5f757f3fSDimitry Andric class LLVM_LIBRARY_VISIBILITY Linker final : public Tool { 4004eeddc0SDimitry Andric public: Linker(const ToolChain & TC)4104eeddc0SDimitry Andric Linker(const ToolChain &TC) : Tool("SPIRV::Linker", "spirv-link", TC) {} hasIntegratedCPP()4204eeddc0SDimitry Andric bool hasIntegratedCPP() const override { return false; } isLinkJob()4304eeddc0SDimitry Andric bool isLinkJob() const override { return true; } 4404eeddc0SDimitry Andric void ConstructJob(Compilation &C, const JobAction &JA, 4504eeddc0SDimitry Andric const InputInfo &Output, const InputInfoList &Inputs, 4604eeddc0SDimitry Andric const llvm::opt::ArgList &TCArgs, 4704eeddc0SDimitry Andric const char *LinkingOutput) const override; 4804eeddc0SDimitry Andric }; 4904eeddc0SDimitry Andric 50349cc55cSDimitry Andric } // namespace SPIRV 51349cc55cSDimitry Andric } // namespace tools 520eae32dcSDimitry Andric 530eae32dcSDimitry Andric namespace toolchains { 540eae32dcSDimitry Andric 550eae32dcSDimitry Andric class LLVM_LIBRARY_VISIBILITY SPIRVToolChain final : public ToolChain { 560eae32dcSDimitry Andric mutable std::unique_ptr<Tool> Translator; 570eae32dcSDimitry Andric 580eae32dcSDimitry Andric public: SPIRVToolChain(const Driver & D,const llvm::Triple & Triple,const llvm::opt::ArgList & Args)590eae32dcSDimitry Andric SPIRVToolChain(const Driver &D, const llvm::Triple &Triple, 600eae32dcSDimitry Andric const llvm::opt::ArgList &Args) 610eae32dcSDimitry Andric : ToolChain(D, Triple, Args) {} 620eae32dcSDimitry Andric useIntegratedAs()630eae32dcSDimitry Andric bool useIntegratedAs() const override { return true; } 640eae32dcSDimitry Andric IsIntegratedBackendDefault()6581ad6265SDimitry Andric bool IsIntegratedBackendDefault() const override { return false; } IsNonIntegratedBackendSupported()6681ad6265SDimitry Andric bool IsNonIntegratedBackendSupported() const override { return true; } IsMathErrnoDefault()670eae32dcSDimitry Andric bool IsMathErrnoDefault() const override { return false; } isCrossCompiling()680eae32dcSDimitry Andric bool isCrossCompiling() const override { return true; } isPICDefault()690eae32dcSDimitry Andric bool isPICDefault() const override { return false; } isPIEDefault(const llvm::opt::ArgList & Args)700eae32dcSDimitry Andric bool isPIEDefault(const llvm::opt::ArgList &Args) const override { 710eae32dcSDimitry Andric return false; 720eae32dcSDimitry Andric } isPICDefaultForced()730eae32dcSDimitry Andric bool isPICDefaultForced() const override { return false; } SupportsProfiling()740eae32dcSDimitry Andric bool SupportsProfiling() const override { return false; } 750eae32dcSDimitry Andric 760eae32dcSDimitry Andric clang::driver::Tool *SelectTool(const JobAction &JA) const override; 770eae32dcSDimitry Andric 780eae32dcSDimitry Andric protected: 790eae32dcSDimitry Andric clang::driver::Tool *getTool(Action::ActionClass AC) const override; 8004eeddc0SDimitry Andric Tool *buildLinker() const override; 810eae32dcSDimitry Andric 820eae32dcSDimitry Andric private: 830eae32dcSDimitry Andric clang::driver::Tool *getTranslator() const; 840eae32dcSDimitry Andric }; 850eae32dcSDimitry Andric 860eae32dcSDimitry Andric } // namespace toolchains 87349cc55cSDimitry Andric } // namespace driver 88349cc55cSDimitry Andric } // namespace clang 89349cc55cSDimitry Andric #endif 90