PandA-2024.02
cdfg_edge_info.cpp
Go to the documentation of this file.
1 /*
2  *
3  * _/_/_/ _/_/ _/ _/ _/_/_/ _/_/
4  * _/ _/ _/ _/ _/_/ _/ _/ _/ _/ _/
5  * _/_/_/ _/_/_/_/ _/ _/_/ _/ _/ _/_/_/_/
6  * _/ _/ _/ _/ _/ _/ _/ _/ _/
7  * _/ _/ _/ _/ _/ _/_/_/ _/ _/
8  *
9  * ***********************************************
10  * PandA Project
11  * URL: http://panda.dei.polimi.it
12  * Politecnico di Milano - DEIB
13  * System Architectures Group
14  * ***********************************************
15  * Copyright (C) 2004-2024 Politecnico di Milano
16  *
17  * This file is part of the PandA framework.
18  *
19  * The PandA framework is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <http://www.gnu.org/licenses/>.
31  *
32  */
43 #include "cdfg_edge_info.hpp"
44 #include "behavioral_helper.hpp"
45 #include <utility> // for pair
46 
48 {
49  if(labels.find(CDG_SELECTOR) == labels.end())
50  {
51  return false;
52  }
53  return labels.find(CDG_SELECTOR)->second.find(T_COND) != labels.find(CDG_SELECTOR)->second.end();
54 }
55 
57 {
58  if(labels.find(CDG_SELECTOR) == labels.end())
59  {
60  return false;
61  }
62  return labels.find(CDG_SELECTOR)->second.find(F_COND) != labels.find(CDG_SELECTOR)->second.end();
63 }
64 
66 {
67  if(labels.find(CFG_SELECTOR) == labels.end())
68  {
69  return false;
70  }
71  return labels.find(CFG_SELECTOR)->second.find(T_COND) != labels.find(CFG_SELECTOR)->second.end();
72 }
73 
75 {
76  if(labels.find(CFG_SELECTOR) == labels.end())
77  {
78  return false;
79  }
80  return labels.find(CFG_SELECTOR)->second.find(F_COND) != labels.find(CFG_SELECTOR)->second.end();
81 }
82 
84 {
85  return not CdgEdgeT() and not CdgEdgeF() and not CfgEdgeT() and not CfgEdgeF() and
86  (labels.find(CDG_SELECTOR) != labels.end() or labels.find(CFG_SELECTOR) != labels.end());
87 }
88 
89 const std::string CdfgEdgeInfo::PrintLabels(const int selector, const BehavioralHelperConstRef BH) const
90 {
91  if(labels.find(selector) == labels.end())
92  {
93  return "";
94  }
95  std::string ret;
96  const CustomOrderedSet<unsigned int>& labels_to_be_printed = labels.find(selector)->second;
97  CustomOrderedSet<unsigned int>::const_iterator label, label_end = labels_to_be_printed.end();
98  for(label = labels_to_be_printed.begin(); label != label_end; ++label)
99  {
100  if(label != labels_to_be_printed.begin())
101  {
102  ret += ", ";
103  }
104  if(*label == T_COND)
105  {
106  ret = "T";
107  }
108  else if(*label == F_COND)
109  {
110  ret = "F";
111  }
112  else if(*label == default_COND)
113  {
114  ret = "default";
115  }
116  else
117  {
118  ret += BH->PrintVariable(*label);
119  }
120  }
121  return ret;
122 }
123 
124 void CdfgEdgeInfo::add_nodeID(unsigned int _nodeID, const int type)
125 {
126  labels[type].insert(_nodeID);
127 }
128 
130 {
131  static CustomOrderedSet<unsigned int> null_set;
132  if(labels.find(selector) != labels.end())
133  {
134  return labels.find(selector)->second;
135  }
136  return null_set;
137 }
bool CdgEdgeT() const
Function returning true when the edge is a then control dependence edge.
bool Switch() const
Return true if it is an edge associated with a switch.
#define CDG_SELECTOR
Control dependence edge selector.
#define default_COND
constant used to represent label "default" of a switch construct
const std::string PrintLabels(const int selector, const BehavioralHelperConstRef BH) const
Return the string of the labels associated with the edge.
std::map< int, CustomOrderedSet< unsigned int > > labels
edge labels; key is the selector
#define T_COND
constant used to represent control edges representing a true edge of a conditional statement...
const CustomOrderedSet< unsigned int > & get_nodeID(const int selector) const
Return the nodeID of type type associated with this edge information.
std::string PrintVariable(unsigned int var) const
Print the name of the variable associated to the index.
void add_nodeID(unsigned int nodeID, const int type)
Add a nodeID of type type to this edge_info.
Data structures used to represent an edge in operation and basic block graphs.
bool CfgEdgeF() const
Function returning true when the edge is an else control flow edge.
bool CdgEdgeF() const
Function returning true when the edge is an else control dependence edge.
bool CfgEdgeT() const
Function returning true when the edge is a then control flow edge.
#define F_COND
constant used to represent control edges representing a false edge of a conditional statement...
#define CFG_SELECTOR
Control flow graph edge selector.

Generated on Mon Feb 12 2024 13:02:50 for PandA-2024.02 by doxygen 1.8.13