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" |
13 | #include "clang/Driver/ToolChain.h" |
14 | |
15 | namespace clang { |
16 | namespace driver { |
17 | |
18 | namespace tools { |
19 | |
20 | namespace hlsl { |
21 | class LLVM_LIBRARY_VISIBILITY Validator : public Tool { |
22 | public: |
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 | |
33 | class LLVM_LIBRARY_VISIBILITY MetalConverter : public Tool { |
34 | public: |
35 | MetalConverter(const ToolChain &TC) |
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 | } // namespace hlsl |
46 | } // namespace tools |
47 | |
48 | namespace toolchains { |
49 | |
50 | class LLVM_LIBRARY_VISIBILITY HLSLToolChain : public ToolChain { |
51 | public: |
52 | HLSLToolChain(const Driver &D, const llvm::Triple &Triple, |
53 | const llvm::opt::ArgList &Args); |
54 | Tool *getTool(Action::ActionClass AC) const override; |
55 | |
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 | |
62 | llvm::opt::DerivedArgList * |
63 | TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch, |
64 | Action::OffloadKind DeviceOffloadKind) const override; |
65 | static std::optional<std::string> parseTargetProfile(StringRef TargetProfile); |
66 | bool requiresValidation(llvm::opt::DerivedArgList &Args) const; |
67 | bool requiresBinaryTranslation(llvm::opt::DerivedArgList &Args) const; |
68 | bool isLastJob(llvm::opt::DerivedArgList &Args, Action::ActionClass AC) const; |
69 | |
70 | // Set default DWARF version to 4 for DXIL uses version 4. |
71 | unsigned GetDefaultDwarfVersion() const override { return 4; } |
72 | |
73 | private: |
74 | mutable std::unique_ptr<tools::hlsl::Validator> Validator; |
75 | mutable std::unique_ptr<tools::hlsl::MetalConverter> MetalConverter; |
76 | }; |
77 | |
78 | } // end namespace toolchains |
79 | } // end namespace driver |
80 | } // end namespace clang |
81 | |
82 | #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HLSL_H |
83 | |