LLVM 20.0.0git
MachineCFGPrinter.h
Go to the documentation of this file.
1//===-- MachineCFGPrinter.h -------------------------------------*- C++ -*-===//
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//===----------------------------------------------------------------------===//
10
16
17namespace llvm {
18
19template <class GraphType> struct GraphTraits;
21private:
22 const MachineFunction *F;
23
24public:
26
27 const MachineFunction *getFunction() const { return this->F; }
28};
29
30template <>
34 return &(CFGInfo->getFunction()->front());
35 }
36
37 // nodes_iterator/begin/end - Allow iteration over all nodes in the graph
39
41 return nodes_iterator(CFGInfo->getFunction()->begin());
42 }
43
45 return nodes_iterator(CFGInfo->getFunction()->end());
46 }
47
48 static size_t size(DOTMachineFuncInfo *CFGInfo) {
49 return CFGInfo->getFunction()->size();
50 }
51};
52
53template <>
55
57
58 static void eraseComment(std::string &OutStr, unsigned &I, unsigned Idx) {
59 OutStr.erase(OutStr.begin() + I, OutStr.begin() + Idx);
60 --I;
61 }
62
63 static std::string getSimpleNodeLabel(const MachineBasicBlock *Node,
66 }
67
68 static std::string getCompleteNodeLabel(
71 HandleBasicBlock =
73 const MachineBasicBlock &Node) -> void { OS << Node; },
74 function_ref<void(std::string &, unsigned &, unsigned)>
75 HandleComment = eraseComment) {
76 return CompleteNodeLabelString(Node, HandleBasicBlock, HandleComment);
77 }
78
80 DOTMachineFuncInfo *CFGInfo) {
81 if (isSimple())
82 return getSimpleNodeLabel(Node, CFGInfo);
83
84 return getCompleteNodeLabel(Node, CFGInfo);
85 }
86
87 static std::string getGraphName(DOTMachineFuncInfo *CFGInfo) {
88 return "Machine CFG for '" + CFGInfo->getFunction()->getName().str() +
89 "' function";
90 }
91};
92} // namespace llvm
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
static bool isSimple(Instruction *I)
raw_pwrite_stream & OS
DOTMachineFuncInfo(const MachineFunction *F)
const MachineFunction * getFunction() const
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
unsigned size() const
const MachineBasicBlock & front() const
std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:215
An efficient, type-erasing, non-owning reference to a callable.
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:661
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
std::string SimpleNodeLabelString(const BasicBlockT *Node)
Definition: CFGPrinter.h:128
std::string CompleteNodeLabelString(const BasicBlockT *Node, function_ref< void(raw_string_ostream &, const BasicBlockT &)> HandleBasicBlock, function_ref< void(std::string &, unsigned &, unsigned)> HandleComment)
Definition: CFGPrinter.h:140
static std::string getGraphName(DOTMachineFuncInfo *CFGInfo)
static std::string getSimpleNodeLabel(const MachineBasicBlock *Node, DOTMachineFuncInfo *)
static void eraseComment(std::string &OutStr, unsigned &I, unsigned Idx)
std::string getNodeLabel(const MachineBasicBlock *Node, DOTMachineFuncInfo *CFGInfo)
static std::string getCompleteNodeLabel(const MachineBasicBlock *Node, DOTMachineFuncInfo *, function_ref< void(raw_string_ostream &, const MachineBasicBlock &)> HandleBasicBlock=[](raw_string_ostream &OS, const MachineBasicBlock &Node) -> void { OS<< Node;}, function_ref< void(std::string &, unsigned &, unsigned)> HandleComment=eraseComment)
DOTGraphTraits - Template class that can be specialized to customize how graphs are converted to 'dot...
DefaultDOTGraphTraits - This class provides the default implementations of all of the DOTGraphTraits ...
static NodeRef getEntryNode(DOTMachineFuncInfo *CFGInfo)
static size_t size(DOTMachineFuncInfo *CFGInfo)
static nodes_iterator nodes_end(DOTMachineFuncInfo *CFGInfo)
static nodes_iterator nodes_begin(DOTMachineFuncInfo *CFGInfo)