Polly 22.0.0git
ScopGraphPrinter.h
Go to the documentation of this file.
1//===- GraphPrinter.h - Create a DOT output describing the Scop. ----------===//
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// Create a DOT output describing the Scop.
10//
11// For each function a dot file is created that shows the control flow graph of
12// the function and highlights the detected Scops.
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef POLLY_SCOP_GRAPH_PRINTER_H
17#define POLLY_SCOP_GRAPH_PRINTER_H
18
19#include "polly/ScopDetection.h"
21#include "llvm/Analysis/DOTGraphTraitsPass.h"
22#include "llvm/Analysis/RegionInfo.h"
23#include "llvm/Analysis/RegionIterator.h"
24#include "llvm/Analysis/RegionPrinter.h"
25
26namespace llvm {
27
28template <>
29struct GraphTraits<polly::ScopDetection *> : GraphTraits<RegionInfo *> {
33 static nodes_iterator nodes_begin(polly::ScopDetection *SD) {
34 return nodes_iterator::begin(getEntryNode(SD));
35 }
36 static nodes_iterator nodes_end(polly::ScopDetection *SD) {
37 return nodes_iterator::end(getEntryNode(SD));
38 }
39};
40
41template <>
42struct DOTGraphTraits<polly::ScopDetection *> : DOTGraphTraits<RegionNode *> {
43 DOTGraphTraits(bool isSimple = false)
44 : DOTGraphTraits<RegionNode *>(isSimple) {}
45 static std::string getGraphName(polly::ScopDetection *SD) {
46 return "Scop Graph";
47 }
48
49 std::string getEdgeAttributes(RegionNode *srcNode,
52
53 std::string getNodeLabel(RegionNode *Node, polly::ScopDetection *SD) {
55 Node, reinterpret_cast<RegionNode *>(SD->getRI()->getTopLevelRegion()));
56 }
57
58 static std::string escapeString(llvm::StringRef String);
59
60 /// Print the cluster of the subregions. This groups the single basic blocks
61 /// and adds a different background color for each group.
62 static void printRegionCluster(polly::ScopDetection *SD, const Region *R,
63 raw_ostream &O, unsigned depth = 0);
64
66 GraphWriter<polly::ScopDetection *> &GW);
67};
68} // end namespace llvm
69
70namespace polly {
71
72extern std::string ViewFilter;
73extern bool ViewAll;
74
75struct ScopViewer final : llvm::DOTGraphTraitsViewer<ScopAnalysis, false> {
76 ScopViewer() : llvm::DOTGraphTraitsViewer<ScopAnalysis, false>("scops") {}
77
78 bool processFunction(Function &F, const ScopDetection &SD) override;
79};
80
81struct ScopOnlyViewer final : llvm::DOTGraphTraitsViewer<ScopAnalysis, false> {
83 : llvm::DOTGraphTraitsViewer<ScopAnalysis, false>("scops-only") {}
84};
85
86struct ScopPrinter final : llvm::DOTGraphTraitsPrinter<ScopAnalysis, false> {
87 ScopPrinter() : llvm::DOTGraphTraitsPrinter<ScopAnalysis, false>("scops") {}
88};
89
90struct ScopOnlyPrinter final : llvm::DOTGraphTraitsPrinter<ScopAnalysis, true> {
92 : llvm::DOTGraphTraitsPrinter<ScopAnalysis, true>("scopsonly") {}
93};
94
95} // end namespace polly
96
97#endif /* POLLY_SCOP_GRAPH_PRINTER_H */
Pass to detect the maximal static control parts (Scops) of a function.
RegionInfo * getRI() const
Get the RegionInfo stored in this pass.
std::string ViewFilter
static void addCustomGraphFeatures(polly::ScopDetection *SD, GraphWriter< polly::ScopDetection * > &GW)
static std::string escapeString(llvm::StringRef String)
static void printRegionCluster(polly::ScopDetection *SD, const Region *R, raw_ostream &O, unsigned depth=0)
Print the cluster of the subregions.
static std::string getGraphName(polly::ScopDetection *SD)
std::string getEdgeAttributes(RegionNode *srcNode, GraphTraits< RegionInfo * >::ChildIteratorType CI, polly::ScopDetection *SD)
std::string getNodeLabel(RegionNode *Node, polly::ScopDetection *SD)
static NodeRef getEntryNode(polly::ScopDetection *SD)
static nodes_iterator nodes_begin(polly::ScopDetection *SD)
static nodes_iterator nodes_end(polly::ScopDetection *SD)
bool processFunction(Function &F, const ScopDetection &SD) override