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) {
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) {
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) {
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) {
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",
"",
"",
246 if (!RI.hasBinding())
254 FormatResourceDimension Dim(RTI, RI.hasCounter());
255 FormatBindingID ID(RI, RTI);
256 FormatBindingLocation Bind(RI, RTI);
257 FormatBindingSize
Count(RI);
258 OS <<
formatv(
"; {0,-30} {1,10} {2,7} {3,11} {4,7} {5,14} {6,9}\n", Name,
267 ModuleSlotTracker &MST;
268 AbstractSlotTrackerStorage &STS;
269 const DXILDebugInfoMap &DI;
272 DXILAssemblyAnnotationWriter(ModuleSlotTracker &MST,
273 AbstractSlotTrackerStorage &STS,
274 const DXILDebugInfoMap &DI)
275 : MST(MST), STS(STS), DI(DI) {}
277 void emitInstructionAnnot(
const Instruction *OrigI,
278 formatted_raw_ostream &os)
override {
279 if (
const Instruction *
I = &DI.getDXILInstruction(*OrigI);
I != OrigI) {
280 os <<
"; DXIL: to be replaced with: ";
286 void emitMDNodeAnnot(
const MDNode *
N, formatted_raw_ostream &os)
override {
287 if (
const Metadata *NewMD = DI.MDReplace.lookup(
N)) {
289 if (STS.getMetadataSlot(NewN) == -1)
290 STS.createMetadataSlot(NewN);
293 N->printAsOperand(os, MST);
294 os <<
": to be replaced by: ";
295 NewMD->printAsOperand(os, MST);
300 if (
const Metadata *ExtraMD = DI.MDExtra.lookup(
N)) {
302 if (STS.getMetadataSlot(ExtraN) == -1)
303 STS.createMetadataSlot(ExtraN);
306 N->printAsOperand(os, MST);
307 os <<
": additional data: ";
308 ExtraMD->printAsOperand(os, MST);
326 unsigned NextMetadataSlot = 0;
335 assert(STS &&
"Slot tracker storage should have been initialised");
337 DXILAssemblyAnnotationWriter DAAW(MST, *STS, DI);
342 std::sort(MDNodes.begin(), MDNodes.end(),
343 [](
const std::pair<unsigned, const MDNode *> &
A,
344 const std::pair<unsigned, const MDNode *> &
B) {
345 return A.first < B.first;
347 for (
auto [
_,
MDNode] : MDNodes) {
348 DAAW.emitMDNodeAnnot(
MDNode, FOS);
371 StringRef getPassName()
const override {
return "DXIL Pretty Printer"; }
373 bool runOnModule(
Module &M)
override;
374 void getAnalysisUsage(AnalysisUsage &AU)
const override {
381char DXILPrettyPrinterLegacy::ID = 0;
383 "DXIL Pretty Printer",
true,
true)
389bool DXILPrettyPrinterLegacy::runOnModule(
Module &M) {
391 getAnalysis<DXILResourceWrapperPass>().getResourceMap();
393 getAnalysis<DXILResourceTypeWrapperPass>().getResourceTypeMap();
399 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.
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)
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.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
ModulePass * createDXILPrettyPrinterLegacyPass(raw_ostream &OS)
Pass to pretty print DXIL metadata.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
dxil::ElementType DXILStorageTy