132 return "fbtex2darray";
151struct FormatResourceDimension
153 FormatResourceDimension(
const dxil::ResourceTypeInfo &RI,
bool HasCounter)
154 : llvm::FormatAdapter<
const dxil::ResourceTypeInfo &>(RI),
155 HasCounter(HasCounter) {}
159 void format(llvm::raw_ostream &OS, StringRef Style) {
164 if (Item.isMultiSample())
165 OS << Item.getMultiSampleCount();
168 case dxil::ResourceKind::RawBuffer:
169 case dxil::ResourceKind::StructuredBuffer:
177 case dxil::ResourceKind::TypedBuffer:
180 case dxil::ResourceKind::CBuffer:
183 case dxil::ResourceKind::RTAccelerationStructure:
190struct FormatBindingID
194 explicit FormatBindingID(
const dxil::ResourceInfo &RI,
195 const dxil::ResourceTypeInfo &RTI)
196 : llvm::FormatAdapter<
const dxil::ResourceInfo &>(RI),
197 RC(RTI.getResourceClass()) {}
199 void format(llvm::raw_ostream &OS, StringRef Style) {
204struct FormatBindingLocation
208 explicit FormatBindingLocation(
const dxil::ResourceInfo &RI,
209 const dxil::ResourceTypeInfo &RTI)
210 : llvm::FormatAdapter<
const dxil::ResourceInfo &>(RI),
211 RC(RTI.getResourceClass()) {}
213 void format(llvm::raw_ostream &OS, StringRef Style) {
214 const auto &
Binding = Item.getBinding();
217 OS <<
",space" <<
Binding.Space;
221struct FormatBindingSize
223 explicit FormatBindingSize(
const dxil::ResourceInfo &RI)
224 : llvm::FormatAdapter<
const dxil::ResourceInfo &>(RI) {}
226 void format(llvm::raw_ostream &OS, StringRef Style) {
227 uint32_t
Size = Item.getBinding().Size;
240 OS <<
";\n; Resource Bindings:\n;\n";
241 OS <<
formatv(
"; {0,-30} {1,10} {2,7} {3,11} {4,7} {5,14} {6,9}\n",
"Name",
242 "Type",
"Format",
"Dim",
"ID",
"HLSL Bind",
"Count");
244 "; {0,-+30} {1,-+10} {2,-+7} {3,-+11} {4,-+7} {5,-+14} {6,-+9}\n",
"",
"",
249 if (!RI.hasBinding())
257 FormatResourceDimension Dim(RTI, RI.hasCounter());
258 FormatBindingID ID(RI, RTI);
259 FormatBindingLocation Bind(RI, RTI);
260 FormatBindingSize
Count(RI);
261 OS <<
formatv(
"; {0,-30} {1,10} {2,7} {3,11} {4,7} {5,14} {6,9}\n", Name,
276 ModuleSlotTracker &MST;
277 AbstractSlotTrackerStorage &STS;
278 const DXILDebugInfoMap &DI;
279 DenseSet<const MDNode *> &EmittedMDNodes;
282 DXILAssemblyAnnotationWriter(ModuleSlotTracker &MST,
283 AbstractSlotTrackerStorage &STS,
284 const DXILDebugInfoMap &DI,
285 DenseSet<const MDNode *> &EmittedMDNodes)
286 : MST(MST), STS(STS), DI(DI), EmittedMDNodes(EmittedMDNodes) {}
288 void emitInstructionAnnot(
const Instruction *OrigI,
289 formatted_raw_ostream &os)
override {
290 if (
const Instruction *
I = &DI.getDXILInstruction(*OrigI);
I != OrigI) {
291 os <<
"; DXIL: to be replaced with: ";
297 void emitMDNodeAnnot(
const MDNode *
N, formatted_raw_ostream &os)
override {
298 EmittedMDNodes.insert(
N);
300 if (
const Metadata *NewMD = DI.MDReplace.lookup(
N)) {
302 STS.createMetadataSlot(NewN);
305 N->printAsOperand(os, MST);
306 os <<
": to be replaced by: ";
307 NewMD->printAsOperand(os, MST);
312 if (
const Metadata *ExtraMD = DI.MDExtra.lookup(
N)) {
314 STS.createMetadataSlot(ExtraN);
317 N->printAsOperand(os, MST);
318 os <<
": additional data: ";
319 ExtraMD->printAsOperand(os, MST);
331 M.renumberMetadataForAssembly();
338 assert(STS &&
"Slot tracker storage should have been initialised");
342 ReplacementMetadata.
insert(Replacement);
346 auto AddOriginal = [&](
const Metadata *MD) {
353 AddOriginal(Original);
354 for (
auto [Original,
_] : DI.
MDExtra)
355 AddOriginal(Original);
359 for (
auto [
_,
N] : OriginalNodes)
363 auto AddAdditional = [&](
const Metadata *MD) {
370 while (!Nodes.
empty()) {
381 for (
size_t I = 0;
I != Worklist.
size(); ++
I) {
384 AddAdditional(Replacement);
389 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);
448 StringRef getPassName()
const override {
return "DXIL Pretty Printer"; }
450 bool runOnModule(
Module &M)
override;
451 void getAnalysisUsage(AnalysisUsage &AU)
const override {
458char DXILPrettyPrinterLegacy::ID = 0;
460 "DXIL Pretty Printer",
true,
false)
466bool DXILPrettyPrinterLegacy::runOnModule(
Module &M) {
468 getAnalysis<DXILResourceWrapperPass>().getResourceMap();
470 getAnalysis<DXILResourceTypeWrapperPass>().getResourceTypeMap();
477 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 void prettyPrint(raw_ostream &OS, Module &M, const DXILResourceMap &DRM, DXILResourceTypeMap &DRTM, const DXILDebugInfoMap &DI)
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 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 none()
Convenience factory function for the empty preserved set.
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.
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 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)
Pass to pretty print DXIL metadata.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
dxil::ElementType DXILStorageTy