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
52// Keywords written on a declaration, before sampling-location precedence and
53// stage/type defaults are applied.
55 None = 0,
57 Linear = 1 << 1,
58 NoPerspective = 1 << 2,
59 // Sampling-location bits are ordered by increasing precedence for min/max.
60 Center = 1 << 3,
61 Centroid = 1 << 4,
62 Sample = 1 << 5,
64};
65
71 "sampling-location bits must increase in precedence");
72
73// Select the highest-precedence sampling-location bit (sample > centroid >
74// center), ignoring other modifiers. Returns None if no location is explicit,
75// keeping it distinct from Center so diagnostics can detect location overrides.
78
79// Returns Invalid for nointerpolation combined with any other modifier.
82
83// Apply component-type defaults and SV_Position's noperspective requirement.
84// Vertex outputs carry interpolation modes so they pack compatibly with pixel
85// inputs; other signature points do not use interpolation modes.
89
100
106
107// Sentinel values denoting that an element is unallocated
108static constexpr uint32_t UnallocatedRow = ~0U;
109static constexpr uint8_t UnallocatedCol = 0xFF;
110
111// Models a single packed range of signature rows with its semantic name and
112// indices, register placement, component masks, and stage-specific attributes.
120 dxbc::PSV::InterpolationMode::Undefined;
128
137
138 bool isAllocated() const {
140 }
141
143 if (!isAllocated())
144 return 0;
145 return static_cast<uint8_t>(((1U << Cols) - 1U) << StartCol);
146 }
147
149
151 return static_cast<uint8_t>(~UsageMask & getDeclaredMask());
152 }
153
154 dxbc::SigMinPrecision getMinPrecision(bool UseMinPrecision) const {
155 if (!UseMinPrecision)
156 return dxbc::SigMinPrecision::Default;
157 switch (CompType) {
159 return dxbc::SigMinPrecision::Float16;
161 return dxbc::SigMinPrecision::SInt16;
163 return dxbc::SigMinPrecision::UInt16;
164 default:
165 return dxbc::SigMinPrecision::Default;
166 }
167 }
168
169 // Parse a signature element from its metadata representation
171 fromMetadata(const MDNode *Node);
172
173 // Build the metadata representation of this signature element
175};
176
178
181
182LLVM_ABI SemanticInterpretation
184 Triple::EnvironmentType ShaderStage, IOType IOTy);
185
186} // namespace hlsl
187} // namespace llvm
188
189#endif // LLVM_FRONTEND_HLSL_SEMANTICSIGNATURES_H
#define LLVM_ABI
Definition Compiler.h:215
static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))
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:1081
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::InterpolationMode getInterpolationMode(InterpolationModifier Modifiers)
LLVM_ABI dxbc::PSV::InterpolationMode normalizeInterpolationMode(dxbc::PSV::InterpolationMode Mode, dxil::ElementType CompType, dxbc::PSV::SemanticKind Kind, Triple::EnvironmentType Stage, IOType IO)
LLVM_ABI InterpolationModifier getInterpolationSamplingLocation(InterpolationModifier Modifiers)
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:1685
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