9#ifndef LLVM_ANALYSIS_DXILRESOURCE_H
10#define LLVM_ANALYSIS_DXILRESOURCE_H
28class DXILResourceTypeMap;
56 return T->getName() ==
"dx.RawBuffer";
59 return isa<TargetExtType>(
T) &&
classof(cast<TargetExtType>(
T));
78 return T->getName() ==
"dx.TypedBuffer";
81 return isa<TargetExtType>(
T) &&
classof(cast<TargetExtType>(
T));
103 return T->getName() ==
"dx.Texture";
106 return isa<TargetExtType>(
T) &&
classof(cast<TargetExtType>(
T));
128 return T->getName() ==
"dx.MSTexture";
131 return isa<TargetExtType>(
T) &&
classof(cast<TargetExtType>(
T));
152 return T->getName() ==
"dx.FeedbackTexture";
155 return isa<TargetExtType>(
T) &&
classof(cast<TargetExtType>(
T));
172 return T->getName() ==
"dx.CBuffer";
175 return isa<TargetExtType>(
T) &&
classof(cast<TargetExtType>(
T));
193 return T->getName() ==
"dx.Sampler";
196 return isa<TargetExtType>(
T) &&
classof(cast<TargetExtType>(
T));
211 std::tie(
RHS.GloballyCoherent,
RHS.HasCounter,
RHS.IsROV);
216 std::tie(
RHS.GloballyCoherent,
RHS.HasCounter,
RHS.IsROV);
243 std::tie(
RHS.ElementTy,
RHS.ElementCount);
248 std::tie(
RHS.ElementTy,
RHS.ElementCount);
258 bool GloballyCoherent;
267 bool HasCounter =
false);
269 bool HasCounter =
false)
271 GloballyCoherent, HasCounter) {}
319 std::tie(
RHS.RecordID,
RHS.Space,
RHS.LowerBound,
RHS.Size);
322 return !(*
this ==
RHS);
326 std::tie(
RHS.RecordID,
RHS.Space,
RHS.LowerBound,
RHS.Size);
331 ResourceBinding Binding;
339 : Binding{RecordID, Space, LowerBound,
Size}, HandleTy(HandleTy),
352 std::pair<uint32_t, uint32_t>
356 return std::tie(Binding, HandleTy, Symbol) ==
357 std::tie(
RHS.Binding,
RHS.HandleTy,
RHS.Symbol);
360 return !(*
this ==
RHS);
363 return Binding <
RHS.Binding;
382 auto It = Infos.
find(Ty);
383 if (It != Infos.
end())
385 auto [NewIt, Inserted] = Infos.
try_emplace(Ty, Ty);
386 return NewIt->second;
409 virtual void anchor();
426 unsigned FirstUAV = 0;
427 unsigned FirstCBuffer = 0;
428 unsigned FirstSampler = 0;
445 auto Pos = CallMap.
find(Key);
446 return Pos == CallMap.
end() ? Infos.
end() : (Infos.
begin() + Pos->second);
450 auto Pos = CallMap.
find(Key);
451 return Pos == CallMap.
end() ? Infos.
end() : (Infos.
begin() + Pos->second);
528 std::unique_ptr<DXILBindingMap> Map;
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This header defines various interfaces for pass management in LLVM.
This file implements a map that provides insertion order iteration.
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.
iterator_range< const_iterator > srvs() const
iterator_range< iterator > cbuffers()
iterator find(const CallInst *Key)
const_iterator sampler_end() const
iterator_range< const_iterator > samplers() const
void print(raw_ostream &OS, DXILResourceTypeMap &DRTM, const DataLayout &DL) const
const_iterator sampler_begin() const
const_iterator begin() const
const_iterator cbuffer_end() const
const_iterator srv_begin() const
iterator_range< iterator > srvs()
const_iterator find(const CallInst *Key) const
iterator_range< iterator > samplers()
iterator_range< const_iterator > uavs() const
iterator_range< const_iterator > cbuffers() const
const_iterator end() const
const_iterator uav_end() const
const_iterator cbuffer_begin() const
const_iterator srv_end() const
const_iterator uav_begin() const
iterator_range< iterator > uavs()
DXILBindingMap run(Module &M, ModuleAnalysisManager &AM)
Gather resource info for the module M.
Printer pass for the DXILResourceBindingAnalysis results.
DXILResourceBindingPrinterPass(raw_ostream &OS)
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
bool runOnModule(Module &M) override
runOnModule - Virtual method overriden by subclasses to process the module being operated on.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
~DXILResourceBindingWrapperPass() override
DXILResourceBindingWrapperPass()
void print(raw_ostream &OS, const Module *M) const override
print - Print out the internal state of the pass.
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
const DXILBindingMap & getBindingMap() const
DXILBindingMap & getBindingMap()
DXILResourceTypeMap run(Module &M, ModuleAnalysisManager &AM)
DXILResourceTypeMap Result
dxil::ResourceTypeInfo & operator[](TargetExtType *Ty)
bool invalidate(Module &M, const PreservedAnalyses &PA, ModuleAnalysisManager::Invalidator &Inv)
DXILResourceTypeWrapperPass()
DXILResourceTypeMap & getResourceTypeMap()
const DXILResourceTypeMap & getResourceTypeMap() 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'.
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)
uint32_t getCBufferSize() const
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.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
const StringRef getName() const
bool operator==(const ResourceBindingInfo &RHS) const
void setBindingID(unsigned ID)
bool operator<(const ResourceBindingInfo &RHS) const
GlobalVariable * createSymbol(Module &M, StructType *Ty, StringRef Name="")
std::pair< uint32_t, uint32_t > getAnnotateProps(Module &M, dxil::ResourceTypeInfo &RTI) const
TargetExtType * getHandleTy() const
MDTuple * getAsMetadata(Module &M, dxil::ResourceTypeInfo &RTI) const
ResourceBindingInfo(uint32_t RecordID, uint32_t Space, uint32_t LowerBound, uint32_t Size, TargetExtType *HandleTy, GlobalVariable *Symbol=nullptr)
const ResourceBinding & getBinding() const
bool operator!=(const ResourceBindingInfo &RHS) const
void print(raw_ostream &OS, dxil::ResourceTypeInfo &RTI, const DataLayout &DL) const
dxil::ResourceClass getResourceClass() const
uint32_t getMultiSampleCount() const
uint32_t getCBufferSize(const DataLayout &DL) const
bool operator<(const ResourceTypeInfo &RHS) const
bool isMultiSample() const
dxil::SamplerType getSamplerType() const
void setHasCounter(bool V)
TypedInfo getTyped() const
bool operator!=(const ResourceTypeInfo &RHS) const
TargetExtType * getHandleTy() const
StructType * createElementStruct()
ResourceTypeInfo(TargetExtType *HandleTy, bool GloballyCoherent=false, bool HasCounter=false)
void setGloballyCoherent(bool V)
StructInfo getStruct(const DataLayout &DL) const
dxil::SamplerFeedbackType getFeedbackType() const
dxil::ResourceKind getResourceKind() const
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)
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.
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.
ModulePass * createDXILResourceTypeWrapperPassPass()
ModulePass * createDXILResourceBindingWrapperPassPass()
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...
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 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