Polly 19.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#include "llvm/IR/PassManager.h"
26
27namespace llvm {
28
29template <>
30struct GraphTraits<polly::ScopDetection *> : GraphTraits<RegionInfo *> {
31 static NodeRef getEntryNode(polly::ScopDetection *SD) {
33 }
34 static nodes_iterator nodes_begin(polly::ScopDetection *SD) {
35 return nodes_iterator::begin(getEntryNode(SD));
36 }
37 static nodes_iterator nodes_end(polly::ScopDetection *SD) {
38 return nodes_iterator::end(getEntryNode(SD));
39 }
40};
41
42template <>
43struct DOTGraphTraits<polly::ScopDetection *> : DOTGraphTraits<RegionNode *> {
44 DOTGraphTraits(bool isSimple = false)
45 : DOTGraphTraits<RegionNode *>(isSimple) {}
46 static std::string getGraphName(polly::ScopDetection *SD) {
47 return "Scop Graph";
48 }
49
50 std::string getEdgeAttributes(RegionNode *srcNode,
53
54 std::string getNodeLabel(RegionNode *Node, polly::ScopDetection *SD) {
56 Node, reinterpret_cast<RegionNode *>(SD->getRI()->getTopLevelRegion()));
57 }
58
59 static std::string escapeString(llvm::StringRef String);
60
61 /// Print the cluster of the subregions. This groups the single basic blocks
62 /// and adds a different background color for each group.
63 static void printRegionCluster(polly::ScopDetection *SD, const Region *R,
64 raw_ostream &O, unsigned depth = 0);
65
67 GraphWriter<polly::ScopDetection *> &GW);
68};
69} // end namespace llvm
70
71namespace polly {
72
73struct ScopViewer final : llvm::DOTGraphTraitsViewer<ScopAnalysis, false> {
74 ScopViewer() : llvm::DOTGraphTraitsViewer<ScopAnalysis, false>("scops") {}
75
76 bool processFunction(Function &F, const ScopDetection &SD) override;
77};
78
79struct ScopOnlyViewer final : llvm::DOTGraphTraitsViewer<ScopAnalysis, false> {
81 : llvm::DOTGraphTraitsViewer<ScopAnalysis, false>("scops-only") {}
82};
83
84struct ScopPrinter final : llvm::DOTGraphTraitsPrinter<ScopAnalysis, false> {
85 ScopPrinter() : llvm::DOTGraphTraitsPrinter<ScopAnalysis, false>("scops") {}
86};
87
88struct ScopOnlyPrinter final : llvm::DOTGraphTraitsPrinter<ScopAnalysis, true> {
90 : llvm::DOTGraphTraitsPrinter<ScopAnalysis, true>("scopsonly") {}
91};
92
93} // end namespace polly
94
95#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.
This file contains the declaration of the PolyhedralInfo class, which will provide an interface to ex...
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