File indexing completed on 2026-05-10 08:43:12
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef LLVM_ANALYSIS_DOMPRINTER_H
0015 #define LLVM_ANALYSIS_DOMPRINTER_H
0016
0017 #include "llvm/Analysis/DOTGraphTraitsPass.h"
0018 #include "llvm/Analysis/PostDominators.h"
0019 #include "llvm/IR/Dominators.h"
0020
0021 namespace llvm {
0022
0023 template <>
0024 struct DOTGraphTraits<DomTreeNode *> : public DefaultDOTGraphTraits {
0025
0026 DOTGraphTraits(bool isSimple = false) : DefaultDOTGraphTraits(isSimple) {}
0027
0028 std::string getNodeLabel(DomTreeNode *Node, DomTreeNode *Graph) {
0029
0030 BasicBlock *BB = Node->getBlock();
0031
0032 if (!BB)
0033 return "Post dominance root node";
0034
0035 if (isSimple())
0036 return DOTGraphTraits<DOTFuncInfo *>::getSimpleNodeLabel(BB, nullptr);
0037
0038 return DOTGraphTraits<DOTFuncInfo *>::getCompleteNodeLabel(BB, nullptr);
0039 }
0040 };
0041
0042 template <>
0043 struct DOTGraphTraits<DominatorTree *>
0044 : public DOTGraphTraits<DomTreeNode *> {
0045
0046 DOTGraphTraits(bool isSimple = false)
0047 : DOTGraphTraits<DomTreeNode *>(isSimple) {}
0048
0049 static std::string getGraphName(DominatorTree *DT) {
0050 return "Dominator tree";
0051 }
0052
0053 std::string getNodeLabel(DomTreeNode *Node, DominatorTree *G) {
0054 return DOTGraphTraits<DomTreeNode *>::getNodeLabel(Node,
0055 G->getRootNode());
0056 }
0057 };
0058
0059 template<>
0060 struct DOTGraphTraits<PostDominatorTree *>
0061 : public DOTGraphTraits<DomTreeNode*> {
0062
0063 DOTGraphTraits (bool isSimple=false)
0064 : DOTGraphTraits<DomTreeNode*>(isSimple) {}
0065
0066 static std::string getGraphName(PostDominatorTree *DT) {
0067 return "Post dominator tree";
0068 }
0069
0070 std::string getNodeLabel(DomTreeNode *Node,
0071 PostDominatorTree *G) {
0072 return DOTGraphTraits<DomTreeNode*>::getNodeLabel(Node, G->getRootNode());
0073 }
0074 };
0075
0076 struct DomViewer final : DOTGraphTraitsViewer<DominatorTreeAnalysis, false> {
0077 DomViewer() : DOTGraphTraitsViewer<DominatorTreeAnalysis, false>("dom") {}
0078 };
0079
0080 struct DomOnlyViewer final : DOTGraphTraitsViewer<DominatorTreeAnalysis, true> {
0081 DomOnlyViewer()
0082 : DOTGraphTraitsViewer<DominatorTreeAnalysis, true>("domonly") {}
0083 };
0084
0085 struct PostDomViewer final
0086 : DOTGraphTraitsViewer<PostDominatorTreeAnalysis, false> {
0087 PostDomViewer()
0088 : DOTGraphTraitsViewer<PostDominatorTreeAnalysis, false>("postdom") {}
0089 };
0090
0091 struct PostDomOnlyViewer final
0092 : DOTGraphTraitsViewer<PostDominatorTreeAnalysis, true> {
0093 PostDomOnlyViewer()
0094 : DOTGraphTraitsViewer<PostDominatorTreeAnalysis, true>("postdomonly") {}
0095 };
0096
0097 struct DomPrinter final : DOTGraphTraitsPrinter<DominatorTreeAnalysis, false> {
0098 DomPrinter() : DOTGraphTraitsPrinter<DominatorTreeAnalysis, false>("dom") {}
0099 };
0100
0101 struct DomOnlyPrinter final
0102 : DOTGraphTraitsPrinter<DominatorTreeAnalysis, true> {
0103 DomOnlyPrinter()
0104 : DOTGraphTraitsPrinter<DominatorTreeAnalysis, true>("domonly") {}
0105 };
0106
0107 struct PostDomPrinter final
0108 : DOTGraphTraitsPrinter<PostDominatorTreeAnalysis, false> {
0109 PostDomPrinter()
0110 : DOTGraphTraitsPrinter<PostDominatorTreeAnalysis, false>("postdom") {}
0111 };
0112
0113 struct PostDomOnlyPrinter final
0114 : DOTGraphTraitsPrinter<PostDominatorTreeAnalysis, true> {
0115 PostDomOnlyPrinter()
0116 : DOTGraphTraitsPrinter<PostDominatorTreeAnalysis, true>("postdomonly") {}
0117 };
0118 }
0119
0120 namespace llvm {
0121 class FunctionPass;
0122 FunctionPass *createDomPrinterWrapperPassPass();
0123 FunctionPass *createDomOnlyPrinterWrapperPassPass();
0124 FunctionPass *createDomViewerWrapperPassPass();
0125 FunctionPass *createDomOnlyViewerWrapperPassPass();
0126 FunctionPass *createPostDomPrinterWrapperPassPass();
0127 FunctionPass *createPostDomOnlyPrinterWrapperPassPass();
0128 FunctionPass *createPostDomViewerWrapperPassPass();
0129 FunctionPass *createPostDomOnlyViewerWrapperPassPass();
0130 }
0131
0132 #endif