9#ifndef LLVM_ANALYSIS_DXILRESOURCE_H
10#define LLVM_ANALYSIS_DXILRESOURCE_H
32class DXILResourceTypeMap;
64 return T->getName() ==
"dx.RawBuffer";
67 return isa<TargetExtType>(
T) &&
classof(cast<TargetExtType>(
T));
86 return T->getName() ==
"dx.TypedBuffer";
89 return isa<TargetExtType>(
T) &&
classof(cast<TargetExtType>(
T));
111 return T->getName() ==
"dx.Texture";
114 return isa<TargetExtType>(
T) &&
classof(cast<TargetExtType>(
T));
136 return T->getName() ==
"dx.MSTexture";
139 return isa<TargetExtType>(
T) &&
classof(cast<TargetExtType>(
T));
160 return T->getName() ==
"dx.FeedbackTexture";
163 return isa<TargetExtType>(
T) &&
classof(cast<TargetExtType>(
T));
179 return T->getName() ==
"dx.CBuffer";
182 return isa<TargetExtType>(
T) &&
classof(cast<TargetExtType>(
T));
200 return T->getName() ==
"dx.Sampler";
203 return isa<TargetExtType>(
T) &&
classof(cast<TargetExtType>(
T));
214 return isa<RawBufferExtType>(
T) || isa<TypedBufferExtType>(
T) ||
215 isa<TextureExtType>(
T) || isa<MSTextureExtType>(
T) ||
216 isa<FeedbackTextureExtType>(
T) || isa<CBufferExtType>(
T) ||
217 isa<SamplerExtType>(
T);
221 return isa<TargetExtType>(
T) &&
classof(cast<TargetExtType>(
T));
239 return T->getName() ==
"dx.Layout";
242 return isa<TargetExtType>(
T) &&
classof(cast<TargetExtType>(
T));
281 std::tie(
RHS.ElementTy,
RHS.ElementCount);
286 std::tie(
RHS.ElementTy,
RHS.ElementCount);
353 std::tie(
RHS.RecordID,
RHS.Space,
RHS.LowerBound,
RHS.Size);
356 return !(*
this ==
RHS);
360 std::tie(
RHS.RecordID,
RHS.Space,
RHS.LowerBound,
RHS.Size);
365 if (
Size == UINT32_MAX)
372 ResourceBinding Binding;
384 :
Binding{RecordID, Space, LowerBound,
Size}, HandleTy(HandleTy),
385 Name(Name), Symbol(Symbol) {}
401 LLVM_ABI std::pair<uint32_t, uint32_t>
405 return std::tie(
Binding, HandleTy, Symbol, Name) ==
406 std::tie(
RHS.Binding,
RHS.HandleTy,
RHS.Symbol,
RHS.Name);
429 auto It = Infos.
find(Ty);
430 if (It != Infos.
end())
432 auto [NewIt, Inserted] = Infos.
try_emplace(Ty, Ty);
433 return NewIt->second;
456 virtual void anchor();
475 unsigned FirstUAV = 0;
476 unsigned FirstCBuffer = 0;
477 unsigned FirstSampler = 0;
478 bool HasInvalidDirection =
false;
485 void populateCounterDirections(
Module &M);
506 auto Pos = CallMap.
find(Key);
507 return Pos == CallMap.
end() ? Infos.
end() : (Infos.
begin() + Pos->second);
511 auto Pos = CallMap.
find(Key);
512 return Pos == CallMap.
end() ? Infos.
end() : (Infos.
begin() + Pos->second);
604 std::unique_ptr<DXILResourceMap> Map;
617 bool runOnModule(
Module &M)
override;
618 void releaseMemory()
override;
641 bool HasImplicitBinding =
false;
642 bool HasOverlappingBinding =
false;
676 std::unique_ptr<DXILResourceBindingInfo> BindingInfo;
688 bool runOnModule(
Module &M)
override;
689 void releaseMemory()
override;
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
DXIL Resource Implicit Binding
This header defines various interfaces for pass management in LLVM.
This file implements a map that provides insertion order iteration.
This file defines the SmallVector class.
API to communicate dependencies between analyses during invalidation.
A container for analyses that lazily runs them and caches their results.
Represent the analysis usage information of a pass.
This class represents a function call, abstracting a target machine's calling convention.
LLVM_ABI DXILResourceMap run(Module &M, ModuleAnalysisManager &AM)
Gather resource info for the module M.
LLVM_ABI DXILResourceBindingInfo run(Module &M, ModuleAnalysisManager &AM)
bool hasOverlappingBinding() const
bool hasImplicitBinding() const
void setHasImplicitBinding(bool Value)
std::optional< uint32_t > findAvailableBinding(dxil::ResourceClass RC, uint32_t Space, int32_t Size)
void setHasOverlappingBinding(bool Value)
const DXILResourceBindingInfo & getBindingInfo() const
DXILResourceBindingInfo & getBindingInfo()
~DXILResourceBindingWrapperPass() override
const_iterator sampler_end() const
iterator find(const CallInst *Key)
bool hasInvalidCounterDirection() const
const_iterator find(const CallInst *Key) const
iterator_range< iterator > samplers()
iterator_range< const_iterator > uavs() const
const_iterator cbuffer_end() const
iterator_range< const_iterator > srvs() const
call_iterator call_begin()
const_iterator uav_begin() const
const_iterator begin() const
iterator_range< const_iterator > samplers() const
LLVM_ABI void print(raw_ostream &OS, DXILResourceTypeMap &DRTM, const DataLayout &DL) const
const_iterator srv_begin() const
iterator_range< iterator > srvs()
iterator_range< iterator > cbuffers()
iterator_range< iterator > uavs()
iterator_range< call_iterator > calls()
const_iterator uav_end() const
const_iterator sampler_begin() const
const_iterator cbuffer_begin() const
const_iterator srv_end() const
iterator_range< const_iterator > cbuffers() const
const_iterator end() const
Printer pass for the DXILResourceAnalysis results.
DXILResourcePrinterPass(raw_ostream &OS)
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
DXILResourceTypeMap run(Module &M, ModuleAnalysisManager &AM)
DXILResourceTypeMap Result
dxil::ResourceTypeInfo & operator[](TargetExtType *Ty)
LLVM_ABI bool invalidate(Module &M, const PreservedAnalyses &PA, ModuleAnalysisManager::Invalidator &Inv)
DXILResourceTypeMap & getResourceTypeMap()
const DXILResourceTypeMap & getResourceTypeMap() const
DXILResourceMap & getResourceMap()
~DXILResourceWrapperPass() override
const DXILResourceMap & getResourceMap() const
A parsed version of the target data layout string in and methods for querying it.
iterator find(const_arg_type_t< KeyT > Val)
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
ImmutablePass class - This class is used to provide information that does not need to be run.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
A Module instance is used to store all the information related to an LLVM module.
A set of analyses that are preserved following a run of a transformation pass.
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.
Class to represent struct types.
Class to represent target extensions types, which are generally unintrospectable from target-independ...
Type * getTypeParameter(unsigned i) const
unsigned getIntParameter(unsigned i) const
The instances of the Type class are immutable: once they are created, they are never changed.
bool isIntegerTy() const
True if this is an instance of IntegerType.
bool isVoidTy() const
Return true if this is 'void'.
LLVM Value Representation.
static bool classof(const Type *T)
AnyResourceExtType & operator=(const AnyResourceExtType &)=delete
static bool classof(const TargetExtType *T)
AnyResourceExtType(const AnyResourceExtType &)=delete
AnyResourceExtType()=delete
The dx.CBuffer target extension type.
static bool classof(const TargetExtType *T)
CBufferExtType & operator=(const CBufferExtType &)=delete
CBufferExtType(const CBufferExtType &)=delete
static bool classof(const Type *T)
Type * getResourceType() const
The dx.FeedbackTexture target extension type.
dxil::SamplerFeedbackType getFeedbackType() const
FeedbackTextureExtType(const FeedbackTextureExtType &)=delete
dxil::ResourceKind getDimension() const
FeedbackTextureExtType & operator=(const FeedbackTextureExtType &)=delete
static bool classof(const TargetExtType *T)
FeedbackTextureExtType()=delete
static bool classof(const Type *T)
The dx.Layout target extension type.
static bool classof(const Type *T)
LayoutExtType(const LayoutExtType &)=delete
LayoutExtType & operator=(const LayoutExtType &)=delete
static bool classof(const TargetExtType *T)
uint32_t getOffsetOfElement(int I) const
Type * getWrappedType() const
The dx.MSTexture target extension type.
dxil::ResourceKind getDimension() const
MSTextureExtType(const MSTextureExtType &)=delete
static bool classof(const TargetExtType *T)
MSTextureExtType()=delete
Type * getResourceType() const
uint32_t getSampleCount() const
static bool classof(const Type *T)
MSTextureExtType & operator=(const MSTextureExtType &)=delete
The dx.RawBuffer target extension type.
static bool classof(const TargetExtType *T)
bool isStructured() const
RawBufferExtType()=delete
RawBufferExtType(const RawBufferExtType &)=delete
static bool classof(const Type *T)
RawBufferExtType & operator=(const RawBufferExtType &)=delete
Type * getResourceType() const
StringRef getName() const
bool operator<(const ResourceInfo &RHS) const
bool operator!=(const ResourceInfo &RHS) const
TargetExtType * getHandleTy() const
LLVM_ABI std::pair< uint32_t, uint32_t > getAnnotateProps(Module &M, dxil::ResourceTypeInfo &RTI) const
LLVM_ABI void print(raw_ostream &OS, dxil::ResourceTypeInfo &RTI, const DataLayout &DL) const
ResourceInfo(uint32_t RecordID, uint32_t Space, uint32_t LowerBound, uint32_t Size, TargetExtType *HandleTy, StringRef Name="", GlobalVariable *Symbol=nullptr)
void setBindingID(unsigned ID)
bool operator==(const ResourceInfo &RHS) const
const ResourceBinding & getBinding() const
LLVM_ABI GlobalVariable * createSymbol(Module &M, StructType *Ty)
LLVM_ABI MDTuple * getAsMetadata(Module &M, dxil::ResourceTypeInfo &RTI) const
ResourceCounterDirection CounterDirection
dxil::ResourceClass getResourceClass() const
LLVM_ABI uint32_t getMultiSampleCount() const
LLVM_ABI uint32_t getCBufferSize(const DataLayout &DL) const
LLVM_ABI bool operator<(const ResourceTypeInfo &RHS) const
LLVM_ABI bool isUAV() const
LLVM_ABI bool isMultiSample() const
LLVM_ABI bool isSampler() const
LLVM_ABI bool isTyped() const
LLVM_ABI dxil::SamplerType getSamplerType() const
LLVM_ABI bool isCBuffer() const
LLVM_ABI TypedInfo getTyped() const
bool operator!=(const ResourceTypeInfo &RHS) const
LLVM_ABI StructType * createElementStruct(StringRef CBufferName="")
TargetExtType * getHandleTy() const
LLVM_ABI bool isFeedback() const
ResourceTypeInfo(TargetExtType *HandleTy)
LLVM_ABI UAVInfo getUAV() const
LLVM_ABI StructInfo getStruct(const DataLayout &DL) const
LLVM_ABI bool isStruct() const
LLVM_ABI dxil::SamplerFeedbackType getFeedbackType() const
dxil::ResourceKind getResourceKind() const
LLVM_ABI void print(raw_ostream &OS, const DataLayout &DL) const
The dx.Sampler target extension type.
SamplerExtType(const SamplerExtType &)=delete
static bool classof(const Type *T)
dxil::SamplerType getSamplerType() const
SamplerExtType & operator=(const SamplerExtType &)=delete
static bool classof(const TargetExtType *T)
The dx.Texture target extension type.
static bool classof(const TargetExtType *T)
dxil::ResourceKind getDimension() const
Type * getResourceType() const
TextureExtType & operator=(const TextureExtType &)=delete
TextureExtType(const TextureExtType &)=delete
static bool classof(const Type *T)
The dx.TypedBuffer target extension type.
Type * getResourceType() const
TypedBufferExtType & operator=(const TypedBufferExtType &)=delete
TypedBufferExtType()=delete
static bool classof(const TargetExtType *T)
TypedBufferExtType(const TypedBufferExtType &)=delete
static bool classof(const Type *T)
BindingInfo represents the ranges of bindings and free space for each dxil::ResourceClass.
LLVM_ABI std::optional< uint32_t > findAvailableBinding(dxil::ResourceClass RC, uint32_t Space, int32_t Size)
CRTP base class for adapting an iterator to a different type.
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
ResourceKind
The kind of resource for an SRV or UAV resource.
ElementType
The element type of an SRV or UAV resource.
LLVM_ABI StringRef getResourceNameFromBindingCall(CallInst *CI)
This is an optimization pass for GlobalISel generic memory operations.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
LLVM_ABI ModulePass * createDXILResourceBindingWrapperPassPass()
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
LLVM_ABI ModulePass * createDXILResourceTypeWrapperPassPass()
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI ModulePass * createDXILResourceWrapperPassPass()
Implement std::hash so that hash_code can be used in STL containers.
A CRTP mix-in that provides informational APIs needed for analysis passes.
A special type used by analysis passes to provide an address that identifies that particular analysis...
CallInst * operator*() const
call_iterator(CallMapTy::iterator Iter)
A CRTP mix-in to automatically provide informational APIs needed for passes.
bool operator!=(const ResourceBinding &RHS) const
bool operator==(const ResourceBinding &RHS) const
bool overlapsWith(const ResourceBinding &RHS) const
bool operator<(const ResourceBinding &RHS) const
bool operator==(const StructInfo &RHS) const
bool operator!=(const StructInfo &RHS) const
bool operator<(const StructInfo &RHS) const
bool operator<(const TypedInfo &RHS) const
bool operator==(const TypedInfo &RHS) const
dxil::ElementType ElementTy
bool operator!=(const TypedInfo &RHS) const
bool operator!=(const UAVInfo &RHS) const
bool operator==(const UAVInfo &RHS) const
bool operator<(const UAVInfo &RHS) const