LLVM 24.0.0git
RootSignatureMetadata.h
Go to the documentation of this file.
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/ADT/StringRef.h"
19#include "llvm/IR/Constants.h"
20#include "llvm/IR/Module.h"
23
24namespace llvm {
25class LLVMContext;
26class MDNode;
27class Metadata;
28
29namespace hlsl {
30namespace rootsig {
32 : public ErrorInfo<RootSignatureValidationError> {
33public:
34 LLVM_ABI static char ID;
35 std::string Msg;
36
38
39 void log(raw_ostream &OS) const override { OS << Msg; }
40
41 std::error_code convertToErrorCode() const override {
43 }
44};
45
47public:
49 : M(M), Ctx(M.getContext()), Elements(Elements) {}
50
51 /// Iterates through elements and dispatches onto the correct Build* method
52 ///
53 /// Accumulates the root signature and returns the Metadata node that is just
54 /// a list of all the elements
56
57private:
58 /// Define the various builders for the different metadata types
59 MDNode *BuildRootFlags(const dxbc::RootFlags &Flags);
60 MDNode *BuildRootConstants(const RootConstants &Constants);
61 MDNode *BuildRootDescriptor(const RootDescriptor &Descriptor);
62 MDNode *BuildDescriptorTable(const DescriptorTable &Table);
63 MDNode *BuildDescriptorTableClause(const DescriptorTableClause &Clause);
64 MDNode *BuildStaticSampler(const StaticSampler &Sampler);
65
66 llvm::Module &M;
68 ArrayRef<RootElement> Elements;
69 SmallVector<Metadata *> GeneratedMetadata;
70};
71
82
84public:
85 MetadataParser(MDNode *Root) : Root(Root) {}
86
89
90private:
91 llvm::Error parseRootFlags(mcdxbc::RootSignatureDesc &RSD,
92 MDNode *RootFlagNode);
93 llvm::Error parseRootConstants(mcdxbc::RootSignatureDesc &RSD,
94 MDNode *RootConstantNode);
95 llvm::Error parseRootDescriptors(mcdxbc::RootSignatureDesc &RSD,
96 MDNode *RootDescriptorNode,
97 RootSignatureElementKind ElementKind);
98 llvm::Error parseDescriptorRange(mcdxbc::DescriptorTable &Table,
99 MDNode *RangeDescriptorNode);
100 llvm::Error parseDescriptorTable(mcdxbc::RootSignatureDesc &RSD,
101 MDNode *DescriptorTableNode);
102 llvm::Error parseRootSignatureElement(mcdxbc::RootSignatureDesc &RSD,
103 MDNode *Element);
104 llvm::Error parseStaticSampler(mcdxbc::RootSignatureDesc &RSD,
105 MDNode *StaticSamplerNode);
106
108
109 MDNode *Root;
110};
111
112} // namespace rootsig
113} // namespace hlsl
114} // namespace llvm
115
116#endif // LLVM_FRONTEND_HLSL_ROOTSIGNATUREMETADATA_H
#define LLVM_ABI
Definition Compiler.h:215
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static void validateRootSignature(Module &M, const mcdxbc::RootSignatureDesc &RSD, dxil::ModuleMetadataInfo &MMI, DXILResourceMap &DRM, DXILResourceTypeMap &DRTM)
Module.h This file contains the declarations for the Module class.
Func getContext().diagnose(DiagnosticInfoUnsupported(Func
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Base class for user error types.
Definition Error.h:354
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
Tagged union holding either a T or a Error.
Definition Error.h:485
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
Metadata node.
Definition Metadata.h:1081
Root of the metadata hierarchy.
Definition Metadata.h:64
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
MetadataBuilder(llvm::Module &M, ArrayRef< RootElement > Elements)
LLVM_ABI MDNode * BuildRootSignature()
Iterates through elements and dispatches onto the correct Build* method.
LLVM_ABI llvm::Expected< llvm::mcdxbc::RootSignatureDesc > ParseRootSignature(uint32_t Version)
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
void log(raw_ostream &OS) const override
Print an error message to an output stream.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition Error.cpp:94