LLVM 24.0.0git
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/ArrayRef.h"
20#include "llvm/ADT/StringRef.h"
24#include "llvm/Support/Error.h"
26#include <cstdint>
27
28namespace llvm {
29
30class LLVMContext;
31class MDNode;
32
33namespace hlsl {
34
36
37// Definitions of the in-memory data layout structures
38
39// Bitmask denoting whether a semantic is an input, output, inout or a value
40// that is constant across a patch (hull/domain shaders) or primitive
41// (mesh shaders).
42enum class IOType {
43 In = 0b001,
44 Out = 0b010,
45 InOut = 0b011,
47 All = 0b111,
48
50};
51
62
68
69// Sentinel values denoting that an element is unallocated
70static constexpr uint32_t UnallocatedRow = ~0U;
71static constexpr uint8_t UnallocatedCol = 0xFF;
72
73// Models a single packed range of signature rows with its semantic name and
74// indices, register placement, component masks, and stage-specific attributes.
82 dxbc::PSV::InterpolationMode::Undefined;
90
99
100 bool isAllocated() const {
102 }
103
105 if (!isAllocated())
106 return 0;
107 return static_cast<uint8_t>(((1U << Cols) - 1U) << StartCol);
108 }
109
111
113 return static_cast<uint8_t>(~UsageMask & getDeclaredMask());
114 }
115
116 dxbc::SigMinPrecision getMinPrecision(bool UseMinPrecision) const {
117 if (!UseMinPrecision)
118 return dxbc::SigMinPrecision::Default;
119 switch (CompType) {
121 return dxbc::SigMinPrecision::Float16;
123 return dxbc::SigMinPrecision::SInt16;
125 return dxbc::SigMinPrecision::UInt16;
126 default:
127 return dxbc::SigMinPrecision::Default;
128 }
129 }
130
131 // Parse a signature element from its metadata representation
133 fromMetadata(const MDNode *Node);
134
135 // Build the metadata representation of this signature element
137};
138
140
143
144LLVM_ABI SemanticInterpretation
146 Triple::EnvironmentType ShaderStage, IOType IOTy);
147
148} // namespace hlsl
149} // namespace llvm
150
151#endif // LLVM_FRONTEND_HLSL_SEMANTICSIGNATURES_H
#define LLVM_ABI
Definition Compiler.h:215
This file defines the SmallVector class.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
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:1069
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
ElementType
The element type of an SRV or UAV resource.
Definition DXILABI.h:68
static constexpr uint32_t UnallocatedRow
LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE()
LLVM_ABI SemanticInterpretation getInterpretationKind(dxbc::PSV::SemanticKind SemanticKind, Triple::EnvironmentType ShaderStage, IOType IOTy)
LLVM_ABI ArrayRef< SemanticStageInfo > getAvailableStages(dxbc::PSV::SemanticKind SemanticKind)
LLVM_ABI dxbc::PSV::SemanticKind getSemanticKind(StringRef SemanticName)
static constexpr uint8_t UnallocatedCol
This is an optimization pass for GlobalISel generic memory operations.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
Definition STLExtras.h:1669
dxbc::SigMinPrecision getMinPrecision(bool UseMinPrecision) const
static LLVM_ABI Expected< SemanticSignatureElement > fromMetadata(const MDNode *Node)
SemanticSignatureElement(uint32_t SigId, StringRef SemanticName, dxil::ElementType CompType, dxbc::PSV::SemanticKind SemanticKind, ArrayRef< uint32_t > SemanticIndices, uint8_t Cols)
dxbc::PSV::InterpolationMode InterpMode
LLVM_ABI MDNode * toMetadata(LLVMContext &Ctx) const
SemanticInterpretation Interpretation
Triple::EnvironmentType Stage