PandA-2024.02
prettyPrintVertex.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  */
45 #include "prettyPrintVertex.hpp"
47 
49 #include "behavioral_helper.hpp"
50 #include "op_graph.hpp"
51 
53 #include "simple_indent.hpp" // for simple_indent
54 #include "var_pp_functor.hpp"
55 
57  CustomUnorderedSet<unsigned int>& list_of_variables,
58  const BehavioralHelperConstRef BH)
59 {
60  const unsigned int node_id = g->CGetOpNodeInfo(v)->GetNodeId();
61  if(node_id)
62  {
63  unsigned intermediate_var = BH->get_intermediate_var(node_id);
64  if(intermediate_var && !BH->is_an_indirect_ref(intermediate_var) && !BH->is_a_constant(intermediate_var) &&
65  !BH->is_a_component_ref(intermediate_var) && !BH->is_an_array_ref(intermediate_var) &&
66  !BH->is_an_addr_expr(intermediate_var))
67  {
68  list_of_variables.insert(intermediate_var);
69  }
70  else if(intermediate_var && BH->is_an_addr_expr(intermediate_var))
71  {
72  unsigned int var = BH->get_operand_from_unary_expr(intermediate_var);
73  while(true)
74  {
75  if(BH->is_a_component_ref(var))
76  {
77  var = BH->get_component_ref_record(var);
78  continue;
79  }
80  if(BH->is_an_array_ref(var))
81  {
82  var = BH->get_array_ref_array(var);
83  continue;
84  }
85  if(BH->is_an_indirect_ref(var))
86  {
87  var = BH->get_indirect_ref_var(var);
88  continue;
89  }
90  break;
91  }
92  if(!BH->is_a_constant(var))
93  {
94  list_of_variables.insert(var);
95  }
96  }
97  }
98 }
99 
100 void prettyPrintVertex::print_forward_declaration(std::ostream& os, unsigned int type, simple_indent& PP,
101  const BehavioralHelperConstRef BH)
102 {
103  PP(os, BH->print_forward_declaration(type) + ";\n");
104 }
virtual unsigned int get_intermediate_var(unsigned int obj) const
Return the intermediate variable of an operation.
virtual bool is_an_array_ref(unsigned int variable) const
Return true if the index is an array ref.
virtual unsigned int get_component_ref_record(unsigned int obj) const
Return the record variable of a component ref.
Simple pretty print functor.
static void get_internal_vars(const vertex &v, const OpGraphConstRef g, CustomUnorderedSet< unsigned int > &list_of_variables, const BehavioralHelperConstRef BH)
Header include.
virtual unsigned int get_operand_from_unary_expr(unsigned int obj) const
Return the index of the operand if index is addr_expr, a realpart_expr or a imagpart_expr.
const OpNodeInfoConstRef CGetOpNodeInfo(const vertex node) const
Returns the info associated with a node.
Definition: op_graph.hpp:843
virtual std::string print_forward_declaration(unsigned int type) const
Print the declaration of a non built-in type.
virtual unsigned int get_array_ref_array(unsigned int obj) const
Return the array variable of an array ref.
static void print_forward_declaration(std::ostream &os, unsigned int type, simple_indent &PP, const BehavioralHelperConstRef BH)
This function prints the forward type declaration of a type.
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
Definition: graph.hpp:1303
virtual bool is_a_constant(unsigned int obj) const
Return true if the index is a constant object.
virtual bool is_an_addr_expr(unsigned int variable) const
Return true if the index is an addr_expr.
Very simple pretty printer functor.
Helper class supporting the printing of vertexes of a graph.
Data structures used in operations graph.
virtual unsigned int get_indirect_ref_var(unsigned int obj) const
Return the variable of an indirect ref.
virtual bool is_a_component_ref(unsigned int variable) const
Return true if the index is a component ref.
virtual bool is_an_indirect_ref(unsigned int variable) const
Return true if the index is an indirect ref.

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