MimIR 0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
domfrontier.h
Go to the documentation of this file.
1#pragma once
2
3#include "mim/analyses/cfg.h"
4
5namespace mim {
6
7/// A Dominance Frontier Graph.
8/// The template parameter @p forward determines whether to compute
9/// regular dominance frontiers or post-dominance frontiers (i.e. control dependence).
10/// This template parameter is associated with @p CFG's @c forward parameter.
11/// See Cooper et al, 2001. A Simple, Fast Dominance Algorithm: http://www.cs.rice.edu/~keith/EMBED/dom.pdf
12template<bool forward> class DomFrontierBase {
13public:
16
18 : cfg_(cfg)
19 , preds_(cfg)
20 , succs_(cfg) {
21 create();
22 }
23
24 const CFG<forward>& cfg() const { return cfg_; }
25 const std::vector<const CFNode*>& preds(const CFNode* n) const { return preds_[n]; }
26 const std::vector<const CFNode*>& succs(const CFNode* n) const { return succs_[n]; }
27
28private:
29 void create();
30 void link(const CFNode* src, const CFNode* dst) {
31 succs_[src].push_back(dst);
32 preds_[dst].push_back(src);
33 }
34
35 const CFG<forward>& cfg_;
36 typename CFG<forward>::template Map<std::vector<const CFNode*>> preds_;
37 typename CFG<forward>::template Map<std::vector<const CFNode*>> succs_;
38};
39
40/// @name Control Flow
41///@{
44///@}
45
46} // namespace mim
A Control-Flow Graph.
Definition scope.h:8
A Control-Flow Node.
Definition cfg.h:27
A Dominance Frontier Graph.
Definition domfrontier.h:12
DomFrontierBase & operator=(DomFrontierBase)=delete
const CFG< forward > & cfg() const
Definition domfrontier.h:24
const std::vector< const CFNode * > & succs(const CFNode *n) const
Definition domfrontier.h:26
DomFrontierBase(const CFG< forward > &cfg)
Definition domfrontier.h:17
const std::vector< const CFNode * > & preds(const CFNode *n) const
Definition domfrontier.h:25
DomFrontierBase(const DomFrontierBase &)=delete
Definition cfg.h:11