LLVM
24.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/IR/Module.h
"
21
#include "
llvm/MC/DXContainerRootSignature.h
"
22
#include "
llvm/Support/Compiler.h
"
23
24
namespace
llvm
{
25
class
LLVMContext
;
26
class
MDNode
;
27
class
Metadata
;
28
29
namespace
hlsl
{
30
namespace
rootsig
{
31
class
RootSignatureValidationError
32
:
public
ErrorInfo
<RootSignatureValidationError> {
33
public
:
34
LLVM_ABI
static
char
ID
;
35
std::string
Msg
;
36
37
RootSignatureValidationError
(
const
Twine
&
Msg
) :
Msg
(
Msg
.str()) {}
38
39
void
log
(
raw_ostream
&OS)
const override
{ OS <<
Msg
; }
40
41
std::error_code
convertToErrorCode
()
const override
{
42
return
llvm::inconvertibleErrorCode
();
43
}
44
};
45
46
class
MetadataBuilder
{
47
public
:
48
MetadataBuilder
(
llvm::Module
&M,
ArrayRef<RootElement>
Elements)
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
55
LLVM_ABI
MDNode
*
BuildRootSignature
();
56
57
private
:
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;
67
llvm::LLVMContext
&Ctx;
68
ArrayRef<RootElement>
Elements;
69
SmallVector<Metadata *>
GeneratedMetadata;
70
};
71
72
enum class
RootSignatureElementKind
{
73
Error
= 0,
74
RootFlags
= 1,
75
RootConstants
= 2,
76
SRV
= 3,
77
UAV
= 4,
78
CBV
= 5,
79
DescriptorTable
= 6,
80
StaticSamplers
= 7
81
};
82
83
class
MetadataParser
{
84
public
:
85
MetadataParser
(
MDNode
*Root) : Root(Root) {}
86
87
LLVM_ABI
llvm::Expected<llvm::mcdxbc::RootSignatureDesc>
88
ParseRootSignature
(
uint32_t
Version
);
89
90
private
:
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
107
llvm::Error
validateRootSignature
(
const
llvm::mcdxbc::RootSignatureDesc
&RSD);
108
109
MDNode
*Root;
110
};
111
112
}
// namespace rootsig
113
}
// namespace hlsl
114
}
// namespace llvm
115
116
#endif
// LLVM_FRONTEND_HLSL_ROOTSIGNATUREMETADATA_H
Compiler.h
LLVM_ABI
#define LLVM_ABI
Definition
Compiler.h:215
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
Module.h
Module.h This file contains the declarations for the Module class.
getContext
Func getContext().diagnose(DiagnosticInfoUnsupported(Func
StringRef.h
llvm::ArrayRef
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition
ArrayRef.h:40
llvm::Clause
Definition
DirectiveEmitter.h:293
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:1081
llvm::Metadata
Root of the metadata hierarchy.
Definition
Metadata.h:64
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition
Module.h:68
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition
SmallVector.h:1252
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition
Twine.h:82
llvm::hlsl::rootsig::MetadataBuilder::MetadataBuilder
MetadataBuilder(llvm::Module &M, ArrayRef< RootElement > Elements)
Definition
RootSignatureMetadata.h:48
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::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:85
llvm::hlsl::rootsig::RootSignatureValidationError::convertToErrorCode
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Definition
RootSignatureMetadata.h:41
llvm::hlsl::rootsig::RootSignatureValidationError::Msg
std::string Msg
Definition
RootSignatureMetadata.h:35
llvm::hlsl::rootsig::RootSignatureValidationError::RootSignatureValidationError
RootSignatureValidationError(const Twine &Msg)
Definition
RootSignatureMetadata.h:37
llvm::hlsl::rootsig::RootSignatureValidationError::log
void log(raw_ostream &OS) const override
Print an error message to an output stream.
Definition
RootSignatureMetadata.h:39
llvm::hlsl::rootsig::RootSignatureValidationError::ID
static LLVM_ABI char ID
Definition
RootSignatureMetadata.h:34
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:164
llvm::hlsl::rootsig
Definition
HLSLRootSignature.h:26
llvm::hlsl::rootsig::RootSignatureElementKind
RootSignatureElementKind
Definition
RootSignatureMetadata.h:72
llvm::hlsl::rootsig::RootSignatureElementKind::CBV
@ CBV
Definition
RootSignatureMetadata.h:78
llvm::hlsl::rootsig::RootSignatureElementKind::UAV
@ UAV
Definition
RootSignatureMetadata.h:77
llvm::hlsl::rootsig::RootSignatureElementKind::Error
@ Error
Definition
RootSignatureMetadata.h:73
llvm::hlsl::rootsig::RootSignatureElementKind::SRV
@ SRV
Definition
RootSignatureMetadata.h:76
llvm::hlsl::rootsig::RootSignatureElementKind::StaticSamplers
@ StaticSamplers
Definition
RootSignatureMetadata.h:80
llvm::hlsl::rootsig::RootSignatureElementKind::RootFlags
@ RootFlags
Definition
RootSignatureMetadata.h:74
llvm::hlsl
Definition
CBuffer.h:26
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition
DefaultTargetInfo.h:21
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:94
llvm::CRCStrategyKind::Table
@ Table
Definition
ScalarOptions.h:18
llvm::PTXOpaqueType::Sampler
@ Sampler
Definition
NVVMProperties.h:38
llvm::Version
@ Version
Definition
PGOCtxProfWriter.h:25
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