LLVM 20.0.0git
DXILPrettyPrinter.cpp
Go to the documentation of this file.
1//===- DXILPrettyPrinter.cpp - Print resources for textual DXIL -----------===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
9#include "DXILPrettyPrinter.h"
11#include "DirectX.h"
12#include "llvm/ADT/StringRef.h"
13#include "llvm/IR/PassManager.h"
14#include "llvm/Pass.h"
16
17using namespace llvm;
18
20 const dxil::Resources &MDResources) {
21 MDResources.print(OS);
22}
23
26 const dxil::Resources &MDResources = MAM.getResult<DXILResourceMDAnalysis>(M);
27 prettyPrintResources(OS, MDResources);
29}
30
31namespace {
32class DXILPrettyPrinterLegacy : public llvm::ModulePass {
33 raw_ostream &OS; // raw_ostream to print to.
34
35public:
36 static char ID;
37 DXILPrettyPrinterLegacy() : ModulePass(ID), OS(dbgs()) {
39 }
40
41 explicit DXILPrettyPrinterLegacy(raw_ostream &O) : ModulePass(ID), OS(O) {
43 }
44
45 StringRef getPassName() const override {
46 return "DXIL Metadata Pretty Printer";
47 }
48
49 bool runOnModule(Module &M) override;
50 void getAnalysisUsage(AnalysisUsage &AU) const override {
51 AU.setPreservesAll();
53 }
54};
55} // namespace
56
57char DXILPrettyPrinterLegacy::ID = 0;
58INITIALIZE_PASS_BEGIN(DXILPrettyPrinterLegacy, "dxil-pretty-printer",
59 "DXIL Metadata Pretty Printer", true, true)
61INITIALIZE_PASS_END(DXILPrettyPrinterLegacy, "dxil-pretty-printer",
62 "DXIL Metadata Pretty Printer", true, true)
63
64bool DXILPrettyPrinterLegacy::runOnModule(Module &M) {
65 dxil::Resources &Res = getAnalysis<DXILResourceMDWrapper>().getDXILResource();
66 Res.print(OS);
67 return false;
68}
69
71 return new DXILPrettyPrinterLegacy(OS);
72}
basic Basic Alias true
static void prettyPrintResources(raw_ostream &OS, const dxil::Resources &MDResources)
dxil pretty printer
dxil pretty DXIL Metadata Pretty Printer
ModuleAnalysisManager MAM
This header defines various interfaces for pass management in LLVM.
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition: PassSupport.h:55
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:57
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:52
raw_pwrite_stream & OS
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:253
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Definition: PassManager.h:405
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.
Definition: Metadata.h:62
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Definition: Pass.h:251
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
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.
Definition: Analysis.h:111
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: Analysis.h:117
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
void print(raw_ostream &O) const
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
void initializeDXILPrettyPrinterLegacyPass(PassRegistry &)
Initializer for DXILPrettyPrinter.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
ModulePass * createDXILPrettyPrinterLegacyPass(raw_ostream &OS)
Pass to pretty print DXIL metadata.