LLVM 22.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"
22
23namespace llvm {
24class LLVMContext;
25class MDNode;
26class Metadata;
27
28namespace hlsl {
29namespace rootsig {
31 : public ErrorInfo<RootSignatureValidationError> {
32public:
33 static char ID;
34 std::string Msg;
35
37
38 void log(raw_ostream &OS) const override { OS << Msg; }
39
40 std::error_code convertToErrorCode() const override {
42 }
43};
44
46public:
48 : Ctx(Ctx), Elements(Elements) {}
49
50 /// Iterates through elements and dispatches onto the correct Build* method
51 ///
52 /// Accumulates the root signature and returns the Metadata node that is just
53 /// a list of all the elements
55
56private:
57 /// Define the various builders for the different metadata types
58 MDNode *BuildRootFlags(const dxbc::RootFlags &Flags);
59 MDNode *BuildRootConstants(const RootConstants &Constants);
60 MDNode *BuildRootDescriptor(const RootDescriptor &Descriptor);
61 MDNode *BuildDescriptorTable(const DescriptorTable &Table);
62 MDNode *BuildDescriptorTableClause(const DescriptorTableClause &Clause);
63 MDNode *BuildStaticSampler(const StaticSampler &Sampler);
64
66 ArrayRef<RootElement> Elements;
67 SmallVector<Metadata *> GeneratedMetadata;
68};
69
80
82public:
83 MetadataParser(MDNode *Root) : Root(Root) {}
84
87
88private:
89 llvm::Error parseRootFlags(mcdxbc::RootSignatureDesc &RSD,
90 MDNode *RootFlagNode);
91 llvm::Error parseRootConstants(mcdxbc::RootSignatureDesc &RSD,
92 MDNode *RootConstantNode);
93 llvm::Error parseRootDescriptors(mcdxbc::RootSignatureDesc &RSD,
94 MDNode *RootDescriptorNode,
95 RootSignatureElementKind ElementKind);
96 llvm::Error parseDescriptorRange(mcdxbc::DescriptorTable &Table,
97 MDNode *RangeDescriptorNode);
98 llvm::Error parseDescriptorTable(mcdxbc::RootSignatureDesc &RSD,
99 MDNode *DescriptorTableNode);
100 llvm::Error parseRootSignatureElement(mcdxbc::RootSignatureDesc &RSD,
101 MDNode *Element);
102 llvm::Error parseStaticSampler(mcdxbc::RootSignatureDesc &RSD,
103 MDNode *StaticSamplerNode);
104
106
107 MDNode *Root;
108};
109
110} // namespace rootsig
111} // namespace hlsl
112} // namespace llvm
113
114#endif // LLVM_FRONTEND_HLSL_ROOTSIGNATUREMETADATA_H
#define LLVM_ABI
Definition Compiler.h:213
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)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:41
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:1078
Root of the metadata hierarchy.
Definition Metadata.h:64
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
LLVM_ABI MDNode * BuildRootSignature()
Iterates through elements and dispatches onto the correct Build* method.
MetadataBuilder(llvm::LLVMContext &Ctx, ArrayRef< RootElement > Elements)
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:98
FunctionAddr VTableAddr uintptr_t uintptr_t Version
Definition InstrProf.h:302