1 //===--- SPIRV.h - SPIR-V Tool Implementations ------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_SPIRV_H
10 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_SPIRV_H
12 #include "clang/Driver/Tool.h"
13 #include "clang/Driver/ToolChain.h"
20 void addTranslatorArgs(const llvm::opt::ArgList
&InArgs
,
21 llvm::opt::ArgStringList
&OutArgs
);
23 void constructTranslateCommand(Compilation
&C
, const Tool
&T
,
24 const JobAction
&JA
, const InputInfo
&Output
,
25 const InputInfo
&Input
,
26 const llvm::opt::ArgStringList
&Args
);
28 class LLVM_LIBRARY_VISIBILITY Translator
: public Tool
{
30 Translator(const ToolChain
&TC
)
31 : Tool("SPIR-V::Translator", "llvm-spirv", TC
) {}
33 bool hasIntegratedCPP() const override
{ return false; }
34 bool hasIntegratedAssembler() const override
{ return true; }
36 void ConstructJob(Compilation
&C
, const JobAction
&JA
,
37 const InputInfo
&Output
, const InputInfoList
&Inputs
,
38 const llvm::opt::ArgList
&TCArgs
,
39 const char *LinkingOutput
) const override
;
42 class LLVM_LIBRARY_VISIBILITY Linker
: public Tool
{
44 Linker(const ToolChain
&TC
) : Tool("SPIRV::Linker", "spirv-link", TC
) {}
45 bool hasIntegratedCPP() const override
{ return false; }
46 bool isLinkJob() const override
{ return true; }
47 void ConstructJob(Compilation
&C
, const JobAction
&JA
,
48 const InputInfo
&Output
, const InputInfoList
&Inputs
,
49 const llvm::opt::ArgList
&TCArgs
,
50 const char *LinkingOutput
) const override
;
56 namespace toolchains
{
58 class LLVM_LIBRARY_VISIBILITY SPIRVToolChain final
: public ToolChain
{
59 mutable std::unique_ptr
<Tool
> Translator
;
62 SPIRVToolChain(const Driver
&D
, const llvm::Triple
&Triple
,
63 const llvm::opt::ArgList
&Args
)
64 : ToolChain(D
, Triple
, Args
) {}
66 bool useIntegratedAs() const override
{ return true; }
68 bool IsIntegratedBackendDefault() const override
{ return false; }
69 bool IsNonIntegratedBackendSupported() const override
{ return true; }
70 bool IsMathErrnoDefault() const override
{ return false; }
71 bool isCrossCompiling() const override
{ return true; }
72 bool isPICDefault() const override
{ return false; }
73 bool isPIEDefault(const llvm::opt::ArgList
&Args
) const override
{
76 bool isPICDefaultForced() const override
{ return false; }
77 bool SupportsProfiling() const override
{ return false; }
79 clang::driver::Tool
*SelectTool(const JobAction
&JA
) const override
;
82 clang::driver::Tool
*getTool(Action::ActionClass AC
) const override
;
83 Tool
*buildLinker() const override
;
86 clang::driver::Tool
*getTranslator() const;
89 } // namespace toolchains