53 #include <boost/tuple/tuple.hpp> 121 return variables.find(variable_type)->second.find(access_type)->second;
134 if(
vertex_name.find(
"_#empty_") != std::string::npos)
140 "Node is not a gimple_node but a " +
GET_NODE(
node)->get_kind_text());
167 stream << name <<
":" << (dotty_format ?
"\\n" :
"\n");
170 for(
const auto& variable : variables)
172 stream << behavioral_helper->
PrintVariable(variable) <<
"(" << variable <<
")" << (dotty_format ?
"\\n" :
"\n");
181 stream << name <<
":" << (dotty_format ?
"\\n" :
"\n");
183 for(
const auto& variable : variables)
185 stream << from_strongtype_cast<int>(variable) << (dotty_format ?
"\\n" :
"\n");
193 for(
const auto& local_variables :
variables)
195 if(local_variables.second.size())
197 stream << name <<
":" << (dotty_format ?
"\\n" :
"\n");
199 behavioral_helper, dotty_format);
201 behavioral_helper, dotty_format);
203 behavioral_helper, dotty_format);
205 behavioral_helper, dotty_format);
215 for(
const auto& local_variables :
variables)
217 if(local_variables.second.size())
219 stream << name <<
":" << (dotty_format ?
"\\n" :
"\n");
221 behavioral_helper, dotty_format);
223 behavioral_helper, dotty_format);
225 behavioral_helper, dotty_format);
235 behavioral_helper, dotty_format);
237 behavioral_helper, dotty_format);
239 behavioral_helper, dotty_format);
278 graphs_collection::clear();
323 :
graph(_op_graphs_collection.get(), _selector)
328 const CustomUnorderedSet<boost::graph_traits<OpGraphsCollection>::vertex_descriptor>& _sub)
329 :
graph(_op_graphs_collection.get(), _selector, _sub)
338 std::string output_directory =
340 if(!std::filesystem::exists(output_directory))
342 std::filesystem::create_directories(output_directory);
344 const std::string
full_name = output_directory + file_name;
345 const VertexWriterConstRef op_label_writer(
new OpWriter(
this, detail_level));
346 const EdgeWriterConstRef op_edge_property_writer(
new OpEdgeWriter(
this));
347 InternalWriteDot<const OpWriter, const OpEdgeWriter>(
full_name, op_label_writer, op_edge_property_writer);
355 OpVertexSet::const_iterator vertIter, vertIterEnd;
356 for(vertIter = toCheck.begin(), vertIterEnd = toCheck.end(); vertIter != vertIterEnd; ++vertIter)
359 for(boost::tie(inE, inEEnd) = boost::in_edges(*vertIter, *
this); inE != inEEnd; inE++)
362 if((edgeType & origEdgeType) != 0)
364 const vertex src = boost::source(*inE, *
this);
365 if(retVal.find(src) == retVal.end())
367 retVal.insert(std::pair<vertex, OpVertexSet>(src,
OpVertexSet(thisRef)));
369 retVal.find(src)->second.insert(*vertIter);
385 return boost::make_iterator_range(boost::in_edges(v, *
this));
393 for(boost::tie(ie, ie_end) = boost::in_edges(v, *
this); ie != ie_end; ie++)
395 ret_value.insert(*ie);
404 return boost::make_iterator_range(boost::out_edges(v, *
this));
412 for(boost::tie(oe, oe_end) = boost::out_edges(v, *
this); oe != oe_end; oe++)
414 ret_value.insert(*oe);
425 std::string output_directory =
427 if(!std::filesystem::exists(output_directory))
429 std::filesystem::create_directories(output_directory);
431 const std::string
full_name = output_directory + file_name;
432 const VertexWriterConstRef op_label_writer(
new TimedOpWriter(
this, HLS, critical_paths));
433 const EdgeWriterConstRef op_edge_property_writer(
new TimedOpEdgeWriter(
this, HLS, critical_paths));
434 InternalWriteDot<const TimedOpWriter, const TimedOpEdgeWriter>(
full_name, op_label_writer, op_edge_property_writer);
#define GET_NODE(t)
Macro used to hide implementation details when accessing a tree_node from another tree_node...
#define FLG_SELECTOR
Flow edge selector.
OpEdgeSet CGetInEdges(const vertex v) const
Return the edge ingoing in a vertex.
std::string vertex_name
Definition of the node name property.
CustomMap< FunctionBehavior_VariableType, CustomMap< FunctionBehavior_VariableAccessType, CustomSet< unsigned int > > > variables
set of scalar ssa accessed in this node
~OpNodeInfo() override
Destructor.
int GetSelector() const
Return the selector of this graph.
OpGraphConstRef op_graph
The operation graph to which vertices belong Note: this should be const, but can not because of assig...
boost::graph_traits< graph >::out_edge_iterator OutEdgeIterator
out_edge_iterator definition.
const ParameterConstRef parameters
Set of input parameters.
~OpGraphsCollection() override
Destructor.
Base class storing user data information to the whole graph.
OpGraphsCollection(const OpGraphInfoRef info, const ParameterConstRef parameters)
Empty Constructror.
std::string get_function_name() const
Return the name of the function.
Edge writer for operation graph.
boost::graph_traits< boost_graphs_collection >::vertex_descriptor AddVertex(const NodeInfoRef info) override
Add a vertex to this graph with a property.
#define GET_NAME(data, vertex_index)
Helper macro returning the name associated with a node.
CustomUnorderedMap< vertex, OpVertexSet > GetSrcVertices(const OpVertexSet &toCheck, int edgeType) const
Given a set of vertices, this function computes the edges which have the target in the set and the so...
CustomOrderedMap< T, U > CustomMap
boost::graph_traits< graph >::in_edge_iterator InEdgeIterator
in_edge_iterator definition.
exceptions managed by PandA
const OpVertexSet CGetOperations() const
Return the vertices belonging to the graph.
FunctionBehavior_VariableType
The possible type of a variable.
Definition of hash function for EdgeDescriptor.
~OpEdgeInfo() override
Destructor.
refcount< const OpGraph > OpGraphConstRef
void RemoveVertex(boost::graph_traits< boost_graphs_collection >::vertex_descriptor v) override
Remove a vertex from this graph.
void PrintVariablesList(std::ostream &stream, const std::string &name, const CustomSet< unsigned int > variables, const BehavioralHelperConstRef behavioral_helper, const bool dotty_format)
A set of operation vertices.
OpGraphConstRef op_graph
The operation graph to which vertices belong Note: this should be const, but can not because of assig...
bool FlgEdgeT() const
Function returning true when the edge is a then flow edge.
unsigned int GetNodeId() const
Return the node id of the operation associated with the vertex.
void WriteDot(const std::string &file_name, const int detail_level=0) const
Writes this graph in dot format.
OpGraph(const OpGraphsCollectionRef _op_graphs_collection, int selector)
Standard constructor.
tree_nodeRef node
The tree node associated with this vertex.
CustomSet< unsigned int > cited_variables
set of cited variables (i.e., variables which are included in the c printing of this statement) ...
~OpGraph() override
Destructor.
void PrintVariablesLists(std::ostream &stream, const std::string &name, const CustomMap< FunctionBehavior_VariableAccessType, CustomSet< unsigned int >> variables, const BehavioralHelperConstRef behavioral_helper, const bool dotty_format)
OpEdgeSet CGetOutEdges(const vertex v) const
Return the edge outgoing from a vertex.
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached
bool FlgEdgeF() const
Function returning true when the edge is an else flow edge.
#define EXIT_ID
constant used to represent tree node index of exit operation
virtual void RemoveVertex(boost::graph_traits< boost_graphs_collection >::vertex_descriptor v)
Remove a vertex from this graph.
This class specifies the characteristic of a particular operation working on a given functional unit...
absl::flat_hash_map< T, U, Hash, Eq, Alloc > CustomUnorderedMap
#define ENTRY
Superclass include.
const CustomSet< unsigned int > & GetVariables(const FunctionBehavior_VariableType variable_type, const FunctionBehavior_VariableAccessType access_type) const
Return a set of accessed scalar variables.
const unsigned int index
Represent the index read from the raw file and the index-1 of the vector of tree_node associated to t...
const std::string GetOperation() const
Return the operation associated with the vertex.
const OpGraphInfoConstRef CGetOpGraphInfo() const
Returns the property associated with the graph.
std::map< int, CustomOrderedSet< unsigned int > > labels
edge labels; key is the selector
void Print(std::ostream &stream, const BehavioralHelperConstRef behavioral_helper, const bool dotty_format) const
Print the content of this node.
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
#define T_COND
constant used to represent control edges representing a true edge of a conditional statement...
General class used to describe a graph in PandA.
FunctionBehavior_VariableAccessType
The access type to a variable.
Classes specification of the tree_node data structures.
std::string PrintVariable(unsigned int var) const
Print the name of the variable associated to the index.
OpVertexSet operations
The set of operations.
bool operator()(const EdgeDescriptor x, const EdgeDescriptor y) const
Compare position of two edges.
OpGraphInfo()
Constructor.
void PrintMemoriesLists(std::ostream &stream, const std::string &name, const CustomMap< FunctionBehavior_VariableAccessType, CustomSet< MemoryAddress >> variables, const BehavioralHelperConstRef behavioral_helper, const bool dotty_format)
Class specification of the tree_reindex support class.
#define ENTRY_ID
constant used to represent tree node index of entry operation
Collect all structs used to write a graph in the dot format.
~OpGraphInfo() override
Destructor();.
OpVertexSorter(const OpGraphConstRef op_graph)
Constructor.
#define NOP
constant string identifying a no operation.
void Initialize()
Initialize variable maps.
Data structures used in operations graph.
OpEdgeSet(const OpGraphConstRef op_graph)
Constructor.
this class is used to manage the command-line or XML options.
#define F_COND
constant used to represent control edges representing a false edge of a conditional statement...
OpVertexSet(const OpGraphConstRef op_graph)
Constructor.
OpEdgeSorter(const OpGraphConstRef op_graph)
Constructor.
void Clear()
Remove all the edges and vertices from the graph.
x
Return the smallest n such that 2^n >= _x.
Class used to describe a particular graph with operations as nodes.
graphs_collection * collection
The graph collection.
This structure defines graphs where nodes are operations.
virtual boost::graph_traits< boost_graphs_collection >::vertex_descriptor AddVertex(const NodeInfoRef info)
Add a vertex to this graph with a property.
#define NULL_VERTEX
null vertex definition
const OpVertexSet CGetOperations() const
Return the vertices belonging to the graph.
Class specification of the manager of the tree structures extracted from the raw file.
void PrintMemoriesList(std::ostream &stream, const std::string &name, const CustomSet< MemoryAddress > variables, const BehavioralHelperConstRef, const bool dotty_format)
bool operator()(const vertex x, const vertex y) const
Compare position of two vertices.
boost::graph_traits< graph >::edge_descriptor EdgeDescriptor
edge definition.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...