Otawa  0.10
Edge.h
Go to the documentation of this file.
1 /*
2  * Edge class interface
3  * Copyright (c) 2003-12, IRIT UPS.
4  *
5  * This file is part of OTAWA
6  *
7  * OTAWA is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * OTAWA is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with OTAWA; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 #ifndef OTAWA_CFG_EDGE_H
22 #define OTAWA_CFG_EDGE_H
23 
24 #include <elm/assert.h>
25 #include <otawa/cfg/CFG.h>
26 
27 namespace otawa {
28 
29 // Classes
30 class BasicBlock;
31 
32 // Edge class
33 class Edge: public PropList {
34  friend class CFG;
35 public:
36  typedef enum kind_t {
37  NONE = 0,
38  TAKEN = 1,
39  NOT_TAKEN = 2,
40  CALL = 3,
41  VIRTUAL = 4,
44  EXN_CALL = 7,
46  } kind_t;
47  static cstring kindName(kind_t kind);
48 
50  ~Edge(void);
51 
52  inline BasicBlock *source(void) const { return src; };
53  inline BasicBlock *target(void) const { return tgt; };
54  inline kind_t kind(void) const { return knd; };
55 
56  inline CFG *calledCFG(void) const {
57  ASSERT(knd == CALL);
58  if(!tgt)
59  return 0;
60  else
61  return ENTRY(tgt);
62  }
63 
64 private:
67  void toCall(void);
68 };
69 
70 Output& operator<<(Output& out, const Edge *edge);
72 
73 // Deprecated
75 #define EDGE_Null Edge::NONE
76 #define EDGE_Taken Edge::TAKEN
77 #define EDGE_NotTaken Edge::NOT_TAKEN
78 #define EDGE_Call Edge::CALL
79 #define EDGE_Virtual Edge::VIRTUAL
80 
81 } // otawa
82 
83 #endif // OTAWA_CFG_EDGE_H
84 
void toCall(void)
Transform this edge as a call edge.
Definition: Edge.cpp:118
dtd::Element edge(dtd::make("edge", _EDGE).attr(source).attr(target).attr(called))
Edges of this kind are only found in a virtual CFG.
Definition: Edge.h:43
Edge(BasicBlock *source, BasicBlock *target, kind_t kind=TAKEN)
Build a new edge.
Definition: Edge.cpp:94
kind_t knd
Definition: Edge.h:65
static cstring kindName(kind_t kind)
Get the name of a kind.
Definition: Edge.cpp:130
kind_t
Kind of the edge.
Definition: Edge.h:36
BasicBlock * source(void) const
Definition: Edge.h:52
kind_t kind(void) const
Definition: Edge.h:54
Kind of an edge matching a sub-program call.
Definition: Edge.h:40
~Edge(void)
Delete an edge.
Definition: Edge.cpp:108
Kind of an edge linking the virtual entry and exit basic blocks with other ones of the CFG...
Definition: Edge.h:41
No meaning.
Definition: Edge.h:37
elm::io::Output & operator<<(elm::io::Output &out, Address addr)
Definition: base.cpp:188
Control Flow Graph representation.
Definition: CFG.h:42
Definition: Edge.h:45
Edge::kind_t edge_kind_t
Definition: Edge.h:74
Edges of this kind are usually added after an analysis of the CFG to denote raise of exception (syste...
Definition: Edge.h:44
sys::SystemOutStream & out
Kind of an edge matching the natural sequential control flow between a basic block and its successor...
Definition: Edge.h:39
BasicBlock * tgt
Definition: Edge.h:66
BasicBlock * src
Definition: Edge.h:66
This class represents edges in the CFG representation.
Definition: Edge.h:33
BasicBlock * target(void) const
Definition: Edge.h:53
This is the minimal definition of a basic block.
Definition: BasicBlock.h:43
Kind of an edge matching a branch instruction.
Definition: Edge.h:38
This a list of properties.
Definition: PropList.h:63
CFG * calledCFG(void) const
Definition: Edge.h:56
Identifier< CFG * > ENTRY
Identifier used for storing and retrieving the CFG on its entry BB.
Edges of this kind are only found in a virtual CFG.
Definition: Edge.h:42