15#ifndef LLVM_OBJECT_DXCONTAINER_H
16#define LLVM_OBJECT_DXCONTAINER_H
136 return make_error<GenericBinaryError>(
149 return V->Header.ParameterType ==
150 (
uint32_t)dxbc::RootParameterType::Constants32Bit;
154 return readParameter<dxbc::RTS0::v1::RootConstants>();
160 return (V->Header.ParameterType ==
162 V->Header.ParameterType ==
164 V->Header.ParameterType ==
170 auto Descriptor = readParameter<dxbc::RTS0::v1::RootDescriptor>();
171 if (
Error E = Descriptor.takeError())
176 return make_error<GenericBinaryError>(
"Invalid Root Signature version: " +
179 return readParameter<dxbc::RTS0::v2::RootDescriptor>();
194 return (V->Header.ParameterType ==
204 support::endian::read<uint32_t, llvm::endianness::little>(Current);
208 support::endian::read<uint32_t, llvm::endianness::little>(Current);
266 case dxbc::RootParameterType::Constants32Bit:
269 case dxbc::RootParameterType::CBV:
270 case dxbc::RootParameterType::SRV:
271 case dxbc::RootParameterType::UAV:
277 case dxbc::RootParameterType::DescriptorTable:
278 if (Header.ParameterOffset +
sizeof(
uint32_t) > EndOfSectionByte)
279 return parseFailed(
"Reading structure out of file bounds");
282 support::endian::read<uint32_t, llvm::endianness::little>(
283 PartData.
begin() + Header.ParameterOffset);
294 if (Header.ParameterOffset + DataSize > EndOfSectionByte)
295 return parseFailed(
"Reading structure out of file bounds");
314 InfoStruct BasicInfo;
322 std::array<ViewArray<uint32_t>, 4> OutputVectorMasks;
324 std::array<ViewArray<uint32_t>, 4> InputOutputMap;
348 const InfoStruct &
getInfo()
const {
return BasicInfo; }
351 if (
const auto *
P = std::get_if<dxbc::PSV::v3::RuntimeInfo>(&BasicInfo))
352 return static_cast<const T *
>(
P);
353 if (std::is_same<T, dxbc::PSV::v3::RuntimeInfo>::value)
356 if (
const auto *
P = std::get_if<dxbc::PSV::v2::RuntimeInfo>(&BasicInfo))
357 return static_cast<const T *
>(
P);
358 if (std::is_same<T, dxbc::PSV::v2::RuntimeInfo>::value)
361 if (
const auto *
P = std::get_if<dxbc::PSV::v1::RuntimeInfo>(&BasicInfo))
362 return static_cast<const T *
>(
P);
363 if (std::is_same<T, dxbc::PSV::v1::RuntimeInfo>::value)
366 if (
const auto *
P = std::get_if<dxbc::PSV::v0::RuntimeInfo>(&BasicInfo))
367 return static_cast<const T *
>(
P);
373 return SemanticIndexTable;
383 return SigPatchOrPrimElements;
388 return OutputVectorMasks[
Idx];
395 return InputOutputMap[
Idx];
404 if (
const auto *
P = getInfoAs<dxbc::PSV::v1::RuntimeInfo>())
405 return P->UsesViewID != 0;
410 if (
const auto *
P = getInfoAs<dxbc::PSV::v1::RuntimeInfo>())
411 return P->SigInputVectors;
416 if (
const auto *
P = getInfoAs<dxbc::PSV::v1::RuntimeInfo>())
422 if (
const auto *
P = getInfoAs<dxbc::PSV::v1::RuntimeInfo>())
423 return P->GeomData.SigPatchConstOrPrimVectors;
435 return Parameters.begin();
439 return Parameters.end();
445 "Offset out of range.");
453 bool isEmpty()
const {
return Parameters.isEmpty(); }
462 using DXILData = std::pair<dxbc::ProgramHeader, const char *>;
470 std::optional<DXILData> DXIL;
471 std::optional<uint64_t> ShaderFeatureFlags;
472 std::optional<dxbc::ShaderHash> Hash;
473 std::optional<DirectX::PSVRuntimeInfo> PSVInfo;
474 std::optional<DirectX::RootSignature> RootSignature;
480 Error parsePartOffsets();
507 : Container(
C), OffsetIt(It) {
508 if (OffsetIt == Container.PartOffsets.
end())
509 updateIteratorImpl(Container.PartOffsets.
back());
517 void updateIterator() {
518 if (OffsetIt != Container.PartOffsets.
end())
519 updateIteratorImpl(*OffsetIt);
528 if (OffsetIt == Container.PartOffsets.
end())
542 return OffsetIt ==
RHS.OffsetIt;
546 return OffsetIt !=
RHS.OffsetIt;
564 const std::optional<DXILData> &
getDXIL()
const {
return DXIL; }
567 return ShaderFeatureFlags;
573 return RootSignature;
576 const std::optional<DirectX::PSVRuntimeInfo> &
getPSVInfo()
const {
582 return OutputSignature;
585 return PatchConstantSignature;
594 using PartData = DXContainer::PartIterator::PartData;
619 void moveSectionNext(
DataRefImpl &Sec)
const override;
625 getSectionContents(
DataRefImpl Sec)
const override;
628 bool isSectionCompressed(
DataRefImpl Sec)
const override;
629 bool isSectionText(
DataRefImpl Sec)
const override;
630 bool isSectionData(
DataRefImpl Sec)
const override;
632 bool isSectionVirtual(
DataRefImpl Sec)
const override;
637 void moveRelocationNext(
DataRefImpl &Rel)
const override;
647 uint8_t getBytesInAddress()
const override;
648 StringRef getFileFormatName()
const override;
661 bool is64Bit()
const override {
return false; }
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static StringRef getSymbolName(SymbolKind SymKind)
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
static FeatureBitset getFeatures(MCSubtargetInfo &STI, StringRef CPU, StringRef TuneCPU, StringRef FS, ArrayRef< StringRef > ProcNames, ArrayRef< SubtargetSubTypeKV > ProcDesc, ArrayRef< SubtargetFeatureKV > ProcFeatures)
This file defines the SmallVector class.
static std::unique_ptr< PDBSymbol > getSymbolType(const PDBSymbol &Symbol)
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.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
typename SuperClass::const_iterator const_iterator
void push_back(const T &Elt)
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.
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
constexpr bool empty() const
empty - Check if the string is empty.
constexpr size_t size() const
size - Get the string size.
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
A table of densely packed, null-terminated strings indexed by offset.
constexpr size_t size() const
Returns the byte size of the table.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM_ABI std::string str() const
Return the twine contents as a std::string.
A range adaptor for a pair of iterators.
basic_symbol_iterator symbol_end() const override
static bool classof(const Binary *v)
const dxbc::Header & getHeader() const
bool isRelocatableObject() const override
True if this is a relocatable object (.o/.obj).
void moveSymbolNext(DataRefImpl &Symb) const override
const DXContainer & getDXContainer() const
bool is64Bit() const override
basic_symbol_iterator symbol_begin() const override
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 > getShaderFeatureFlags() const
const std::optional< DXILData > & getDXIL() const
const std::optional< DirectX::PSVRuntimeInfo > & getPSVInfo() const
const dxbc::Header & getHeader() const
const DirectX::Signature & getInputSignature() const
std::pair< dxbc::ProgramHeader, const char * > DXILData
std::optional< DirectX::RootSignature > getRootSignature() const
StringRef getData() const
PartIterator begin() const
static LLVM_ABI Expected< DXContainer > create(MemoryBufferRef Object)
std::optional< dxbc::ShaderHash > getShaderHash() const
const DirectX::Signature & getOutputSignature() const
const DirectX::Signature & getPatchConstantSignature() 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
LLVM_ABI uint8_t getSigInputCount() const
ViewArray< uint32_t > getPatchOrPrimMasks() const
LLVM_ABI 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
LLVM_ABI uint8_t getSigOutputCount() const
SigElementArray getSigOutputElements() const
const InfoStruct & getInfo() const
ViewArray< uint32_t > getPatchOutputMap() const
const T * getInfoAs() const
llvm::Expected< RootParameterView > getParameter(const dxbc::RTS0::v1::RootParameterHeader &Header) const
uint32_t getVersion() const
llvm::iterator_range< samplers_iterator > samplers() const
uint32_t getFlags() const
uint32_t getStaticSamplersOffset() const
uint32_t getRootParametersOffset() const
RootSignature(StringRef PD)
uint32_t getNumStaticSamplers() const
llvm::iterator_range< param_header_iterator > param_headers() const
uint32_t getNumParameters() const
uint32_t getNumRootParameters() const
ViewArray< dxbc::ProgramSignatureElement >::iterator begin() const
LLVM_ABI Error initialize(StringRef Part)
ViewArray< dxbc::ProgramSignatureElement >::iterator end() const
StringRef getName(uint32_t Offset) const
This class is the base class for all object file types.
This is a value type class that represents a single symbol in the list of symbols in the object file.
This class implements an extremely fast bulk output stream that can only output to a stream.
@ C
The default llvm calling convention, compatible with C.
bool isValidParameterType(uint32_t V)
static Error parseFailed(const Twine &Msg)
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.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
constexpr std::underlying_type_t< Enum > to_underlying(Enum E)
Returns underlying integer value of an enum.
llvm::Expected< DescriptorTable< T > > read()
static bool classof(const RootParameterView *V)
ViewArray< T >::iterator begin() const
ViewArray< T >::iterator end() const
static bool classof(const RootParameterView *V)
llvm::Expected< dxbc::RTS0::v1::RootConstants > read()
llvm::Expected< dxbc::RTS0::v2::RootDescriptor > read(uint32_t Version)
static bool classof(const RootParameterView *V)
RootParameterView(const dxbc::RTS0::v1::RootParameterHeader &H, StringRef P)
Expected< T > readParameter()
const dxbc::RTS0::v1::RootParameterHeader & Header
bool operator!=(const iterator I)
iterator(const ViewArray &A, const char *C)
bool operator==(const iterator I)
iterator(const iterator &)=default
static constexpr uint32_t MaxStride()
ViewArray(StringRef D, size_t S)