LLVM 23.0.0git
DXContainer.cpp
Go to the documentation of this file.
1
2//===-- llvm/BinaryFormat/DXContainer.cpp - DXContainer Utils ----*- C++-*-===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9//
10// This file contains utility functions for working with DXContainers.
11//
12//===----------------------------------------------------------------------===//
13
17
18using namespace llvm;
19using namespace llvm::dxbc;
20
21#define ROOT_PARAMETER(Val, Enum) \
22 case Val: \
23 return true;
25 switch (V) {
26#include "llvm/BinaryFormat/DXContainerConstants.def"
27 }
28 return false;
29}
30
34
35#define SHADER_VISIBILITY(Val, Enum) \
36 case Val: \
37 return true;
39 switch (V) {
40#include "llvm/BinaryFormat/DXContainerConstants.def"
41 }
42 return false;
43}
44
45#define FILTER(Val, Enum) \
46 case Val: \
47 return true;
49 switch (V) {
50#include "llvm/BinaryFormat/DXContainerConstants.def"
51 }
52 return false;
53}
54
55#define TEXTURE_ADDRESS_MODE(Val, Enum) \
56 case Val: \
57 return true;
59 switch (V) {
60#include "llvm/BinaryFormat/DXContainerConstants.def"
61 }
62 return false;
63}
64
65#define COMPARISON_FUNC(Val, Enum) \
66 case Val: \
67 return true;
69 switch (V) {
70#include "llvm/BinaryFormat/DXContainerConstants.def"
71 }
72 return false;
73}
74
75#define STATIC_BORDER_COLOR(Val, Enum) \
76 case Val: \
77 return true;
79 switch (V) {
80#include "llvm/BinaryFormat/DXContainerConstants.def"
81 }
82 return false;
83}
84
85template <typename FlagT>
86static bool isValidFlags(std::underlying_type_t<FlagT> V) {
87 decltype(V) LargestValue =
88 llvm::to_underlying(FlagT::LLVM_BITMASK_LARGEST_ENUMERATOR);
89 return V < NextPowerOf2(LargestValue);
90}
91
95
99
103
107
108template <typename EnumT>
109static bool isValidEnumValue(std::underlying_type_t<EnumT> V) {
110 decltype(V) LargestValue =
111 llvm::to_underlying(EnumT::LLVM_BITMASK_LARGEST_ENUMERATOR);
112 return V <= LargestValue;
113}
114
118
122
124#define CONTAINER_PART(PartName) .Case(#PartName, PartType::PartName)
126#include "llvm/BinaryFormat/DXContainerConstants.def"
128}
129
130bool dxbc::isDebugProgramPart(PartType PT) { return PT == PartType::ILDB; }
131
132const char *dxbc::getProgramPartName(bool IsDebug) {
133 return IsDebug ? "ILDB" : "DXIL";
134}
135
137 static uint8_t Zeros[16] = {0};
138 return Flags > 0 || 0 != memcmp(&Digest, &Zeros, 16);
139}
140
141#define COMPONENT_PRECISION(Val, Enum) {#Enum, SigMinPrecision::Enum},
142
144#include "llvm/BinaryFormat/DXContainerConstants.def"
145};
146
150
151#define D3D_SYSTEM_VALUE(Val, Enum) {#Enum, D3DSystemValue::Enum},
152
154#include "llvm/BinaryFormat/DXContainerConstants.def"
155};
156
160
161#define COMPONENT_TYPE(Val, Enum) {#Enum, SigComponentType::Enum},
162
164#include "llvm/BinaryFormat/DXContainerConstants.def"
165};
166
170
172#define ROOT_SIGNATURE_FLAG(Val, Enum) {#Enum, RootFlags::Enum},
173#include "llvm/BinaryFormat/DXContainerConstants.def"
174};
175
179
181#define ROOT_DESCRIPTOR_FLAG(Val, Enum, Flag) \
182 {#Enum, RootDescriptorFlags::Enum},
183#include "llvm/BinaryFormat/DXContainerConstants.def"
184};
185
189
191#define DESCRIPTOR_RANGE_FLAG(Val, Enum, Flag) \
192 {#Enum, DescriptorRangeFlags::Enum},
193#include "llvm/BinaryFormat/DXContainerConstants.def"
194};
195
199
201#define STATIC_SAMPLER_FLAG(Val, Enum, Flag) {#Enum, StaticSamplerFlags::Enum},
202#include "llvm/BinaryFormat/DXContainerConstants.def"
203};
204
208
209#define SHADER_VISIBILITY(Val, Enum) {#Enum, ShaderVisibility::Enum},
210
212#include "llvm/BinaryFormat/DXContainerConstants.def"
213};
214
218
219#define FILTER(Val, Enum) {#Enum, SamplerFilter::Enum},
220
222#include "llvm/BinaryFormat/DXContainerConstants.def"
223};
224
228
229#define TEXTURE_ADDRESS_MODE(Val, Enum) {#Enum, TextureAddressMode::Enum},
230
232#include "llvm/BinaryFormat/DXContainerConstants.def"
233};
234
238
239#define COMPARISON_FUNC(Val, Enum) {#Enum, ComparisonFunc::Enum},
240
242#include "llvm/BinaryFormat/DXContainerConstants.def"
243};
244
248
249#define STATIC_BORDER_COLOR(Val, Enum) {#Enum, StaticBorderColor::Enum},
250
252#include "llvm/BinaryFormat/DXContainerConstants.def"
253};
254
258
259#define ROOT_PARAMETER(Val, Enum) {#Enum, RootParameterType::Enum},
260
262#include "llvm/BinaryFormat/DXContainerConstants.def"
263};
264
268
269#define SEMANTIC_KIND(Val, Enum) {#Enum, PSV::SemanticKind::Enum},
270
272#include "llvm/BinaryFormat/DXContainerConstants.def"
273};
274
278
279#define COMPONENT_TYPE(Val, Enum) {#Enum, PSV::ComponentType::Enum},
280
282#include "llvm/BinaryFormat/DXContainerConstants.def"
283};
284
288
289#define INTERPOLATION_MODE(Val, Enum) {#Enum, PSV::InterpolationMode::Enum},
290
292#include "llvm/BinaryFormat/DXContainerConstants.def"
293};
294
298
299#define RESOURCE_TYPE(Val, Enum) {#Enum, PSV::ResourceType::Enum},
300
302#include "llvm/BinaryFormat/DXContainerConstants.def"
303};
304
308
309#define RESOURCE_KIND(Val, Enum) {#Enum, PSV::ResourceKind::Enum},
310
312#include "llvm/BinaryFormat/DXContainerConstants.def"
313};
314
318
320#define SOURCE_INFO_TYPE(Num, Val) {#Val, SourceInfo::SectionType::Val},
321#include "llvm/BinaryFormat/DXContainerConstants.def"
322};
323
327
334
337#define COMPRESSION_TYPE(Num, Val) \
338 {#Val, SourceInfo::Contents::CompressionType::Val},
339#include "llvm/BinaryFormat/DXContainerConstants.def"
340};
341
static const EnumEntry< DescriptorRangeFlags > DescriptorRangeFlagNames[]
static const EnumEntry< ShaderVisibility > ShaderVisibilityValues[]
static const EnumEntry< SourceInfo::Contents::CompressionType > CompressionTypes[]
static const EnumEntry< D3DSystemValue > D3DSystemValueNames[]
static bool isValidEnumValue(std::underlying_type_t< EnumT > V)
static const EnumEntry< PSV::InterpolationMode > InterpolationModeNames[]
static const EnumEntry< SigMinPrecision > SigMinPrecisionNames[]
static const EnumEntry< StaticSamplerFlags > StaticSamplerFlagNames[]
static const EnumEntry< SamplerFilter > SamplerFilterNames[]
static const EnumEntry< RootParameterType > RootParameterTypes[]
static const EnumEntry< PSV::SemanticKind > SemanticKindNames[]
static bool isValidFlags(std::underlying_type_t< FlagT > V)
static const EnumEntry< PSV::ResourceType > ResourceTypeNames[]
static const EnumEntry< StaticBorderColor > StaticBorderColorValues[]
static const EnumEntry< RootFlags > RootFlagNames[]
static const EnumEntry< ComparisonFunc > ComparisonFuncNames[]
static const EnumEntry< PSV::ResourceKind > ResourceKindNames[]
static const EnumEntry< RootDescriptorFlags > RootDescriptorFlagNames[]
static const EnumEntry< TextureAddressMode > TextureAddressModeNames[]
static const EnumEntry< SigComponentType > SigComponentTypes[]
static const EnumEntry< PSV::ComponentType > ComponentTypeNames[]
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
A switch()-like statement whose cases are string literals.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
static constexpr StringLiteral SectionNames[SectionKindsNum]
LLVM_ABI ArrayRef< EnumEntry< ResourceKind > > getResourceKinds()
LLVM_ABI ArrayRef< EnumEntry< ComponentType > > getComponentTypes()
LLVM_ABI ArrayRef< EnumEntry< ResourceType > > getResourceTypes()
LLVM_ABI ArrayRef< EnumEntry< SemanticKind > > getSemanticKinds()
LLVM_ABI ArrayRef< EnumEntry< InterpolationMode > > getInterpolationModes()
LLVM_ABI ArrayRef< EnumEntry< CompressionType > > getCompressionTypes()
bool isValidCompressionType(uint16_t V)
LLVM_ABI bool isValidSectionType(uint16_t V)
LLVM_ABI ArrayRef< EnumEntry< SectionType > > getSectionTypes()
LLVM_ABI StringRef getSectionName(SectionType Type)
LLVM_ABI ArrayRef< EnumEntry< ComparisonFunc > > getComparisonFuncs()
LLVM_ABI ArrayRef< EnumEntry< ShaderVisibility > > getShaderVisibility()
bool isValidShaderVisibility(uint32_t V)
LLVM_ABI PartType parsePartType(StringRef S)
bool isValidSamplerFilter(uint32_t V)
bool isValidStaticSamplerFlags(uint32_t V)
LLVM_ABI ArrayRef< EnumEntry< RootFlags > > getRootFlags()
LLVM_ABI ArrayRef< EnumEntry< RootParameterType > > getRootParameterTypes()
bool isValidRootDesciptorFlags(uint32_t V)
LLVM_ABI ArrayRef< EnumEntry< SigComponentType > > getSigComponentTypes()
bool isDebugProgramPart(PartType PT)
LLVM_ABI ArrayRef< EnumEntry< SigMinPrecision > > getSigMinPrecisions()
LLVM_ABI ArrayRef< EnumEntry< DescriptorRangeFlags > > getDescriptorRangeFlags()
bool isValidCompilerVersionFlags(uint32_t V)
LLVM_ABI ArrayRef< EnumEntry< SamplerFilter > > getSamplerFilters()
LLVM_ABI ArrayRef< EnumEntry< D3DSystemValue > > getD3DSystemValues()
bool isValidDescriptorRangeFlags(uint32_t V)
bool isValidBorderColor(uint32_t V)
bool isValidComparisonFunc(uint32_t V)
LLVM_ABI_FOR_TEST bool isValidParameterType(uint32_t V)
const char * getProgramPartName(bool IsDebug)
LLVM_ABI ArrayRef< EnumEntry< StaticBorderColor > > getStaticBorderColors()
bool isValidAddress(uint32_t V)
LLVM_ABI ArrayRef< EnumEntry< TextureAddressMode > > getTextureAddressModes()
bool isValidRangeType(uint32_t V)
LLVM_ABI ArrayRef< EnumEntry< StaticSamplerFlags > > getStaticSamplerFlags()
LLVM_ABI ArrayRef< EnumEntry< RootDescriptorFlags > > getRootDescriptorFlags()
This is an optimization pass for GlobalISel generic memory operations.
constexpr std::underlying_type_t< Enum > to_underlying(Enum E)
Returns underlying integer value of an enum.
ArrayRef(const T &OneElt) -> ArrayRef< T >
constexpr uint64_t NextPowerOf2(uint64_t A)
Returns the next power of two (in 64-bits) that is strictly greater than A.
Definition MathExtras.h:373
LLVM_ABI bool isPopulated()