15#ifndef LLVM_OBJECT_DXCONTAINER_H
16#define LLVM_OBJECT_DXCONTAINER_H
49 template <
typename T>
struct ViewArray {
53 ViewArray() =
default;
57 static constexpr uint32_t MaxStride() {
58 return static_cast<uint32_t>(
sizeof(value_type));
78 memcpy(
static_cast<void *
>(&Val),
Current,
79 std::min(
Stride, MaxStride()));
113 iterator begin()
const {
return iterator(*
this,
Data.begin()); }
115 iterator end()
const {
return iterator(*
this,
Data.end()); }
117 size_t size()
const {
return Data.size() / Stride; }
120 using ResourceArray = ViewArray<dxbc::PSV::v2::ResourceBindInfo>;
121 using SigElementArray = ViewArray<dxbc::PSV::v0::SignatureElement>;
126 std::variant<std::monostate, dxbc::PSV::v0::RuntimeInfo,
127 dxbc::PSV::v1::RuntimeInfo, dxbc::PSV::v2::RuntimeInfo>;
128 InfoStruct BasicInfo;
129 ResourceArray Resources;
130 StringRef StringTable;
131 SmallVector<uint32_t> SemanticIndexTable;
132 SigElementArray SigInputElements;
133 SigElementArray SigOutputElements;
134 SigElementArray SigPatchOrPrimElements;
136 std::array<ViewArray<uint32_t>, 4> OutputVectorMasks;
137 ViewArray<uint32_t> PatchOrPrimMasks;
138 std::array<ViewArray<uint32_t>, 4> InputOutputMap;
139 ViewArray<uint32_t> InputPatchMap;
140 ViewArray<uint32_t> PatchOutputMap;
160 const InfoStruct &
getInfo()
const {
return BasicInfo; }
163 if (
const auto *
P = std::get_if<dxbc::PSV::v2::RuntimeInfo>(&BasicInfo))
164 return static_cast<const T *
>(
P);
165 if (std::is_same<T, dxbc::PSV::v2::RuntimeInfo>::value)
168 if (
const auto *
P = std::get_if<dxbc::PSV::v1::RuntimeInfo>(&BasicInfo))
169 return static_cast<const T *
>(
P);
170 if (std::is_same<T, dxbc::PSV::v1::RuntimeInfo>::value)
173 if (
const auto *
P = std::get_if<dxbc::PSV::v0::RuntimeInfo>(&BasicInfo))
174 return static_cast<const T *
>(
P);
180 return SemanticIndexTable;
190 return SigPatchOrPrimElements;
195 return OutputVectorMasks[
Idx];
202 return InputOutputMap[
Idx];
211 if (
const auto *
P = getInfoAs<dxbc::PSV::v1::RuntimeInfo>())
212 return P->UsesViewID != 0;
217 if (
const auto *
P = getInfoAs<dxbc::PSV::v1::RuntimeInfo>())
218 return P->SigInputVectors;
223 if (
const auto *
P = getInfoAs<dxbc::PSV::v1::RuntimeInfo>())
229 if (
const auto *
P = getInfoAs<dxbc::PSV::v1::RuntimeInfo>())
230 return P->GeomData.SigPatchConstOrPrimVectors;
239 using DXILData = std::pair<dxbc::ProgramHeader, const char *>;
247 std::optional<DXILData> DXIL;
248 std::optional<uint64_t> ShaderFlags;
249 std::optional<dxbc::ShaderHash> Hash;
250 std::optional<DirectX::PSVRuntimeInfo> PSVInfo;
253 Error parsePartOffsets();
277 : Container(
C), OffsetIt(It) {
278 if (OffsetIt == Container.PartOffsets.
end())
279 updateIteratorImpl(Container.PartOffsets.
back());
287 void updateIterator() {
288 if (OffsetIt != Container.PartOffsets.
end())
289 updateIteratorImpl(*OffsetIt);
298 if (OffsetIt == Container.PartOffsets.
end())
312 return OffsetIt ==
RHS.OffsetIt;
316 return OffsetIt !=
RHS.OffsetIt;
334 const std::optional<DXILData> &
getDXIL()
const {
return DXIL; }
340 const std::optional<DirectX::PSVRuntimeInfo> &
getPSVInfo()
const {
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
Given that RA is a live value
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
typename SuperClass::const_iterator const_iterator
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
const PartData & operator*()
PartIterator operator++(int)
const PartData * operator->()
PartIterator & operator++()
bool operator!=(const PartIterator &RHS) const
bool operator==(const PartIterator &RHS) const
std::optional< uint64_t > getShaderFlags() const
const std::optional< DXILData > & getDXIL() const
const std::optional< DirectX::PSVRuntimeInfo > & getPSVInfo() const
const dxbc::Header & getHeader() const
std::pair< dxbc::ProgramHeader, const char * > DXILData
StringRef getData() const
PartIterator begin() const
static Expected< DXContainer > create(MemoryBufferRef Object)
std::optional< dxbc::ShaderHash > getShaderHash() const
uint32_t getResourceStride() const
ArrayRef< uint8_t > getOutputVectorCounts() const
ArrayRef< uint32_t > getSemanticIndexTable() const
ResourceArray getResources() const
ViewArray< uint32_t > getInputOutputMap(size_t Idx) const
uint8_t getPatchConstOrPrimVectorCount() const
uint8_t getSigInputCount() const
ViewArray< uint32_t > getPatchOrPrimMasks() const
uint8_t getSigPatchOrPrimCount() const
StringRef getStringTable() const
PSVRuntimeInfo(StringRef D)
ViewArray< uint32_t > getInputPatchMap() const
ViewArray< uint32_t > getOutputVectorMasks(size_t Idx) const
uint32_t getVersion() const
uint32_t getSigElementStride() const
SigElementArray getSigPatchOrPrimElements() const
SigElementArray getSigInputElements() const
uint32_t getResourceCount() const
uint8_t getInputVectorCount() const
uint8_t getSigOutputCount() const
SigElementArray getSigOutputElements() const
const InfoStruct & getInfo() const
ViewArray< uint32_t > getPatchOutputMap() const
const T * getInfoAs() const
@ C
The default llvm calling convention, compatible with C.
std::enable_if_t< std::is_arithmetic< T >::value, void > swapBytes(T &value)
constexpr bool IsBigEndianHost
void swapByteOrder(T &Value)
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.
iterator(const iterator &)=default
iterator(const ViewArray &A, const char *C)
bool operator==(const iterator I)
bool operator!=(const iterator I)