LLVM
24.0.0git
include
llvm
Frontend
HLSL
SemanticSignatures.h
Go to the documentation of this file.
1
//===- SemanticSignatures.h - HLSL Semantic Signature helper objects ------===//
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 structure definitions of HLSL Semantic Signature
10
/// objects.
11
///
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_FRONTEND_HLSL_SEMANTICSIGNATURES_H
15
#define LLVM_FRONTEND_HLSL_SEMANTICSIGNATURES_H
16
17
#include "
llvm/ADT/SmallVector.h
"
18
#include "
llvm/ADT/StringRef.h
"
19
#include "
llvm/BinaryFormat/DXContainer.h
"
20
#include "
llvm/Support/Compiler.h
"
21
#include "
llvm/Support/DXILABI.h
"
22
#include "
llvm/Support/Error.h
"
23
#include <cstdint>
24
25
namespace
llvm
{
26
27
class
LLVMContext
;
28
class
MDNode
;
29
30
namespace
hlsl
{
31
32
// Definitions of the in-memory data layout structures
33
34
// Sentinel values denoting that an element is unallocated
35
static
constexpr
uint32_t
UnallocatedRow
= ~0U;
36
static
constexpr
uint8_t
UnallocatedCol
= 0xFF;
37
38
// Models a single packed range of signature rows with its semantic name and
39
// indices, register placement, component masks, and stage-specific attributes.
40
struct
SemanticSignatureElement
{
41
uint32_t
SigId
;
42
StringRef
SemanticName
;
43
dxil::ElementType
CompType
;
44
dxbc::PSV::SemanticKind
SemanticKind
;
45
SmallVector<uint32_t>
SemanticIndices
;
46
dxbc::PSV::InterpolationMode
InterpMode
=
47
dxbc::PSV::InterpolationMode::Undefined;
48
uint32_t
Rows
;
49
uint8_t
Cols
;
50
uint32_t
StartRow
=
UnallocatedRow
;
51
uint8_t
StartCol
=
UnallocatedCol
;
52
uint8_t
UsageMask
= 0;
53
uint8_t
DynIndexMask
= 0;
54
uint32_t
GSStream
= 0;
55
56
bool
isAllocated
()
const
{
57
return
StartRow
!=
UnallocatedRow
&&
StartCol
!=
UnallocatedCol
;
58
}
59
60
uint8_t
getDeclaredMask
()
const
{
61
if
(!
isAllocated
())
62
return
0;
63
return
static_cast<
uint8_t
>
(((1U <<
Cols
) - 1U) <<
StartCol
);
64
}
65
66
uint8_t
getAlwaysReadsMask
()
const
{
return
UsageMask
; }
67
68
uint8_t
getNeverWritesMask
()
const
{
69
return
static_cast<
uint8_t
>
(
~UsageMask
&
getDeclaredMask
());
70
}
71
72
dxbc::SigMinPrecision
getMinPrecision
(
bool
UseMinPrecision)
const
{
73
if
(!UseMinPrecision)
74
return
dxbc::SigMinPrecision::Default;
75
switch
(
CompType
) {
76
case
dxil::ElementType::F16
:
77
return
dxbc::SigMinPrecision::Float16;
78
case
dxil::ElementType::I16
:
79
return
dxbc::SigMinPrecision::SInt16;
80
case
dxil::ElementType::U16
:
81
return
dxbc::SigMinPrecision::UInt16;
82
default
:
83
return
dxbc::SigMinPrecision::Default;
84
}
85
}
86
87
// Parse a signature element from its metadata representation
88
LLVM_ABI
static
Expected<SemanticSignatureElement>
89
fromMetadata
(
const
MDNode
*
Node
);
90
91
// Build the metadata representation of this signature element
92
LLVM_ABI
MDNode
*
toMetadata
(
LLVMContext
&Ctx)
const
;
93
};
94
95
}
// namespace hlsl
96
}
// namespace llvm
97
98
#endif
// LLVM_FRONTEND_HLSL_SEMANTICSIGNATURES_H
DXContainer.h
Compiler.h
LLVM_ABI
#define LLVM_ABI
Definition
Compiler.h:215
DXILABI.h
SmallVector.h
This file defines the SmallVector class.
StringRef.h
Node
Definition
ItaniumDemangle.h:166
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:1069
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition
SmallVector.h:1236
llvm::StringRef
Represent a constant reference to a string, i.e.
Definition
StringRef.h:56
uint32_t
uint8_t
Error.h
llvm::dxbc::PSV::SemanticKind
SemanticKind
Definition
DXContainer.h:393
llvm::dxbc::PSV::InterpolationMode
InterpolationMode
Definition
DXContainer.h:407
llvm::dxbc::SigMinPrecision
SigMinPrecision
Definition
DXContainer.h:590
llvm::dxil::ElementType
ElementType
The element type of an SRV or UAV resource.
Definition
DXILABI.h:68
llvm::dxil::ElementType::F16
@ F16
Definition
DXILABI.h:77
llvm::dxil::ElementType::I16
@ I16
Definition
DXILABI.h:71
llvm::dxil::ElementType::U16
@ U16
Definition
DXILABI.h:72
llvm::hlsl
Definition
CBuffer.h:26
llvm::hlsl::UnallocatedRow
static constexpr uint32_t UnallocatedRow
Definition
SemanticSignatures.h:35
llvm::hlsl::UnallocatedCol
static constexpr uint8_t UnallocatedCol
Definition
SemanticSignatures.h:36
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition
FunctionInfo.h:25
llvm::hlsl::SemanticSignatureElement
Definition
SemanticSignatures.h:40
llvm::hlsl::SemanticSignatureElement::getAlwaysReadsMask
uint8_t getAlwaysReadsMask() const
Definition
SemanticSignatures.h:66
llvm::hlsl::SemanticSignatureElement::DynIndexMask
uint8_t DynIndexMask
Definition
SemanticSignatures.h:53
llvm::hlsl::SemanticSignatureElement::getNeverWritesMask
uint8_t getNeverWritesMask() const
Definition
SemanticSignatures.h:68
llvm::hlsl::SemanticSignatureElement::getMinPrecision
dxbc::SigMinPrecision getMinPrecision(bool UseMinPrecision) const
Definition
SemanticSignatures.h:72
llvm::hlsl::SemanticSignatureElement::getDeclaredMask
uint8_t getDeclaredMask() const
Definition
SemanticSignatures.h:60
llvm::hlsl::SemanticSignatureElement::Cols
uint8_t Cols
Definition
SemanticSignatures.h:49
llvm::hlsl::SemanticSignatureElement::fromMetadata
static LLVM_ABI Expected< SemanticSignatureElement > fromMetadata(const MDNode *Node)
Definition
SemanticSignatures.cpp:46
llvm::hlsl::SemanticSignatureElement::SemanticIndices
SmallVector< uint32_t > SemanticIndices
Definition
SemanticSignatures.h:45
llvm::hlsl::SemanticSignatureElement::SigId
uint32_t SigId
Definition
SemanticSignatures.h:41
llvm::hlsl::SemanticSignatureElement::StartRow
uint32_t StartRow
Definition
SemanticSignatures.h:50
llvm::hlsl::SemanticSignatureElement::StartCol
uint8_t StartCol
Definition
SemanticSignatures.h:51
llvm::hlsl::SemanticSignatureElement::GSStream
uint32_t GSStream
Definition
SemanticSignatures.h:54
llvm::hlsl::SemanticSignatureElement::isAllocated
bool isAllocated() const
Definition
SemanticSignatures.h:56
llvm::hlsl::SemanticSignatureElement::Rows
uint32_t Rows
Definition
SemanticSignatures.h:48
llvm::hlsl::SemanticSignatureElement::UsageMask
uint8_t UsageMask
Definition
SemanticSignatures.h:52
llvm::hlsl::SemanticSignatureElement::SemanticName
StringRef SemanticName
Definition
SemanticSignatures.h:42
llvm::hlsl::SemanticSignatureElement::CompType
dxil::ElementType CompType
Definition
SemanticSignatures.h:43
llvm::hlsl::SemanticSignatureElement::SemanticKind
dxbc::PSV::SemanticKind SemanticKind
Definition
SemanticSignatures.h:44
llvm::hlsl::SemanticSignatureElement::InterpMode
dxbc::PSV::InterpolationMode InterpMode
Definition
SemanticSignatures.h:46
llvm::hlsl::SemanticSignatureElement::toMetadata
LLVM_ABI MDNode * toMetadata(LLVMContext &Ctx) const
Definition
SemanticSignatures.cpp:180
Generated on
for LLVM by
1.14.0