clang 22.0.0git
SPIRV.h
Go to the documentation of this file.
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
9#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_SPIRV_H
10#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_SPIRV_H
11
12#include "clang/Driver/Tool.h"
14
15namespace clang {
16namespace driver {
17namespace tools {
18namespace SPIRV {
19
21 const JobAction &JA, const InputInfo &Output,
22 const InputInfo &Input,
23 const llvm::opt::ArgStringList &Args);
24
26 const JobAction &JA, const InputInfo &Output,
27 const InputInfo &Input,
28 const llvm::opt::ArgStringList &Args);
29
30class LLVM_LIBRARY_VISIBILITY Translator : public Tool {
31public:
33 : Tool("SPIR-V::Translator", "llvm-spirv", TC) {}
34
35 bool hasIntegratedCPP() const override { return false; }
36 bool hasIntegratedAssembler() const override { return true; }
37
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
44class LLVM_LIBRARY_VISIBILITY Linker final : public Tool {
45public:
46 Linker(const ToolChain &TC) : Tool("SPIR-V::Linker", "spirv-link", TC) {}
47 bool hasIntegratedCPP() const override { return false; }
48 bool isLinkJob() const override { return true; }
49 void ConstructJob(Compilation &C, const JobAction &JA,
50 const InputInfo &Output, const InputInfoList &Inputs,
51 const llvm::opt::ArgList &TCArgs,
52 const char *LinkingOutput) const override;
53};
54
55class LLVM_LIBRARY_VISIBILITY Assembler final : public Tool {
56public:
57 Assembler(const ToolChain &TC) : Tool("SPIR-V::Assembler", "spirv-as", TC) {}
58 bool hasIntegratedAssembler() const override { return false; }
59 bool hasIntegratedCPP() const override { return false; }
60 void ConstructJob(Compilation &C, const JobAction &JA,
61 const InputInfo &Output, const InputInfoList &Inputs,
62 const llvm::opt::ArgList &TCArgs,
63 const char *AssembleOutput) const override;
64};
65
66} // namespace SPIRV
67} // namespace tools
68
69namespace toolchains {
70
71class LLVM_LIBRARY_VISIBILITY SPIRVToolChain : public ToolChain {
72 mutable std::unique_ptr<Tool> Assembler;
73
74public:
75 SPIRVToolChain(const Driver &D, const llvm::Triple &Triple,
76 const llvm::opt::ArgList &Args);
77
78 bool useIntegratedAs() const override { return true; }
79
80 bool IsIntegratedBackendDefault() const override { return true; }
81 bool IsNonIntegratedBackendSupported() const override { return true; }
82 bool IsMathErrnoDefault() const override { return false; }
83 bool isCrossCompiling() const override { return true; }
84 bool isPICDefault() const override { return false; }
85 bool isPIEDefault(const llvm::opt::ArgList &Args) const override {
86 return false;
87 }
88 bool isPICDefaultForced() const override { return false; }
89 bool SupportsProfiling() const override { return false; }
90 bool HasNativeLLVMSupport() const override;
91
92 clang::driver::Tool *SelectTool(const JobAction &JA) const override;
93
94protected:
95 clang::driver::Tool *getTool(Action::ActionClass AC) const override;
96 Tool *buildLinker() const override;
97
98private:
99 clang::driver::Tool *getAssembler() const;
100
101 bool NativeLLVMSupport;
102};
103
104} // namespace toolchains
105} // namespace driver
106} // namespace clang
107#endif
const Decl * D
Compilation - A set of tasks to perform for a single driver invocation.
Definition: Compilation.h:45
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:99
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:22
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:92
Tool - Information on a specific compilation tool.
Definition: Tool.h:32
bool isPICDefault() const override
Test whether this toolchain defaults to PIC.
Definition: SPIRV.h:84
bool IsNonIntegratedBackendSupported() const override
IsNonIntegratedBackendSupported - Does this tool chain support -fno-integrated-objemitter.
Definition: SPIRV.h:81
bool useIntegratedAs() const override
Check if the toolchain should use the integrated assembler.
Definition: SPIRV.h:78
bool isPICDefaultForced() const override
Tests whether this toolchain forces its default for PIC, PIE or non-PIC.
Definition: SPIRV.h:88
bool IsMathErrnoDefault() const override
IsMathErrnoDefault - Does this tool chain use -fmath-errno by default.
Definition: SPIRV.h:82
bool IsIntegratedBackendDefault() const override
IsIntegratedBackendDefault - Does this tool chain enable -fintegrated-objemitter by default.
Definition: SPIRV.h:80
bool isPIEDefault(const llvm::opt::ArgList &Args) const override
Test whether this toolchain defaults to PIE.
Definition: SPIRV.h:85
bool isCrossCompiling() const override
Returns true if the toolchain is targeting a non-native architecture.
Definition: SPIRV.h:83
bool SupportsProfiling() const override
SupportsProfiling - Does this tool chain support -pg.
Definition: SPIRV.h:89
bool hasIntegratedAssembler() const override
Definition: SPIRV.h:58
bool hasIntegratedCPP() const override
Definition: SPIRV.h:59
Assembler(const ToolChain &TC)
Definition: SPIRV.h:57
bool isLinkJob() const override
Definition: SPIRV.h:48
Linker(const ToolChain &TC)
Definition: SPIRV.h:46
bool hasIntegratedCPP() const override
Definition: SPIRV.h:47
bool hasIntegratedAssembler() const override
Definition: SPIRV.h:36
bool hasIntegratedCPP() const override
Definition: SPIRV.h:35
Translator(const ToolChain &TC)
Definition: SPIRV.h:32
void constructAssembleCommand(Compilation &C, const Tool &T, const JobAction &JA, const InputInfo &Output, const InputInfo &Input, const llvm::opt::ArgStringList &Args)
Definition: SPIRV.cpp:48
void constructTranslateCommand(Compilation &C, const Tool &T, const JobAction &JA, const InputInfo &Output, const InputInfo &Input, const llvm::opt::ArgStringList &Args)
Definition: SPIRV.cpp:20
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T