clang 22.0.0git
HLSL.h
Go to the documentation of this file.
1//===--- HLSL.h - HLSL ToolChain 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_HLSL_H
10#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HLSL_H
11
12#include "clang/Driver/Tool.h"
14
15namespace clang {
16namespace driver {
17
18namespace tools {
19
20namespace hlsl {
21class LLVM_LIBRARY_VISIBILITY Validator : public Tool {
22public:
23 Validator(const ToolChain &TC) : Tool("hlsl::Validator", "dxv", TC) {}
24
25 bool hasIntegratedCPP() const override { return false; }
26
27 void ConstructJob(Compilation &C, const JobAction &JA,
28 const InputInfo &Output, const InputInfoList &Inputs,
29 const llvm::opt::ArgList &TCArgs,
30 const char *LinkingOutput) const override;
31};
32
33class LLVM_LIBRARY_VISIBILITY MetalConverter : public Tool {
34public:
36 : Tool("hlsl::MetalConverter", "metal-shaderconverter", TC) {}
37
38 bool hasIntegratedCPP() const override { return false; }
39
40 void ConstructJob(Compilation &C, const JobAction &JA,
41 const InputInfo &Output, const InputInfoList &Inputs,
42 const llvm::opt::ArgList &TCArgs,
43 const char *LinkingOutput) const override;
44};
45
46class LLVM_LIBRARY_VISIBILITY LLVMObjcopy : public Tool {
47public:
49 : Tool("hlsl::LLVMObjcopy", "llvm-objcopy", TC) {}
50
51 bool hasIntegratedCPP() const override { return false; }
52
53 void ConstructJob(Compilation &C, const JobAction &JA,
54 const InputInfo &Output, const InputInfoList &Inputs,
55 const llvm::opt::ArgList &TCArgs,
56 const char *LinkingOutput) const override;
57};
58
59} // namespace hlsl
60} // namespace tools
61
62namespace toolchains {
63
64class LLVM_LIBRARY_VISIBILITY HLSLToolChain : public ToolChain {
65public:
66 HLSLToolChain(const Driver &D, const llvm::Triple &Triple,
67 const llvm::opt::ArgList &Args);
68 Tool *getTool(Action::ActionClass AC) const override;
69
70 bool isPICDefault() const override { return false; }
71 bool isPIEDefault(const llvm::opt::ArgList &Args) const override {
72 return false;
73 }
74 bool isPICDefaultForced() const override { return false; }
75
76 llvm::opt::DerivedArgList *
77 TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
78 Action::OffloadKind DeviceOffloadKind) const override;
79 static std::optional<std::string> parseTargetProfile(StringRef TargetProfile);
80 bool requiresValidation(llvm::opt::DerivedArgList &Args) const;
81 bool requiresBinaryTranslation(llvm::opt::DerivedArgList &Args) const;
82 bool requiresObjcopy(llvm::opt::DerivedArgList &Args) const;
83
84 /// If we are targeting DXIL then the last job should output the DXContainer
85 /// to the specified output file with /Fo. Otherwise, we will emit to a
86 /// temporary file for the next job to use.
87 ///
88 /// Returns true if we should output to the final result file.
89 bool isLastJob(llvm::opt::DerivedArgList &Args, Action::ActionClass AC) const;
90
91 // Set default DWARF version to 4 for DXIL uses version 4.
92 unsigned GetDefaultDwarfVersion() const override { return 4; }
93
94private:
95 mutable std::unique_ptr<tools::hlsl::Validator> Validator;
96 mutable std::unique_ptr<tools::hlsl::MetalConverter> MetalConverter;
97 mutable std::unique_ptr<tools::hlsl::LLVMObjcopy> LLVMObjcopy;
98};
99
100} // end namespace toolchains
101} // end namespace driver
102} // end namespace clang
103
104#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HLSL_H
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
unsigned GetDefaultDwarfVersion() const override
Definition: HLSL.h:92
bool isPICDefault() const override
Test whether this toolchain defaults to PIC.
Definition: HLSL.h:70
bool isPIEDefault(const llvm::opt::ArgList &Args) const override
Test whether this toolchain defaults to PIE.
Definition: HLSL.h:71
bool isPICDefaultForced() const override
Tests whether this toolchain forces its default for PIC, PIE or non-PIC.
Definition: HLSL.h:74
LLVMObjcopy(const ToolChain &TC)
Definition: HLSL.h:48
bool hasIntegratedCPP() const override
Definition: HLSL.h:51
MetalConverter(const ToolChain &TC)
Definition: HLSL.h:35
bool hasIntegratedCPP() const override
Definition: HLSL.h:38
bool hasIntegratedCPP() const override
Definition: HLSL.h:25
Validator(const ToolChain &TC)
Definition: HLSL.h:23
The JSON file list parser is used to communicate input to InstallAPI.