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"
19#include "llvm/ADT/StringRef.h"
23#include "llvm/Support/Error.h"
24#include <cstdint>
25
26namespace llvm {
27
28class LLVMContext;
29class MDNode;
30
31namespace hlsl {
32
33// Definitions of the in-memory data layout structures
34
35// Sentinel values denoting that an element is unallocated
36static constexpr uint32_t UnallocatedRow = ~0U;
37static constexpr uint8_t UnallocatedCol = 0xFF;
38
39// Models a single packed range of signature rows with its semantic name and
40// indices, register placement, component masks, and stage-specific attributes.
48 dxbc::PSV::InterpolationMode::Undefined;
56
65
66 bool isAllocated() const {
68 }
69
71 if (!isAllocated())
72 return 0;
73 return static_cast<uint8_t>(((1U << Cols) - 1U) << StartCol);
74 }
75
77
79 return static_cast<uint8_t>(~UsageMask & getDeclaredMask());
80 }
81
82 dxbc::SigMinPrecision getMinPrecision(bool UseMinPrecision) const {
83 if (!UseMinPrecision)
84 return dxbc::SigMinPrecision::Default;
85 switch (CompType) {
87 return dxbc::SigMinPrecision::Float16;
89 return dxbc::SigMinPrecision::SInt16;
91 return dxbc::SigMinPrecision::UInt16;
92 default:
93 return dxbc::SigMinPrecision::Default;
94 }
95 }
96
97 // Parse a signature element from its metadata representation
99 fromMetadata(const MDNode *Node);
100
101 // Build the metadata representation of this signature element
103};
104
106
107} // namespace hlsl
108} // namespace llvm
109
110#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_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