1//===- DXILPrettyPrinter.cpp - Print resources for textual DXIL -----------===// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7//===----------------------------------------------------------------------===// 25case dxil::ResourceClass::SRV:
27case dxil::ResourceClass::UAV:
29case dxil::ResourceClass::CBuffer:
31case dxil::ResourceClass::Sampler:
39case dxil::ResourceClass::SRV:
41case dxil::ResourceClass::UAV:
43case dxil::ResourceClass::CBuffer:
45case dxil::ResourceClass::Sampler:
54case dxil::ElementType::I1:
56case dxil::ElementType::I16:
58case dxil::ElementType::U16:
60case dxil::ElementType::I32:
62case dxil::ElementType::U32:
64case dxil::ElementType::I64:
66case dxil::ElementType::U64:
68case dxil::ElementType::F16:
70case dxil::ElementType::F32:
72case dxil::ElementType::F64:
74case dxil::ElementType::SNormF16:
76case dxil::ElementType::UNormF16:
78case dxil::ElementType::SNormF32:
80case dxil::ElementType::UNormF32:
82case dxil::ElementType::SNormF64:
84case dxil::ElementType::UNormF64:
86case dxil::ElementType::PackedS8x32:
88case dxil::ElementType::PackedU8x32:
90case dxil::ElementType::Invalid:
103case dxil::ResourceKind::Texture1D:
105case dxil::ResourceKind::Texture2D:
107case dxil::ResourceKind::Texture3D:
109case dxil::ResourceKind::TextureCube:
111case dxil::ResourceKind::Texture1DArray:
113case dxil::ResourceKind::Texture2DArray:
115case dxil::ResourceKind::TextureCubeArray:
117case dxil::ResourceKind::TBuffer:
119case dxil::ResourceKind::FeedbackTexture2D:
121case dxil::ResourceKind::FeedbackTexture2DArray:
123case dxil::ResourceKind::Texture2DMS:
125case dxil::ResourceKind::Texture2DMSArray:
127case dxil::ResourceKind::Invalid:
128case dxil::ResourceKind::NumEntries:
129case dxil::ResourceKind::CBuffer:
130case dxil::ResourceKind::RawBuffer:
131case dxil::ResourceKind::Sampler:
132case dxil::ResourceKind::StructuredBuffer:
133case dxil::ResourceKind::TypedBuffer:
134case dxil::ResourceKind::RTAccelerationStructure:
141structFormatResourceDimension
151if (Item.isMultiSample())
152OS << Item.getMultiSampleCount();
159elseif (Item.getUAV().HasCounter)
168// TODO: dxc would print "ras" here. Can/should this happen? 181 RC(RTI.getResourceClass()) {}
188structFormatBindingLocation
195 RC(RTI.getResourceClass()) {}
198constauto &Binding = Item.getBinding();
201OS <<
",space" << Binding.Space;
205structFormatBindingSize
212if (
Size == std::numeric_limits<uint32_t>::max())
224// Column widths are arbitrary but match the widths DXC uses. 225OS <<
";\n; Resource Bindings:\n;\n";
226OS <<
formatv(
"; {0,-30} {1,10} {2,7} {3,11} {4,7} {5,14} {6,9}\n",
"Name",
227"Type",
"Format",
"Dim",
"ID",
"HLSL Bind",
"Count");
229"; {0,-+30} {1,-+10} {2,-+7} {3,-+11} {4,-+7} {5,-+14} {6,-+9}\n",
"",
"",
232// TODO: Do we want to sort these by binding or something like that? 238"Old and new cbuffer representations can't coexist");
239assert((RC != dxil::ResourceClass::UAV || !MDResources.
hasUAVs()) &&
240"Old and new UAV representations can't coexist");
245 FormatResourceDimension Dim(RTI);
246 FormatBindingID
ID(RBI, RTI);
247 FormatBindingLocation Bind(RBI, RTI);
248 FormatBindingSize Count(RBI);
249OS <<
formatv(
"; {0,-30} {1,10} {2,7} {3,11} {4,7} {5,14} {6,9}\n",
Name,
250Type, Format, Dim,
ID, Bind, Count);
285return"DXIL Metadata Pretty Printer";
288bool runOnModule(
Module &M)
override;
298char DXILPrettyPrinterLegacy::ID = 0;
300"DXIL Metadata Pretty Printer",
true,
true)
307bool DXILPrettyPrinterLegacy::runOnModule(
Module &M) {
309 getAnalysis<DXILResourceBindingWrapperPass>().getBindingMap();
311 getAnalysis<DXILResourceTypeWrapperPass>().getResourceTypeMap();
312dxil::Resources &Res = getAnalysis<DXILResourceMDWrapper>().getDXILResource();
318returnnew DXILPrettyPrinterLegacy(
OS);
static void prettyPrintResources(raw_ostream &OS, const DXILBindingMap &DBM, DXILResourceTypeMap &DRTM, const dxil::Resources &MDResources)
static StringRef getTextureDimName(dxil::ResourceKind RK)
static StringRef getRCPrefix(dxil::ResourceClass RC)
static StringRef getFormatName(const dxil::ResourceTypeInfo &RI)
dxil pretty DXIL Metadata Pretty Printer
static StringRef getRCName(dxil::ResourceClass RC)
This header defines various interfaces for pass management in LLVM.
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)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A container for analyses that lazily runs them and caches their results.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
void setPreservesAll()
Set by analyses that do not transform their input at all.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &)
Analysis pass that exposes the DXILResource for a module.
The legacy pass manager's analysis pass to compute DXIL resource information.
Root of the metadata hierarchy.
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.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
StringRef - Represent a constant reference to a string, i.e.
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
TypedInfo getTyped() const
void printUAVs(raw_ostream &OS) const
void printCBuffers(raw_ostream &OS) const
This class implements an extremely fast bulk output stream that can only output to a stream.
virtual void format(raw_ostream &S, StringRef Options)=0
#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.
ResourceKind
The kind of resource for an SRV or UAV resource.
@ RTAccelerationStructure
This is an optimization pass for GlobalISel generic memory operations.
void initializeDXILPrettyPrinterLegacyPass(PassRegistry &)
Initializer for DXILPrettyPrinter.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
ModulePass * createDXILPrettyPrinterLegacyPass(raw_ostream &OS)
Pass to pretty print DXIL metadata.
dxil::ElementType ElementTy