129 return "fbtex2darray";
148struct FormatResourceDimension
150 FormatResourceDimension(
const dxil::ResourceTypeInfo &RI,
bool HasCounter)
151 : llvm::FormatAdapter<
const dxil::ResourceTypeInfo &>(RI),
152 HasCounter(HasCounter) {}
156 void format(llvm::raw_ostream &OS, StringRef Style)
override {
161 if (Item.isMultiSample())
162 OS << Item.getMultiSampleCount();
165 case dxil::ResourceKind::RawBuffer:
166 case dxil::ResourceKind::StructuredBuffer:
174 case dxil::ResourceKind::TypedBuffer:
177 case dxil::ResourceKind::CBuffer:
180 case dxil::ResourceKind::RTAccelerationStructure:
187struct FormatBindingID
191 explicit FormatBindingID(
const dxil::ResourceInfo &RI,
192 const dxil::ResourceTypeInfo &RTI)
193 : llvm::FormatAdapter<
const dxil::ResourceInfo &>(RI),
194 RC(RTI.getResourceClass()) {}
196 void format(llvm::raw_ostream &OS, StringRef Style)
override {
201struct FormatBindingLocation
205 explicit FormatBindingLocation(
const dxil::ResourceInfo &RI,
206 const dxil::ResourceTypeInfo &RTI)
207 : llvm::FormatAdapter<
const dxil::ResourceInfo &>(RI),
208 RC(RTI.getResourceClass()) {}
210 void format(llvm::raw_ostream &OS, StringRef Style)
override {
211 const auto &
Binding = Item.getBinding();
214 OS <<
",space" <<
Binding.Space;
218struct FormatBindingSize
220 explicit FormatBindingSize(
const dxil::ResourceInfo &RI)
221 : llvm::FormatAdapter<
const dxil::ResourceInfo &>(RI) {}
223 void format(llvm::raw_ostream &OS, StringRef Style)
override {
224 uint32_t
Size = Item.getBinding().Size;
237 OS <<
";\n; Resource Bindings:\n;\n";
238 OS <<
formatv(
"; {0,-30} {1,10} {2,7} {3,11} {4,7} {5,14} {6,9}\n",
"Name",
239 "Type",
"Format",
"Dim",
"ID",
"HLSL Bind",
"Count");
241 "; {0,-+30} {1,-+10} {2,-+7} {3,-+11} {4,-+7} {5,-+14} {6,-+9}\n",
"",
"",
252 FormatResourceDimension Dim(RTI, RI.hasCounter());
253 FormatBindingID
ID(RI, RTI);
254 FormatBindingLocation Bind(RI, RTI);
255 FormatBindingSize
Count(RI);
256 OS <<
formatv(
"; {0,-30} {1,10} {2,7} {3,11} {4,7} {5,14} {6,9}\n", Name,
265 ModuleSlotTracker &MST;
266 AbstractSlotTrackerStorage &STS;
267 const DXILDebugInfoMap &DI;
270 DXILAssemblyAnnotationWriter(ModuleSlotTracker &MST,
271 AbstractSlotTrackerStorage &STS,
272 const DXILDebugInfoMap &DI)
273 : MST(MST), STS(STS), DI(DI) {}
275 void emitInstructionAnnot(
const Instruction *OrigI,
276 formatted_raw_ostream &os)
override {
277 if (
const Instruction *
I = &DI.getDXILInstruction(*OrigI);
I != OrigI) {
278 os <<
"; DXIL: to be replaced with: ";
284 void emitMDNodeAnnot(
const MDNode *
N, formatted_raw_ostream &os)
override {
285 if (
const Metadata *NewMD = DI.MDReplace.lookup(
N)) {
287 if (STS.getMetadataSlot(NewN) == -1)
288 STS.createMetadataSlot(NewN);
291 N->printAsOperand(os, MST);
292 os <<
": to be replaced by: ";
293 NewMD->printAsOperand(os, MST);
298 if (
const Metadata *ExtraMD = DI.MDExtra.lookup(
N)) {
300 if (STS.getMetadataSlot(ExtraN) == -1)
301 STS.createMetadataSlot(ExtraN);
304 N->printAsOperand(os, MST);
305 os <<
": additional data: ";
306 ExtraMD->printAsOperand(os, MST);
324 unsigned NextMetadataSlot = 0;
333 assert(STS &&
"Slot tracker storage should have been initialised");
335 DXILAssemblyAnnotationWriter DAAW(MST, *STS, DI);
340 std::sort(MDNodes.begin(), MDNodes.end(),
341 [](
const std::pair<unsigned, const MDNode *> &
A,
342 const std::pair<unsigned, const MDNode *> &
B) {
343 return A.first < B.first;
345 for (
auto [
_,
MDNode] : MDNodes) {
346 DAAW.emitMDNodeAnnot(
MDNode, FOS);
369 StringRef getPassName()
const override {
return "DXIL Pretty Printer"; }
371 bool runOnModule(
Module &M)
override;
372 void getAnalysisUsage(AnalysisUsage &AU)
const override {
379char DXILPrettyPrinterLegacy::ID = 0;
381 "DXIL Pretty Printer",
true,
true)
387bool DXILPrettyPrinterLegacy::runOnModule(
Module &M) {
389 getAnalysis<DXILResourceWrapperPass>().getResourceMap();
391 getAnalysis<DXILResourceTypeWrapperPass>().getResourceTypeMap();
397 return new DXILPrettyPrinterLegacy(OS);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static StringRef getTextureDimName(dxil::ResourceKind RK)
static void prettyPrintResources(raw_ostream &OS, const DXILResourceMap &DRM, DXILResourceTypeMap &DRTM)
static StringRef getRCPrefix(dxil::ResourceClass RC)
static StringRef getFormatName(const dxil::ResourceTypeInfo &RI)
static void prettyPrint(raw_ostream &OS, Module &M, const DXILResourceMap &DRM, DXILResourceTypeMap &DRTM)
static StringRef getRCName(dxil::ResourceClass RC)
DXIL Resource Implicit Binding
Module.h This file contains the declarations for the Module class.
This header defines various interfaces for pass management in LLVM.
Machine Check Debug Module
ModuleAnalysisManager MAM
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Abstract interface of slot tracker storage.
virtual unsigned getNextMetadataSlot()=0
AnalysisUsage & addRequired()
PreservedAnalyses run(Module &M, ModuleAnalysisManager &)
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Manage lifetime of a slot tracker for printing IR.
std::vector< std::pair< unsigned, const MDNode * > > MachineMDNodeListType
void collectMDNodes(MachineMDNodeListType &L, unsigned LB, unsigned UB) const
void setProcessHook(std::function< void(AbstractSlotTrackerStorage *, const Module *, bool)>)
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.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
Represent a constant reference to a string, i.e.
LLVM_ABI std::string upper() const
Convert the given ASCII string to uppercase.
The instances of the Type class are immutable: once they are created, they are never changed.
dxil::ResourceClass getResourceClass() const
LLVM_ABI bool isSampler() const
LLVM_ABI bool isTyped() const
LLVM_ABI bool isCBuffer() const
LLVM_ABI TypedInfo getTyped() const
LLVM_ABI bool isStruct() const
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
DXILDebugInfoMap run(Module &M)
ResourceKind
The kind of resource for an SRV or UAV resource.
@ RTAccelerationStructure
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
FunctionAddr VTableAddr Count
LLVM_ABI raw_ostream & nulls()
This returns a reference to a raw_ostream which simply discards output.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
ModulePass * createDXILPrettyPrinterLegacyPass(raw_ostream &OS)
Pass to pretty print DXIL metadata.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
dxil::ElementType DXILStorageTy