xref: /freebsd/contrib/llvm-project/llvm/include/llvm/Frontend/HLSL/RootSignatureMetadata.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
1 //===- RootSignatureMetadata.h - HLSL Root Signature helpers --------------===//
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 /// \file This file contains a library for working with HLSL Root Signatures and
10 /// their metadata representation.
11 ///
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_FRONTEND_HLSL_ROOTSIGNATUREMETADATA_H
15 #define LLVM_FRONTEND_HLSL_ROOTSIGNATUREMETADATA_H
16 
17 #include "llvm/Frontend/HLSL/HLSLRootSignature.h"
18 
19 namespace llvm {
20 class LLVMContext;
21 class MDNode;
22 class Metadata;
23 
24 namespace hlsl {
25 namespace rootsig {
26 
27 class MetadataBuilder {
28 public:
MetadataBuilder(llvm::LLVMContext & Ctx,ArrayRef<RootElement> Elements)29   MetadataBuilder(llvm::LLVMContext &Ctx, ArrayRef<RootElement> Elements)
30       : Ctx(Ctx), Elements(Elements) {}
31 
32   /// Iterates through elements and dispatches onto the correct Build* method
33   ///
34   /// Accumulates the root signature and returns the Metadata node that is just
35   /// a list of all the elements
36   LLVM_ABI MDNode *BuildRootSignature();
37 
38 private:
39   /// Define the various builders for the different metadata types
40   MDNode *BuildRootFlags(const dxbc::RootFlags &Flags);
41   MDNode *BuildRootConstants(const RootConstants &Constants);
42   MDNode *BuildRootDescriptor(const RootDescriptor &Descriptor);
43   MDNode *BuildDescriptorTable(const DescriptorTable &Table);
44   MDNode *BuildDescriptorTableClause(const DescriptorTableClause &Clause);
45   MDNode *BuildStaticSampler(const StaticSampler &Sampler);
46 
47   llvm::LLVMContext &Ctx;
48   ArrayRef<RootElement> Elements;
49   SmallVector<Metadata *> GeneratedMetadata;
50 };
51 
52 } // namespace rootsig
53 } // namespace hlsl
54 } // namespace llvm
55 
56 #endif // LLVM_FRONTEND_HLSL_ROOTSIGNATUREMETADATA_H
57