131 return "fbtex2darray";
150struct FormatResourceDimension
152 FormatResourceDimension(
const dxil::ResourceTypeInfo &RI,
bool HasCounter)
153 : llvm::FormatAdapter<
const dxil::ResourceTypeInfo &>(RI),
154 HasCounter(HasCounter) {}
158 void format(llvm::raw_ostream &OS, StringRef Style) {
163 if (Item.isMultiSample())
164 OS << Item.getMultiSampleCount();
167 case dxil::ResourceKind::RawBuffer:
168 case dxil::ResourceKind::StructuredBuffer:
176 case dxil::ResourceKind::TypedBuffer:
179 case dxil::ResourceKind::CBuffer:
182 case dxil::ResourceKind::RTAccelerationStructure:
189struct FormatBindingID
193 explicit FormatBindingID(
const dxil::ResourceInfo &RI,
194 const dxil::ResourceTypeInfo &RTI)
195 : llvm::FormatAdapter<
const dxil::ResourceInfo &>(RI),
196 RC(RTI.getResourceClass()) {}
198 void format(llvm::raw_ostream &OS, StringRef Style) {
203struct FormatBindingLocation
207 explicit FormatBindingLocation(
const dxil::ResourceInfo &RI,
208 const dxil::ResourceTypeInfo &RTI)
209 : llvm::FormatAdapter<
const dxil::ResourceInfo &>(RI),
210 RC(RTI.getResourceClass()) {}
212 void format(llvm::raw_ostream &OS, StringRef Style) {
213 const auto &
Binding = Item.getBinding();
216 OS <<
",space" <<
Binding.Space;
220struct FormatBindingSize
222 explicit FormatBindingSize(
const dxil::ResourceInfo &RI)
223 : llvm::FormatAdapter<
const dxil::ResourceInfo &>(RI) {}
225 void format(llvm::raw_ostream &OS, StringRef Style) {
226 uint32_t
Size = Item.getBinding().Size;
239 OS <<
";\n; Resource Bindings:\n;\n";
240 OS <<
formatv(
"; {0,-30} {1,10} {2,7} {3,11} {4,7} {5,14} {6,9}\n",
"Name",
241 "Type",
"Format",
"Dim",
"ID",
"HLSL Bind",
"Count");
243 "; {0,-+30} {1,-+10} {2,-+7} {3,-+11} {4,-+7} {5,-+14} {6,-+9}\n",
"",
"",
248 if (!RI.hasBinding())
256 FormatResourceDimension Dim(RTI, RI.hasCounter());
257 FormatBindingID ID(RI, RTI);
258 FormatBindingLocation Bind(RI, RTI);
259 FormatBindingSize
Count(RI);
260 OS <<
formatv(
"; {0,-30} {1,10} {2,7} {3,11} {4,7} {5,14} {6,9}\n", Name,
275 ModuleSlotTracker &MST;
276 AbstractSlotTrackerStorage &STS;
277 const DXILDebugInfoMap &DI;
278 DenseSet<const MDNode *> &EmittedMDNodes;
281 DXILAssemblyAnnotationWriter(ModuleSlotTracker &MST,
282 AbstractSlotTrackerStorage &STS,
283 const DXILDebugInfoMap &DI,
284 DenseSet<const MDNode *> &EmittedMDNodes)
285 : MST(MST), STS(STS), DI(DI), EmittedMDNodes(EmittedMDNodes) {}
287 void emitInstructionAnnot(
const Instruction *OrigI,
288 formatted_raw_ostream &os)
override {
289 if (
const Instruction *
I = &DI.getDXILInstruction(*OrigI);
I != OrigI) {
290 os <<
"; DXIL: to be replaced with: ";
296 void emitMDNodeAnnot(
const MDNode *
N, formatted_raw_ostream &os)
override {
297 EmittedMDNodes.insert(
N);
299 if (
const Metadata *NewMD = DI.MDReplace.lookup(
N)) {
301 STS.createMetadataSlot(NewN);
304 N->printAsOperand(os, MST);
305 os <<
": to be replaced by: ";
306 NewMD->printAsOperand(os, MST);
311 if (
const Metadata *ExtraMD = DI.MDExtra.lookup(
N)) {
313 STS.createMetadataSlot(ExtraN);
316 N->printAsOperand(os, MST);
317 os <<
": additional data: ";
318 ExtraMD->printAsOperand(os, MST);
330 M.renumberMetadataForAssembly();
337 assert(STS &&
"Slot tracker storage should have been initialised");
341 ReplacementMetadata.
insert(Replacement);
345 auto AddOriginal = [&](
const Metadata *MD) {
352 AddOriginal(Original);
353 for (
auto [Original,
_] : DI.
MDExtra)
354 AddOriginal(Original);
358 for (
auto [
_,
N] : OriginalNodes)
362 auto AddAdditional = [&](
const Metadata *MD) {
369 while (!Nodes.
empty()) {
380 for (
size_t I = 0;
I != Worklist.
size(); ++
I) {
383 AddAdditional(Replacement);
388 return AdditionalMetadata;
400 DXILModuleSlotTracker MST(&M);
401 MST.renumberMetadataForAssembly(AdditionalMetadata);
408 assert(STS &&
"Slot tracker storage should have been initialised");
411 DXILAssemblyAnnotationWriter DAAW(MST, *STS, DI, EmittedMDNodes);
415 MST.collectMDNodes(MDNodes);
416 std::sort(MDNodes.
begin(), MDNodes.
end(),
417 [](
const std::pair<unsigned, const MDNode *> &
A,
418 const std::pair<unsigned, const MDNode *> &
B) {
419 return A.first < B.first;
421 for (
auto [
_,
MDNode] : MDNodes) {
424 DAAW.emitMDNodeAnnot(
MDNode, FOS);
447 StringRef getPassName()
const override {
return "DXIL Pretty Printer"; }
449 bool runOnModule(
Module &M)
override;
450 void getAnalysisUsage(AnalysisUsage &AU)
const override {
457char DXILPrettyPrinterLegacy::ID = 0;
459 "DXIL Pretty Printer",
true,
false)
465bool DXILPrettyPrinterLegacy::runOnModule(
Module &M) {
467 getAnalysis<DXILResourceWrapperPass>().getResourceMap();
469 getAnalysis<DXILResourceTypeWrapperPass>().getResourceTypeMap();
475 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 SmallVector< const MDNode * > collectAdditionalMetadata(Module &M, const DXILDebugInfoMap &DI)
static StringRef getRCName(dxil::ResourceClass RC)
DXIL Resource Implicit Binding
This file defines the DenseSet and SmallDenseSet classes.
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)
This file defines the SmallVector class.
Abstract interface of slot tracker storage.
virtual int getMetadataSlot(const MDNode *)=0
AnalysisUsage & addRequired()
PreservedAnalyses run(Module &M, ModuleAnalysisManager &)
ValueT lookup(const_arg_type_t< KeyT > Val) const
Return the entry for the specified key, or a default constructed value if no such entry exists.
Implements a dense probed hash-table based set.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Tracking metadata reference owned by Metadata.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Manage lifetime of a slot tracker for printing IR.
ModuleSlotTracker(SlotTracker &Machine, const Module *M, const Function *F=nullptr)
Wrap a preinitialized SlotTracker.
void renumberMetadataForAssembly(ArrayRef< const MDNode * > AdditionalMetadata, MachineMDNodeListType *AdditionalMetadataNodes=nullptr) const
Renumber module metadata and then additional metadata for canonical assembly output.
void setProcessHook(std::function< void(AbstractSlotTrackerStorage *, const Module *)>)
SmallVector< std::pair< unsigned, const MDNode * >, 0 > MachineMDNodeListType
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 all()
Construct a special preserved set that preserves all passes.
reference emplace_back(ArgTypes &&... Args)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
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.
std::pair< iterator, bool > insert(const ValueT &V)
bool contains(const_arg_type_t< ValueT > V) const
Check if the set contains the given element.
MDMap MDExtra
Enumerate extra metadata when Key is encountered in ValueEnumerator.
MDMap MDReplace
Completely replace one metadata with another in ValueEnumerator.
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.
ResourceKind
The kind of resource for an SRV or UAV resource.
@ RTAccelerationStructure
DXILDebugInfoMap collectDXILDebugInfo(Module &M)
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 dyn_cast_or_null(const Y &Val)
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
auto reverse(ContainerTy &&C)
void sort(IteratorTy Start, IteratorTy End)
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
DWARFExpression::Operation Op
ModulePass * createDXILPrettyPrinterLegacyPass(raw_ostream &OS)
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
dxil::ElementType DXILStorageTy