LLVM
22.0.0git
include
llvm
Frontend
HLSL
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
"
18
#include "
llvm/Frontend/HLSL/HLSLRootSignature.h
"
19
#include "
llvm/IR/Constants.h
"
20
#include "
llvm/MC/DXContainerRootSignature.h
"
21
#include "
llvm/Support/Compiler.h
"
22
23
namespace
llvm
{
24
class
LLVMContext
;
25
class
MDNode
;
26
class
Metadata
;
27
28
namespace
hlsl
{
29
namespace
rootsig
{
30
class
RootSignatureValidationError
31
:
public
ErrorInfo
<RootSignatureValidationError> {
32
public
:
33
static
char
ID
;
34
std::string
Msg
;
35
36
RootSignatureValidationError
(
const
Twine
&
Msg
) :
Msg
(
Msg
.str()) {}
37
38
void
log
(
raw_ostream
&OS)
const override
{ OS <<
Msg
; }
39
40
std::error_code
convertToErrorCode
()
const override
{
41
return
llvm::inconvertibleErrorCode
();
42
}
43
};
44
45
class
MetadataBuilder
{
46
public
:
47
MetadataBuilder
(
llvm::LLVMContext
&Ctx,
ArrayRef<RootElement>
Elements)
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
54
LLVM_ABI
MDNode
*
BuildRootSignature
();
55
56
private
:
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
65
llvm::LLVMContext
&Ctx;
66
ArrayRef<RootElement>
Elements;
67
SmallVector<Metadata *>
GeneratedMetadata;
68
};
69
70
enum class
RootSignatureElementKind
{
71
Error
= 0,
72
RootFlags
= 1,
73
RootConstants
= 2,
74
SRV
= 3,
75
UAV
= 4,
76
CBV
= 5,
77
DescriptorTable
= 6,
78
StaticSamplers
= 7
79
};
80
81
class
MetadataParser
{
82
public
:
83
MetadataParser
(
MDNode
*Root) : Root(Root) {}
84
85
LLVM_ABI
llvm::Expected<llvm::mcdxbc::RootSignatureDesc>
86
ParseRootSignature
(
uint32_t
Version
);
87
88
private
:
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
105
llvm::Error
validateRootSignature
(
const
llvm::mcdxbc::RootSignatureDesc
&RSD);
106
107
MDNode
*Root;
108
};
109
110
}
// namespace rootsig
111
}
// namespace hlsl
112
}
// namespace llvm
113
114
#endif
// LLVM_FRONTEND_HLSL_ROOTSIGNATUREMETADATA_H
Compiler.h
LLVM_ABI
#define LLVM_ABI
Definition
Compiler.h:213
Constants.h
This file contains the declarations for the subclasses of Constant, which represent the different fla...
DXContainerRootSignature.h
validateRootSignature
static void validateRootSignature(Module &M, const mcdxbc::RootSignatureDesc &RSD, dxil::ModuleMetadataInfo &MMI, DXILResourceMap &DRM, DXILResourceTypeMap &DRTM)
Definition
DXILPostOptimizationValidation.cpp:198
HLSLRootSignature.h
StringRef.h
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition
ArrayRef.h:41
llvm::Clause
Definition
DirectiveEmitter.h:280
llvm::ErrorInfo
Base class for user error types.
Definition
Error.h:354
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition
Error.h:159
llvm::Expected
Tagged union holding either a T or a Error.
Definition
Error.h:485
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition
LLVMContext.h:68
llvm::MDNode
Metadata node.
Definition
Metadata.h:1078
llvm::Metadata
Root of the metadata hierarchy.
Definition
Metadata.h:64
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition
SmallVector.h:1196
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition
Twine.h:82
llvm::hlsl::rootsig::MetadataBuilder::BuildRootSignature
LLVM_ABI MDNode * BuildRootSignature()
Iterates through elements and dispatches onto the correct Build* method.
Definition
RootSignatureMetadata.cpp:108
llvm::hlsl::rootsig::MetadataBuilder::MetadataBuilder
MetadataBuilder(llvm::LLVMContext &Ctx, ArrayRef< RootElement > Elements)
Definition
RootSignatureMetadata.h:47
llvm::hlsl::rootsig::MetadataParser::ParseRootSignature
LLVM_ABI llvm::Expected< llvm::mcdxbc::RootSignatureDesc > ParseRootSignature(uint32_t Version)
Definition
RootSignatureMetadata.cpp:766
llvm::hlsl::rootsig::MetadataParser::MetadataParser
MetadataParser(MDNode *Root)
Definition
RootSignatureMetadata.h:83
llvm::hlsl::rootsig::RootSignatureValidationError::convertToErrorCode
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Definition
RootSignatureMetadata.h:40
llvm::hlsl::rootsig::RootSignatureValidationError::Msg
std::string Msg
Definition
RootSignatureMetadata.h:34
llvm::hlsl::rootsig::RootSignatureValidationError::RootSignatureValidationError
RootSignatureValidationError(const Twine &Msg)
Definition
RootSignatureMetadata.h:36
llvm::hlsl::rootsig::RootSignatureValidationError::log
void log(raw_ostream &OS) const override
Print an error message to an output stream.
Definition
RootSignatureMetadata.h:38
llvm::hlsl::rootsig::RootSignatureValidationError::ID
static char ID
Definition
RootSignatureMetadata.h:33
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition
raw_ostream.h:53
uint32_t
llvm::dxbc::RootFlags
RootFlags
Definition
DXContainer.h:162
llvm::hlsl::rootsig
Definition
HLSLRootSignature.h:26
llvm::hlsl::rootsig::RootSignatureElementKind
RootSignatureElementKind
Definition
RootSignatureMetadata.h:70
llvm::hlsl::rootsig::RootSignatureElementKind::CBV
@ CBV
Definition
RootSignatureMetadata.h:76
llvm::hlsl::rootsig::RootSignatureElementKind::UAV
@ UAV
Definition
RootSignatureMetadata.h:75
llvm::hlsl::rootsig::RootSignatureElementKind::Error
@ Error
Definition
RootSignatureMetadata.h:71
llvm::hlsl::rootsig::RootSignatureElementKind::SRV
@ SRV
Definition
RootSignatureMetadata.h:74
llvm::hlsl::rootsig::RootSignatureElementKind::StaticSamplers
@ StaticSamplers
Definition
RootSignatureMetadata.h:78
llvm::hlsl::rootsig::RootSignatureElementKind::RootFlags
@ RootFlags
Definition
RootSignatureMetadata.h:72
llvm::hlsl
Definition
CBuffer.h:26
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition
AddressRanges.h:18
llvm::inconvertibleErrorCode
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
llvm::Version
FunctionAddr VTableAddr uintptr_t uintptr_t Version
Definition
InstrProf.h:302
llvm::hlsl::rootsig::DescriptorTableClause
Definition
HLSLRootSignature.h:88
llvm::hlsl::rootsig::DescriptorTable
Definition
HLSLRootSignature.h:78
llvm::hlsl::rootsig::RootConstants
Definition
HLSLRootSignature.h:38
llvm::hlsl::rootsig::RootDescriptor
Definition
HLSLRootSignature.h:46
llvm::hlsl::rootsig::StaticSampler
Definition
HLSLRootSignature.h:122
llvm::mcdxbc::DescriptorTable
Definition
DXContainerRootSignature.h:53
llvm::mcdxbc::RootSignatureDesc
Definition
DXContainerRootSignature.h:138
Generated on
for LLVM by
1.14.0