PandA-2024.02
Public Member Functions | Private Member Functions | Private Attributes | Friends
tree_manager Class Reference

This class manages the tree structures extracted from the raw file. More...

#include <tree_manager.hpp>

Collaboration diagram for tree_manager:
Collaboration graph
[legend]

Public Member Functions

void RecursiveReplaceTreeNode (tree_nodeRef &tn, const tree_nodeRef old_node, const tree_nodeRef &new_node, const tree_nodeRef &stmt, bool definition)
 Replace the occurrences of tree node old_node with new_node in statement identified by tn. More...
 
 tree_manager (const ParameterConstRef &Param)
 This is the constructor of the tree_manager which initializes the vector of functions. More...
 
 ~tree_manager ()
 
unsigned int get_implementation_node (unsigned int decl_node) const
 Return the index of function_decl node that implements the declaration node. More...
 
void AddTreeNode (const unsigned int i, const tree_nodeRef &curr)
 Add to the tree manager the current node. More...
 
tree_nodeRef GetTreeReindex (const unsigned int i)
 Return a tree_reindex wrapping the i-th tree_node. More...
 
const tree_nodeRef CGetTreeReindex (const unsigned int i) const
 Return a tree_reindex wrapping the i-th tree_node. More...
 
tree_nodeRef GetTreeNode (const unsigned int index) const
 Return the index-th tree_node (modifiable version) More...
 
const tree_nodeRef get_tree_node_const (unsigned int i) const
 Return the reference to the i-th tree_node Constant version of get_tree_node. More...
 
const tree_nodeConstRef CGetTreeNode (const unsigned int i) const
 
bool is_tree_node (unsigned int i) const
 Return true if there exists a tree node associated with the given id, false otherwise. More...
 
void create_tree_node (const unsigned int node_id, enum kind tree_node_type, std::map< TreeVocabularyTokenTypes_TokenEnum, std::string > &tree_node_schema)
 Factory method. More...
 
unsigned int find (enum kind tree_node_type, const std::map< TreeVocabularyTokenTypes_TokenEnum, std::string > &tree_node_schema)
 if there exist return the node id of a tree node compatible with the tree_node_schema and of type tree_node_type. More...
 
unsigned int new_tree_node_id (const unsigned int ask=0)
 Return a new node id in the intermediate representation. More...
 
unsigned int get_next_available_tree_node_id () const
 return the next available tree node id. More...
 
void add_function (unsigned int index, tree_nodeRef curr)
 Add to the function_decl_nodes the current node. More...
 
unsigned long get_function_decl_node_n () const
 Return the number of function_decl_node. More...
 
const CustomUnorderedSet< unsigned int > GetAllFunctions () const
 Returns all the functions in the tree_manager. More...
 
unsigned int find_sc_main_node () const
 Determine the index node of "sc_main" function in tree_node vector. More...
 
unsigned int function_index (const std::string &function_name) const
 Return the index of a function given its name. More...
 
tree_nodeRef GetFunction (const std::string &function_name) const
 Return the index of a function given its name. More...
 
unsigned int function_index_mngl (const std::string &function_name) const
 Return the index of a function given its mangled name. More...
 
void print (std::ostream &os) const
 Function that prints the class tree_manager. More...
 
void PrintGimple (std::ostream &os, const bool use_uid) const
 Function that prints the bodies of function in gimple format. More...
 
void collapse_into (const unsigned int &funID, CustomUnorderedMapUnstable< unsigned int, unsigned int > &stmt_to_bloc, const tree_nodeRef &tn, CustomUnorderedSet< unsigned int > &removed_nodes, const application_managerRef AppM)
 Collapse operations chains into the examinated node. More...
 
void add_parallel_loop ()
 increment the number a parallel loop More...
 
unsigned int get_n_pl () const
 return the number of parallel loops More...
 
void merge_tree_managers (const tree_managerRef &source_tree_manager)
 merge two tree manager: this with TM_source More...
 
void add_goto ()
 Increment the number of added gotos. More...
 
unsigned int get_added_goto () const
 Return the number of added gotos. More...
 
void increment_removed_pointer_plus ()
 Increment the number of removed pointer plus. More...
 
unsigned int get_removed_pointer_plus () const
 Return the number of removed pointer plus. More...
 
void increment_removable_pointer_plus ()
 Increment the number of removable pointer plus. More...
 
unsigned int get_removable_pointer_plus () const
 Return the number of not removed pointer plus. More...
 
void increment_unremoved_pointer_plus ()
 Increment the number of not removed pointer plus. More...
 
unsigned int get_unremoved_pointer_plus () const
 Return the number of not removed pointer plus. More...
 
unsigned int find_identifier_nodeID (const std::string &str) const
 Return the nodeID of the identifier_node representing string str. More...
 
void add_identifier_node (unsigned int nodeID, const std::string &str)
 Add an identifier_node to the corresponding unique table. More...
 
void add_identifier_node (unsigned int nodeID, const bool &op)
 
unsigned int get_next_vers ()
 Return the next unused version number for ssa variables. More...
 
void ReplaceTreeNode (const tree_nodeRef &stmt, const tree_nodeRef &old_node, const tree_nodeRef &new_node)
 Replace the occurrences of tree node old_node with new_node in statement identified by tn. More...
 
tree_nodeRef CreateUniqueIntegerCst (integer_cst_t value, const tree_nodeConstRef &type)
 memoization of integer constants More...
 
tree_nodeRef CreateUniqueRealCst (long double value, const tree_nodeConstRef &type)
 memoization of integer constants More...
 
bool is_CPP () const
 is_CPP return true in case we have at least one CPP source code More...
 
bool is_top_function (const function_decl *fd) const
 is_top_function checks if a function is one of the application top functions. More...
 
bool check_ssa_uses (unsigned int fun_id) const
 check_ssa_uses check if the uses of a ssa are correct More...
 

Private Member Functions

bool check_for_decl (const tree_nodeRef &tn, const tree_managerRef &TM, std::string &symbol_name, std::string &symbol_scope, unsigned int node_id, const CustomUnorderedMap< unsigned int, std::string > &global_type_unql_symbol_table)
 check for decl_node and return true if not suitable for symbol table or otherwise its symbol_name and symbol_scope. More...
 
bool check_for_type (const tree_nodeRef &tn, const tree_managerRef &TM, std::string &symbol_name, std::string &symbol_scope, const CustomUnorderedMapUnstable< std::string, unsigned int > &global_type_symbol_table, unsigned int node_id)
 check for type and return true if not suitable for symbol table or otherwise its symbol_name and symbol_scope. More...
 
void erase_usage_info (const tree_nodeRef &tn, const tree_nodeRef &stmt)
 Erase the information about variable usage (remove stmt from use_stmts attribute) in ssa variables recursively contained in node tn. More...
 
void insert_usage_info (const tree_nodeRef &tn, const tree_nodeRef &stmt)
 Insert the information about variable usage (insert stmt in use_stmts attribute) in ssa variables recursively contained in node tn. More...
 
tree_nodeRef create_unique_const (const std::string &val, const tree_nodeConstRef &type)
 

Private Attributes

CustomUnorderedMapUnstable< std::string, unsigned int > find_cache
 cache for tree_manager::find More...
 
OrderedMapStd< unsigned int, tree_nodeReftree_nodes
 Variable containing set of tree_nodes. More...
 
std::map< unsigned int, tree_nodeReffunction_decl_nodes
 Variable containing set of function_declaration with their index node. More...
 
std::deque< tree_nodeRefstack
 list of examining statements during collapse_into recursion More...
 
CustomUnorderedSet< tree_nodeRefalready_visited
 set of already examined addr_expr used to avoid circular recursion More...
 
unsigned int n_pl
 the number of parallel loops More...
 
unsigned int added_goto
 the number of added goto More...
 
unsigned int removed_pointer_plus
 the number of removed pointer_plus More...
 
unsigned int removable_pointer_plus
 the number of removable pointer_plus More...
 
unsigned int unremoved_pointer_plus
 the number of unremoved pointer_plus More...
 
int debug_level
 The debug level. More...
 
unsigned int last_node_id
 last node_id used More...
 
CustomUnorderedMapUnstable< std::string, unsigned int > identifiers_unique_table
 this table stores all identifier_nodes with their nodeID. More...
 
CustomUnorderedMap< std::pair< std::string, unsigned int >, tree_nodeRefunique_cst_map
 
const ParameterConstRef Param
 Set of parameters. More...
 
CustomUnorderedMap< ssa_name *, tree_nodeRefuses_erase_temp
 Map containing temporary information for ssa_name uses deletion. More...
 
unsigned int next_vers
 Next version number for ssa variables. More...
 
unsigned int collapse_into_counter
 Index of current call of collapse_into_counter. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const tree_manager &s)
 Friend definition of the << operator. More...
 
std::ostream & operator<< (std::ostream &os, const tree_managerRef &s)
 Friend definition of the << operator. More...
 

Detailed Description

This class manages the tree structures extracted from the raw file.

Definition at line 84 of file tree_manager.hpp.

Constructor & Destructor Documentation

◆ tree_manager()

tree_manager::tree_manager ( const ParameterConstRef _Param)
explicit

This is the constructor of the tree_manager which initializes the vector of functions.

Autoheader include.

Parameters
Paramis the set of input parameters

Header include Parameter include parser/compiler include Tree include Wrapper include

Definition at line 87 of file tree_manager.cpp.

References ~tree_manager().

Here is the call graph for this function:

◆ ~tree_manager()

tree_manager::~tree_manager ( )
default

Referenced by tree_manager().

Here is the caller graph for this function:

Member Function Documentation

◆ add_function()

void tree_manager::add_function ( unsigned int  index,
tree_nodeRef  curr 
)

Add to the function_decl_nodes the current node.

Parameters
indexis the index of the node
curris the added element

Definition at line 340 of file tree_manager.cpp.

References function_decl_nodes, and index.

Referenced by tree_manipulation::create_function_decl().

Here is the caller graph for this function:

◆ add_goto()

void tree_manager::add_goto ( )

Increment the number of added gotos.

Definition at line 2740 of file tree_manager.cpp.

References added_goto.

Referenced by tree_manipulation::create_goto().

Here is the caller graph for this function:

◆ add_identifier_node() [1/2]

void tree_manager::add_identifier_node ( unsigned int  nodeID,
const std::string &  str 
)
inline

Add an identifier_node to the corresponding unique table.

Parameters
nodeIDis the node id.
stris the string.

Definition at line 457 of file tree_manager.hpp.

References check_ssa_uses(), CreateUniqueIntegerCst(), CreateUniqueRealCst(), get_next_vers(), is_CPP(), is_top_function(), ReplaceTreeNode(), str, test_panda::type, and symmetry::value.

Referenced by find_identifier_nodeID(), and handler::visit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_identifier_node() [2/2]

void tree_manager::add_identifier_node ( unsigned int  nodeID,
const bool op 
)

◆ add_parallel_loop()

void tree_manager::add_parallel_loop ( )

increment the number a parallel loop

Definition at line 1808 of file tree_manager.cpp.

References n_pl.

◆ AddTreeNode()

void tree_manager::AddTreeNode ( const unsigned int  i,
const tree_nodeRef curr 
)

Add to the tree manager the current node.

Parameters
iposition in the tree_vector. Note that the raw file start from 1
curris the added element

Definition at line 118 of file tree_manager.cpp.

References last_node_id, STR, THROW_ASSERT, and tree_nodes.

Referenced by tree_node_factory::create_tree_node().

Here is the caller graph for this function:

◆ CGetTreeNode()

const tree_nodeConstRef tree_manager::CGetTreeNode ( const unsigned int  i) const

Definition at line 162 of file tree_manager.cpp.

References last_node_id, STR, THROW_ASSERT, and tree_nodes.

Referenced by memory::add_internal_symbol(), CallGraphManager::AddCallPoint(), CallGraphManager::AddFunctionAndCallPoint(), mux_connection_binding::address_precision(), AllocationInformation::can_implement_set(), Schedule::CanBeMoved(), BehavioralHelper::CanBeMoved(), BehavioralHelper::CanBeSpeculated(), AllocationInformation::CanImplementSetNotEmpty(), CreateAddressTranslation::ComputeAddress(), create_tree_node(), mux_connection_binding::determine_connection(), Schedule::EvaluateCondsMerging(), tree_helper::extract_array_indexes(), AllocationInformation::get_attribute_of_fu_per_op(), Schedule::get_cstep(), Schedule::get_cstep_end(), AllocationInformation::get_cycles(), AllocationInformation::get_execution_time(), AllocationInformation::get_initiation_time(), tree_helper::get_multi_way_if_pos(), BehavioralHelper::get_parameters(), tree_helper::get_pointed_type(), AllocationInformation::get_stage_period(), tree_helper::get_var_alignment(), Schedule::GetEndingTime(), BehavioralHelper::GetMangledFunctionName(), BehavioralHelper::GetParameters(), BehavioralHelper::GetParameterTypes(), AllocationInformation::GetStatementArea(), tree_helper::GetUnqualified(), StorageValueInformation::Initialize(), multi_way_if::Initialize(), MultipleEntryIfReduction::Initialize(), PhiOpt::Initialize(), cdfc_module_binding::initialize_connection_relation(), tree_manipulation::InlineFunctionCall(), SDCCodeMotion::InternalExec(), SwitchFix::InternalExec(), CondExprRestructuring::InternalExec(), MultipleEntryIfReduction::InternalExec(), lut_transformation::InternalExec(), BehavioralHelper::is_a_component_ref(), BehavioralHelper::is_a_constant(), BehavioralHelper::is_a_mem_ref(), BehavioralHelper::is_an_addr_expr(), tree_helper::is_an_addr_expr(), BehavioralHelper::is_an_array_ref(), BehavioralHelper::is_an_indirect_ref(), tree_helper::is_builtin_channel(), tree_helper::is_channel(), tree_helper::is_clock(), BehavioralHelper::is_empty_return(), tree_helper::is_event(), tree_helper::is_in_port(), tree_helper::is_inout_port(), tree_helper::is_module(), AllocationInformation::is_operation_bounded(), AllocationInformation::is_operation_PI_registered(), tree_helper::is_out_port(), tree_helper::is_packed_access(), tree_helper::is_port(), tree_helper::is_SC_BIND_PROXY_NIL(), tree_helper::is_signal(), AllocationInformation::is_vertex_bounded_with(), CallGraphManager::IsCallPoint(), rebuild_initialization2::look_for_ROMs(), AllocationInformation::max_number_of_resources(), AllocationInformation::min_number_of_resources(), Bit_Value_opt::optimize(), BehavioralHelper::print_attributes(), BehavioralHelper::print_forward_declaration(), BehavioralHelper::print_phinode_res(), BehavioralHelper::print_type_declaration(), BehavioralHelper::PrintNode(), BehavioralHelper::PrintVarDeclaration(), BehavioralHelper::PrintVariable(), CallGraphManager::RemoveCallPoint(), ResolvePointerAlias(), dead_code_eliminationIPA::signature_opt(), vcd_trace_head::update(), Schedule::UpdateTime(), BasicBlocksProfilingCWriter::WriteGlobalDeclarations(), HLSCWriter::WriteHeader(), DiscrepancyAnalysisCWriter::writePostInstructionInfo(), and DiscrepancyAnalysisCWriter::writePreInstructionInfo().

Here is the caller graph for this function:

◆ CGetTreeReindex()

const tree_nodeRef tree_manager::CGetTreeReindex ( const unsigned int  i) const

Return a tree_reindex wrapping the i-th tree_node.

Parameters
iis the index of the tree_node.
Returns
the reference to the tree_node.

Definition at line 139 of file tree_manager.cpp.

References last_node_id, STR, THROW_ASSERT, and tree_nodes.

Referenced by mux_connection_binding::add_conversion(), memory::add_internal_symbol(), operations_graph_constructor::AddOperation(), mux_connection_binding::address_precision(), memory::compute_next_base_address(), CreateAddressTranslation::ComputeAddress(), tree_manipulation::CreateAddrExpr(), tree_manipulation::CreateGimpleAssignAddrExpr(), DiscrepancyAnalysisCWriter::DeclareLocalVariables(), CWriter::DeclareLocalVariables(), CWriter::DeclareVariable(), TestbenchGeneration::generate_init_file(), tree_helper::get_array_data_bitsize(), tree_helper::get_array_dimensions(), tree_helper::get_array_num_elements(), tree_helper::get_base_index(), HLS_manager::get_constant_string(), BehavioralHelper::get_definition(), tree_helper::get_field_idx(), tree_helper::get_formal_ith(), memory::get_last_address(), tree_helper::get_parameter_types(), BehavioralHelper::get_pointed_type(), BehavioralHelper::get_size(), tree_helper::get_type_index(), tree_helper::get_type_name(), tree_helper::GetElements(), BehavioralHelper::GetElements(), GetFunction(), BehavioralHelper::GetFunctionReturnType(), AllocationInformation::GetNodeTypePrec(), tree_helper::GetRealType(), compute_implicit_calls::InternalExec(), MultipleEntryIfReduction::InternalExec(), tree_helper::is_a_complex(), tree_helper::is_a_function(), tree_helper::is_a_misaligned_vector(), tree_helper::is_a_pointer(), tree_helper::is_a_struct(), tree_helper::is_a_variable(), tree_helper::is_a_vector(), tree_helper::is_a_void(), tree_helper::is_an_array(), tree_helper::is_an_enum(), tree_helper::is_an_union(), tree_helper::is_bool(), tree_helper::is_builtin_channel(), tree_helper::is_const_type(), tree_helper::is_constant(), tree_helper::is_extern(), tree_helper::is_fully_resolved(), tree_helper::is_function_pointer_type(), tree_helper::is_function_type(), tree_helper::is_int(), BehavioralHelper::is_named_pointer(), tree_helper::is_natural(), tree_helper::is_packed(), tree_helper::is_real(), tree_helper::is_scalar(), tree_helper::is_static(), tree_helper::is_system(), tree_helper::is_unsigned(), tree_helper::is_volatile(), tree_helper::IsAligned(), tree_helper::IsInLibbambu(), BehavioralHelper::IsLoad(), BehavioralHelper::IsLut(), BehavioralHelper::IsStore(), rebuild_initialization2::look_for_ROMs(), tree_helper::name_function(), mux_connection_binding::object_bitsize(), Bit_Value_opt::optimize(), FunctionCallTypeCleanup::ParametersTypeCleanup(), BehavioralHelper::print_type(), tree_helper::print_type(), BehavioralHelper::print_type_declaration(), TestbenchGeneration::print_var_init(), tree_helper::PrintType(), BehavioralHelper::PrintVarDeclaration(), ResolvePointerAlias(), InterfaceInfer::setReadInterface(), InterfaceInfer::setWriteInterface(), CWriter::WriteBuiltinWaitCall(), EdgeCWriter::writeRoutineInstructions_rec(), and CWriter::writeRoutineInstructions_rec().

Here is the caller graph for this function:

◆ check_for_decl()

bool tree_manager::check_for_decl ( const tree_nodeRef tn,
const tree_managerRef TM,
std::string &  symbol_name,
std::string &  symbol_scope,
unsigned int  node_id,
const CustomUnorderedMap< unsigned int, std::string > &  global_type_unql_symbol_table 
)
private

check for decl_node and return true if not suitable for symbol table or otherwise its symbol_name and symbol_scope.

Parameters
tnis the tree node to be examinated
TMis a refcount to this TODO: could be removed?
symbol_nameis where symbol name will be stored
symobl_scopeis where symbol scope will be stored
node_idis the index of the tree node
Returns
true if symbol has not to be inserted into symbol table

check for name

check for memory_tag, parm_decl, result_decl

check for scope

declaration with type_node local to a function are not considered

Definition at line 2475 of file tree_manager.cpp.

References function_decl::builtin_flag, debug_level, DEBUG_LEVEL_PARANOIC, FIRST_TOKEN, GET_INDEX_NODE, tree_node::get_kind(), GET_NODE, tree_helper::get_type_name(), srcp::include_name, INDENT_DBG_MEX, decl_node::mngl, decl_node::name, tree_helper::return_qualifier_prefix(), decl_node::scpe, starts_with(), function_decl::static_flag, STR, THROW_ASSERT, and test_panda::type.

Referenced by merge_tree_managers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_for_type()

bool tree_manager::check_for_type ( const tree_nodeRef tn,
const tree_managerRef TM,
std::string &  symbol_name,
std::string &  symbol_scope,
const CustomUnorderedMapUnstable< std::string, unsigned int > &  global_type_symbol_table,
unsigned int  node_id 
)
private

check for type and return true if not suitable for symbol table or otherwise its symbol_name and symbol_scope.

integer_type and real_type have some duplication

Definition at line 2620 of file tree_manager.cpp.

References debug_level, DEBUG_LEVEL_PARANOIC, FIRST_TOKEN, GET_INDEX_NODE, tree_node::get_kind(), GET_NODE, tree_helper::get_type_name(), PRINT_DBG_MEX, tree_helper::return_qualifier_prefix(), STR, THROW_ASSERT, and test_panda::type.

Referenced by merge_tree_managers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_ssa_uses()

bool tree_manager::check_ssa_uses ( unsigned int  fun_id) const

check_ssa_uses check if the uses of a ssa are correct

Returns
true in case all the ssa uses are correct, false otherwise.

Definition at line 2886 of file tree_manager.cpp.

References tree_helper::ComputeSsaUses(), GET_INDEX_CONST_NODE, tree_node::get_kind(), GET_NODE, get_tree_node_const(), phi, sl, and THROW_ERROR.

Referenced by add_identifier_node().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ collapse_into()

void tree_manager::collapse_into ( const unsigned int &  funID,
CustomUnorderedMapUnstable< unsigned int, unsigned int > &  stmt_to_bloc,
const tree_nodeRef tn,
CustomUnorderedSet< unsigned int > &  removed_nodes,
const application_managerRef  AppM 
)

Collapse operations chains into the examinated node.

Parameters
funIDis the index of the function
stmt_to_blockmaps each statement to its bloc
tnis the top tree node of the tree to be collapsed
removed_nodesis the set of nodes removed during collapsing

If there is a conversion to a not built-in type, type has to be declared; but if no variable survives, type will be not declared by the backend

If there is a conversion to a not built-in type, type has to be declared; but if no variable survives, type will be not declared by the backend

FIXME: If right part is a subtree, it should be completly duplicated; For the moment we just stop the collapsing

Update uses of right operand

Definition at line 401 of file tree_manager.cpp.

References test_panda::arg, test_panda::args, BUILTIN_SRCP, CASE_BINARY_EXPRESSION, CASE_CPP_NODES, CASE_FAKE_NODES, CASE_PRAGMA_NODES, CASE_QUATERNARY_EXPRESSION, CASE_TERNARY_EXPRESSION, CASE_TYPE_NODES, CASE_UNARY_EXPRESSION, collapse_into_counter, create_tree_node(), debug_level, DEBUG_LEVEL_PARANOIC, erase_usage_info(), GET_INDEX_CONST_NODE, GET_INDEX_NODE, tree_node::get_kind(), tree_node::get_kind_text(), get_next_vers(), GET_NODE, get_tree_node_const(), GetTreeReindex(), tree_helper::HasToBeDeclared(), INDENT_DBG_MEX, insert_usage_info(), new_tree_node_id(), Param, PrintGimple(), RecursiveReplaceTreeNode(), sl, STR, THROW_ASSERT, THROW_ERROR, TOK, TOK_OP0, TOK_OP1, TOK_SCPE, TOK_SRCP, TOK_TYPE, TOK_VAR, TOK_VERS, TOK_VOLATILE, top(), and tree_node::ToString().

Here is the call graph for this function:

◆ create_tree_node()

void tree_manager::create_tree_node ( const unsigned int  node_id,
enum kind  tree_node_type,
std::map< TreeVocabularyTokenTypes_TokenEnum, std::string > &  tree_node_schema 
)

Factory method.

It creates a tree_node of type equal tree_node_type by using a relation (tree_node_schema) between tree node fields and their values.

Parameters
node_idis the node id of the created object.
tree_node_typeis the type of the node added to the tree_manager expressed as a treeVocabularyTokenTypes.
tree_node_schemaexpresses the value of the field of the tree node created. For example the following code: std::map<int, std::string> identifier_schema; int identifier_node_id = TM->get_tree_node_n(); identifier_schema[TOK(TOK_STRG)]= "my_identifier"; TM->create_tree_node(identifier_node_id, TOK(TOK_IDENTIFIER_NODE), identifier_schema); will add an identifier node to the tree_manager TM.

Definition at line 314 of file tree_manager.cpp.

References CGetTreeNode(), tree_node_factory::create_tree_node(), DEBUG_LEVEL_PARANOIC, GET_FUNCTION_DEBUG_LEVEL, INDENT_DBG_MEX, Param, and STR.

Referenced by dead_code_elimination::add_gimple_nop(), PhiOpt::ApplyIfMerge(), PhiOpt::ApplyIfRemove(), PhiOpt::ApplyMultiMerge(), PhiOpt::ApplyMultiRemove(), collapse_into(), tree_manipulation::create_binary_operation(), tree_manipulation::create_extract_bit_expr(), tree_manipulation::create_function_decl(), tree_manipulation::create_gimple_call(), tree_manipulation::create_gimple_cond(), tree_manipulation::create_gimple_modify_stmt(), tree_manipulation::create_gimple_return(), tree_manipulation::create_goto(), tree_manipulation::create_identifier_node(), tree_manipulation::create_label(), tree_manipulation::create_lut_expr(), PragmaAnalysis::create_map_pragma(), PragmaAnalysis::create_omp_pragma(), tree_manipulation::create_parm_decl(), tree_manipulation::create_phi_node(), tree_manipulation::create_quaternary_operation(), tree_manipulation::create_result_decl(), tree_manipulation::create_ssa_name(), tree_manipulation::create_ternary_operation(), tree_manipulation::create_translation_unit_decl(), tree_manipulation::create_unary_operation(), create_unique_const(), tree_manipulation::create_var_decl(), tree_manipulation::CreateAddrExpr(), tree_manipulation::CreateAndExpr(), tree_manipulation::CreateCallExpr(), tree_manipulation::CreateEqExpr(), tree_manipulation::CreateIntegerCst(), tree_manipulation::CreateNopExpr(), tree_manipulation::CreateNotExpr(), tree_manipulation::CreateOrExpr(), tree_manipulation::CreateUnsigned(), tree_manipulation::CreateVectorBooleanType(), PragmaAnalysis::Exec(), tree_manipulation::GetBitsizeType(), tree_manipulation::GetBooleanType(), tree_manipulation::GetCustomIntegerType(), tree_manipulation::GetFunctionType(), tree_manipulation::GetPointerType(), tree_manipulation::GetSignedIntegerType(), tree_manipulation::GetSizeType(), tree_manipulation::GetUnsignedIntegerType(), tree_manipulation::GetUnsignedLongLongType(), tree_manipulation::GetVoidType(), SwitchFix::InternalExec(), rebuild_initialization::InternalExec(), operations_cfg_computation::InternalExec(), dead_code_elimination::kill_uses(), dead_code_elimination::kill_vdef(), rebuild_initialization2::look_for_ROMs(), multi_way_if::MergeCondCond(), multi_way_if::MergeCondMulti(), multi_way_if::MergeMultiCond(), and multi_way_if::MergeMultiMulti().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_unique_const()

tree_nodeRef tree_manager::create_unique_const ( const std::string &  val,
const tree_nodeConstRef type 
)
private

Definition at line 2780 of file tree_manager.cpp.

References create_tree_node(), GetTreeReindex(), tree_node::index, tree_helper::IsRealType(), key, new_tree_node_id(), STR, TOK, TOK_TYPE, TOK_VALR, TOK_VALUE, TOK_VALX, and unique_cst_map.

Referenced by CreateUniqueIntegerCst(), and CreateUniqueRealCst().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateUniqueIntegerCst()

tree_nodeRef tree_manager::CreateUniqueIntegerCst ( integer_cst_t  value,
const tree_nodeConstRef type 
)

memoization of integer constants

Parameters
valueis the integer value
type_indexis the type of the integer constant
Returns
a tree reindex node for the integer value with as type type

Definition at line 2808 of file tree_manager.cpp.

References create_unique_const(), tree_helper::IsSignedIntegerType(), tree_helper::Size(), STR, and THROW_ASSERT.

Referenced by add_identifier_node(), IR_lowering::array_ref_lowering(), Bit_Value_opt::constrainSSA(), tree_manipulation::CreateAndExpr(), lut_transformation::CreateBitSelectionNodeOrCast(), tree_manipulation::CreateEqExpr(), tree_manipulation::CreateNotExpr(), tree_manipulation::CreateOrExpr(), tree_manipulation::CreateVectorBooleanType(), IR_lowering::division_by_a_constant(), IR_lowering::expand_MC(), IR_lowering::expand_mult_const(), IR_lowering::expand_mult_highpart(), IR_lowering::expand_sdiv_pow2(), IR_lowering::expand_smod_pow2(), tree_manipulation::ExtractCondition(), tree_manipulation::GetBooleanType(), tree_manipulation::GetCustomIntegerType(), tree_manipulation::GetFunctionType(), tree_manipulation::GetPointerType(), tree_manipulation::GetSignedIntegerType(), tree_manipulation::GetSizeType(), tree_manipulation::GetUnsignedIntegerType(), tree_manipulation::GetUnsignedLongLongType(), SwitchFix::InternalExec(), rebuild_initialization::InternalExec(), compute_implicit_calls::InternalExec(), CondExprRestructuring::InternalExec(), IR_lowering::InternalExec(), dead_code_elimination::kill_uses(), rebuild_initialization2::look_for_ROMs(), Bit_Value_opt::optimize(), lut_transformation::ProcessBasicBlock(), compute_implicit_calls::replace_with_memcpy(), compute_implicit_calls::replace_with_memset(), InterfaceInfer::setReadInterface(), and InterfaceInfer::setWriteInterface().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateUniqueRealCst()

tree_nodeRef tree_manager::CreateUniqueRealCst ( long double  value,
const tree_nodeConstRef type 
)

memoization of integer constants

Parameters
valueis the real value
type_indexis the type of the real constant
Returns
a tree reindex node for the real value with as type type

Definition at line 2823 of file tree_manager.cpp.

References create_unique_const(), test_panda::type, and symmetry::value.

Referenced by add_identifier_node(), dead_code_elimination::kill_uses(), and Bit_Value_opt::optimize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ erase_usage_info()

void tree_manager::erase_usage_info ( const tree_nodeRef tn,
const tree_nodeRef stmt 
)
private

Erase the information about variable usage (remove stmt from use_stmts attribute) in ssa variables recursively contained in node tn.

Parameters
tnis the node from which the recursion begin.
stmtis the statement that is removed from the usage vector of ssa variables.

Definition at line 1375 of file tree_manager.cpp.

References test_panda::arg, test_panda::args, CASE_BINARY_EXPRESSION, CASE_CPP_NODES, CASE_FAKE_NODES, CASE_PRAGMA_NODES, CASE_QUATERNARY_EXPRESSION, CASE_TERNARY_EXPRESSION, CASE_TYPE_NODES, CASE_UNARY_EXPRESSION, debug_level, DEBUG_LEVEL_PARANOIC, GET_INDEX_NODE, tree_node::get_kind(), GET_NODE, INDENT_DBG_MEX, STR, THROW_ASSERT, and THROW_ERROR.

Referenced by collapse_into().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find()

unsigned int tree_manager::find ( enum kind  tree_node_type,
const std::map< TreeVocabularyTokenTypes_TokenEnum, std::string > &  tree_node_schema 
)

◆ find_identifier_nodeID()

unsigned int tree_manager::find_identifier_nodeID ( const std::string &  str) const

Return the nodeID of the identifier_node representing string str.

In case there is not that identifier_node it returns 0.

Parameters
stris the identifier we are looking for.

Definition at line 2686 of file tree_manager.cpp.

References add_identifier_node(), ASSERT_PARAMETER, identifiers_unique_table, STOK, THROW_ASSERT, and TOK_OPERATOR.

Referenced by CWriter::create_new_identifier(), find(), and merge_tree_managers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_sc_main_node()

unsigned int tree_manager::find_sc_main_node ( ) const

Determine the index node of "sc_main" function in tree_node vector.

Definition at line 178 of file tree_manager.cpp.

References function_index().

Here is the call graph for this function:

◆ function_index()

unsigned int tree_manager::function_index ( const std::string &  function_name) const

Return the index of a function given its name.

Parameters
function_nameis the name of the function
Returns
the treenode_index of the function_declFIXME: to be remove after substitution with GetFunction

Definition at line 183 of file tree_manager.cpp.

References GetFunction().

Referenced by find_sc_main_node().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ function_index_mngl()

unsigned int tree_manager::function_index_mngl ( const std::string &  function_name) const

Return the index of a function given its mangled name.

Parameters
tmis the tree_manager
function_nameis the mangled name of the function
Returns
the treenode_index of the function_decl

Definition at line 241 of file tree_manager.cpp.

References function_decl_nodes, tree_node::get_kind(), GET_NODE, and tree_helper::print_function_name().

Here is the call graph for this function:

◆ get_added_goto()

unsigned int tree_manager::get_added_goto ( ) const

Return the number of added gotos.

Definition at line 2745 of file tree_manager.cpp.

References added_goto.

◆ get_function_decl_node_n()

unsigned long tree_manager::get_function_decl_node_n ( ) const

Return the number of function_decl_node.

Returns
the number of function decl nodes.

Definition at line 345 of file tree_manager.cpp.

References function_decl_nodes.

◆ get_implementation_node()

unsigned int tree_manager::get_implementation_node ( unsigned int  decl_node) const

Return the index of function_decl node that implements the declaration node.

Parameters
decl_nodeis the index of the declaration node
Returns
the index of implementation node

Definition at line 103 of file tree_manager.cpp.

References decl_node, get_tree_node_const(), STR, and THROW_ASSERT.

Referenced by CallGraphManager::AddFunctionAndCallPoint(), CallGraphManager::call_graph_computation_recursive(), and tree_helper::PrintType().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_n_pl()

unsigned int tree_manager::get_n_pl ( ) const

return the number of parallel loops

Definition at line 1813 of file tree_manager.cpp.

References n_pl.

◆ get_next_available_tree_node_id()

unsigned int tree_manager::get_next_available_tree_node_id ( ) const

return the next available tree node id.

Definition at line 335 of file tree_manager.cpp.

References last_node_id.

Referenced by tree_manipulation::create_function_decl(), CWriter::Initialize(), and merge_tree_managers().

Here is the caller graph for this function:

◆ get_next_vers()

unsigned int tree_manager::get_next_vers ( )

Return the next unused version number for ssa variables.

Definition at line 2716 of file tree_manager.cpp.

References DEBUG_LEVEL_PARANOIC, GET_FUNCTION_DEBUG_LEVEL, tree_node::get_kind(), INDENT_DBG_MEX, next_vers, Param, STR, and tree_nodes.

Referenced by add_identifier_node(), collapse_into(), and tree_manipulation::create_ssa_name().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_removable_pointer_plus()

unsigned int tree_manager::get_removable_pointer_plus ( ) const

Return the number of not removed pointer plus.

Definition at line 2765 of file tree_manager.cpp.

References removable_pointer_plus.

◆ get_removed_pointer_plus()

unsigned int tree_manager::get_removed_pointer_plus ( ) const

Return the number of removed pointer plus.

Definition at line 2755 of file tree_manager.cpp.

References removed_pointer_plus.

◆ get_tree_node_const()

const tree_nodeRef tree_manager::get_tree_node_const ( unsigned int  i) const

Return the reference to the i-th tree_node Constant version of get_tree_node.

Parameters
iis the index of the tree_node of the considered function.
Returns
the reference to the tree_node. FIXME: this should return tree_nodeConstRef

Definition at line 153 of file tree_manager.cpp.

References last_node_id, STR, THROW_ASSERT, and tree_nodes.

Referenced by operations_graph_constructor::AddOperation(), CallGraphBuiltinCall::buildTypeToDeclaration(), CallGraphManager::call_graph_computation_recursive(), AllocationInformation::can_be_asynchronous_ram(), Schedule::CanBeMoved(), check_ssa_uses(), collapse_into(), CreateAddressTranslation::ComputeAddress(), Schedule::ComputeCriticalPath(), mux_connection_binding::connect_to_registers(), tree_manipulation::create_goto(), tree_manipulation::create_label(), PragmaAnalysis::create_map_pragma(), PragmaAnalysis::create_omp_pragma(), mux_connection_binding::create_single_conn(), Schedule::EvaluateCondsMerging(), Schedule::EvaluateMultiWayIfsMerging(), HDLFunctionDeclFix::Exec(), PragmaAnalysis::Exec(), mux_connection_binding::extract_parm_decl(), tree_helper::get_array_dim_and_bitsize(), BehavioralHelper::get_array_ref_array(), BehavioralHelper::get_array_ref_index(), tree_helper::get_array_var(), tree_helper::get_asm_string(), BehavioralHelper::get_attributes(), PragmaAnalysis::get_call_parameter(), BehavioralHelper::get_component_ref_field(), BehavioralHelper::get_component_ref_record(), fsm_controller::get_guard_value(), get_implementation_node(), BehavioralHelper::get_indirect_ref_var(), BehavioralHelper::get_intermediate_var(), BehavioralHelper::get_label_name(), BehavioralHelper::get_mem_ref_base(), BehavioralHelper::get_mem_ref_offset(), liveness::get_op_where_defined(), BehavioralHelper::get_operand_from_unary_expr(), Schedule::GetBBEndingTime(), tree_helper::GetFunctionSize(), BehavioralHelper::GetInit(), Schedule::GetReadyTime(), BehavioralHelper::GetVarFromSsa(), BehavioralHelper::has_bit_field(), RemoveEndingIf::Initialize(), SDCCodeMotion::InternalExec(), SwitchFix::InternalExec(), remove_clobber_ga::InternalExec(), call_expr_fix::InternalExec(), rebuild_initialization::InternalExec(), NI_SSA_liveness::InternalExec(), BlockFix::InternalExec(), compute_implicit_calls::InternalExec(), commutative_expr_restructuring::InternalExec(), virtual_phi_nodes_split::InternalExec(), operations_cfg_computation::InternalExec(), IR_lowering::InternalExec(), cdfc_module_binding::InternalExec(), BehavioralHelper::is_a_imagpart_expr(), BehavioralHelper::is_a_realpart_expr(), BehavioralHelper::is_a_result_decl(), tree_helper::is_concat_bit_ior_expr(), BehavioralHelper::is_operating_system_function(), tree_helper::is_parameter(), HLS_manager::is_reading_writing_function(), tree_helper::is_simple_pointer_plus_test(), tree_helper::is_ssa_name(), BehavioralHelper::is_va_start_call(), BehavioralHelper::is_var_args(), tree_helper::is_virtual(), mux_connection_binding::isConstantObj(), BehavioralHelper::IsDefaultSsaName(), rebuild_initialization2::look_for_ROMs(), multi_way_if::MergeCondMulti(), multi_way_if::MergeMultiCond(), multi_way_if::MergeMultiMulti(), Bit_Value_opt::optimize(), EdgeCWriter::writeRoutineInstructions_rec(), and CWriter::writeRoutineInstructions_rec().

Here is the caller graph for this function:

◆ get_unremoved_pointer_plus()

unsigned int tree_manager::get_unremoved_pointer_plus ( ) const

Return the number of not removed pointer plus.

Definition at line 2775 of file tree_manager.cpp.

References unremoved_pointer_plus.

◆ GetAllFunctions()

const CustomUnorderedSet< unsigned int > tree_manager::GetAllFunctions ( ) const

Returns all the functions in the tree_manager.

Returns
all the functions

Definition at line 2705 of file tree_manager.cpp.

References function_decl_nodes.

Referenced by HDLFunctionDeclFix::Exec(), and PragmaAnalysis::Exec().

Here is the caller graph for this function:

◆ GetFunction()

tree_nodeRef tree_manager::GetFunction ( const std::string &  function_name) const

◆ GetTreeNode()

tree_nodeRef tree_manager::GetTreeNode ( const unsigned int  index) const

◆ GetTreeReindex()

tree_nodeRef tree_manager::GetTreeReindex ( const unsigned int  i)

Return a tree_reindex wrapping the i-th tree_node.

Parameters
iis the index of the tree_node.
Returns
the reference to the tree_node.

Definition at line 129 of file tree_manager.cpp.

References last_node_id, STR, THROW_ASSERT, and tree_nodes.

Referenced by dead_code_elimination::add_gimple_nop(), gimple_phi::AddDefEdge(), PhiOpt::ApplyIfMerge(), PhiOpt::ApplyIfRemove(), PhiOpt::ApplyMultiMerge(), PhiOpt::ApplyMultiRemove(), tree_manipulation::CloneFunction(), collapse_into(), tree_manipulation::create_binary_operation(), tree_manipulation::create_extract_bit_expr(), tree_manipulation::create_function_decl(), tree_manipulation::create_gimple_call(), tree_manipulation::create_gimple_cond(), tree_manipulation::create_gimple_modify_stmt(), tree_manipulation::create_gimple_return(), tree_manipulation::create_goto(), tree_manipulation::create_identifier_node(), tree_manipulation::create_label(), tree_manipulation::create_lut_expr(), tree_manipulation::create_parm_decl(), tree_manipulation::create_phi_node(), tree_manipulation::create_quaternary_operation(), tree_manipulation::create_result_decl(), tree_manipulation::create_ssa_name(), tree_manipulation::create_ternary_operation(), tree_manipulation::create_translation_unit_decl(), tree_manipulation::create_unary_operation(), create_unique_const(), tree_manipulation::create_var_decl(), tree_manipulation::CreateAndExpr(), tree_manipulation::CreateCallExpr(), tree_manipulation::CreateEqExpr(), tree_manipulation::CreateGimpleAssign(), tree_manipulation::CreateIntegerCst(), tree_manipulation::CreateNopExpr(), tree_manipulation::CreateNotExpr(), tree_manipulation::CreateOrExpr(), tree_manipulation::CreateUnsigned(), tree_manipulation::CreateVectorBooleanType(), Schedule::EvaluateCondsMerging(), tree_manipulation::GetBitsizeType(), tree_manipulation::GetBooleanType(), tree_manipulation::GetCustomIntegerType(), tree_manipulation::GetFunctionType(), tree_manipulation::GetPointerType(), tree_manipulation::GetSignedIntegerType(), tree_manipulation::GetSizeType(), tree_manipulation::GetUnsignedIntegerType(), tree_manipulation::GetUnsignedLongLongType(), tree_manipulation::GetVoidType(), SDCCodeMotion::InternalExec(), SwitchFix::InternalExec(), remove_clobber_ga::InternalExec(), rebuild_initialization::InternalExec(), MultipleEntryIfReduction::InternalExec(), operations_cfg_computation::InternalExec(), IR_lowering::InternalExec(), dead_code_elimination::kill_uses(), dead_code_elimination::kill_vdef(), rebuild_initialization2::look_for_ROMs(), multi_way_if::MergeCondCond(), multi_way_if::MergeCondMulti(), multi_way_if::MergeMultiCond(), multi_way_if::MergeMultiMulti(), new_tree_node_id(), Bit_Value_opt::optimize(), gimple_phi::RemoveDefEdge(), gimple_phi::ReplaceDefEdge(), dead_code_eliminationIPA::signature_opt(), and VarNode::updateIR().

Here is the caller graph for this function:

◆ increment_removable_pointer_plus()

void tree_manager::increment_removable_pointer_plus ( )

Increment the number of removable pointer plus.

Definition at line 2760 of file tree_manager.cpp.

References removable_pointer_plus.

◆ increment_removed_pointer_plus()

void tree_manager::increment_removed_pointer_plus ( )

Increment the number of removed pointer plus.

Definition at line 2750 of file tree_manager.cpp.

References removed_pointer_plus.

◆ increment_unremoved_pointer_plus()

void tree_manager::increment_unremoved_pointer_plus ( )

Increment the number of not removed pointer plus.

Definition at line 2770 of file tree_manager.cpp.

References unremoved_pointer_plus.

◆ insert_usage_info()

void tree_manager::insert_usage_info ( const tree_nodeRef tn,
const tree_nodeRef stmt 
)
private

Insert the information about variable usage (insert stmt in use_stmts attribute) in ssa variables recursively contained in node tn.

Parameters
tnis the node from which the recursion begin.
stmtis the statement that is inserted in the usage vector of ssa variables.

Definition at line 1596 of file tree_manager.cpp.

References test_panda::arg, test_panda::args, CASE_BINARY_EXPRESSION, CASE_CPP_NODES, CASE_FAKE_NODES, CASE_PRAGMA_NODES, CASE_QUATERNARY_EXPRESSION, CASE_TERNARY_EXPRESSION, CASE_TYPE_NODES, CASE_UNARY_EXPRESSION, debug_level, DEBUG_LEVEL_PARANOIC, GET_INDEX_NODE, tree_node::get_kind(), GET_NODE, INDENT_DBG_MEX, STR, THROW_ASSERT, and THROW_ERROR.

Referenced by collapse_into().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_CPP()

bool tree_manager::is_CPP ( ) const

is_CPP return true in case we have at least one CPP source code

Returns
true when at least one translation unit is written in C++

Definition at line 2839 of file tree_manager.cpp.

References Param.

Referenced by add_identifier_node(), and GetFunction().

Here is the caller graph for this function:

◆ is_top_function()

bool tree_manager::is_top_function ( const function_decl fd) const

is_top_function checks if a function is one of the application top functions.

Parameters
fdis the function decl
Returns
true in case fd is a top function

Definition at line 2846 of file tree_manager.cpp.

References tree_node::get_kind(), GET_NODE, decl_node::name, and Param.

Referenced by add_identifier_node(), and tree_helper::print_function_name().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_tree_node()

bool tree_manager::is_tree_node ( unsigned int  i) const

Return true if there exists a tree node associated with the given id, false otherwise.

Parameters
iis the index of the tree_node to be checked

Definition at line 171 of file tree_manager.cpp.

References tree_nodes.

◆ merge_tree_managers()

void tree_manager::merge_tree_managers ( const tree_managerRef source_tree_manager)

merge two tree manager: this with TM_source

Parameters
TM_sourceis one of the tree_manager.

a declaration is uniquely identified by the name and by the scope in case the decl_node has a mangle the associated identifier_node is unique a decl_node without name is not added to the symbol table a decl_node local to a function_decl (scpe is a function_decl) is not added to the symbol table a decl_node local to a type_node without name is not added to the symbol table a static decl_node is not added to the symbol table memory_tag, parm_decl, result_decl are not added to the symbol table declaration with type_node local to a function are not considered the key of the declaration symbol table is structured as "name--scope" the value of the declaration symbol table is the nodeID of the tree_node in the tree_manager

a type_node without name is not added to the symbol table a type_node local to a function_decl is not added to the symbol table the key of the type symbol table is structured as "name" the value of the type symbol table is the nodeID of the tree_node in the tree_manager

this table is used to give a name to unqualified record or union

global static variable and function become global so we need some sort of uniquification

build the symbol tables of tree_node inheriting from type_node and then from decl_node; decl_nodes have to be examinated later since they have to be examinated after the record/union types???

give a name to unql where possible

check for decl_node

check for static

check for function_decl undefined

source static function declaration used to correctly rename declaration and definition of a function

the key is the old index while the values is the new index

At the moment the reverse of remap; it is filled only with function_decl without body

For each static function in source_tree_manager the index of the tree node (in source_tree_manager) of its forward declaration

For each static function in TM?source the index of the tree node (in source_tree_manager) of its implementation

set of nodes that will be added to the current tree manager (this)

FIXME: during one of the analysis of the tree nodes of source_tree_manager, new nodes can be inserted; if source_tree_manager->tree_nodes is a undirected_map, the insertion of a new node can invalidate the iterators because of rehash; for this reason we temporary copy the unordered_map in map

remap tree_node from source_tree_manager to this tree_manager first remap the types and then decl

check for decl_node

overwrite gst_it->second

overwrite gst_it->second

overwrite gst_it->second

overwrite gst_it->second

remap tree_node from source_tree_manager to this tree_manager

check for decl_node

check for static

Management of forward declaration of static function

Implementation node

If this is the implementation already remaps so that also forward declaration can be remapped on the same node

If we have already encountered forward declaration, remap it on the same node

Forward declaration

Check if we have already encountered function implementation, remap this on the same node

CHECK: reference to source_tree_manager tree_node in tree_reindex

static function or var_decl with a conflicting name so we fix the name... and we fix in the source tree_manager

CHECK: reference to source_tree_manager tree_node in tree_reindex

The following statements force ti_source.first to overwrite gst_it->second

If the symbol is in reverse_remap, it means that is a function_decl without body coming from other; it has not to be remapped

already performed

tree node visitor

compute the vertexes reached from all function_decl of source_tree_manager

Definition at line 1818 of file tree_manager.cpp.

References check_for_decl(), check_for_type(), counter, tree_node_index_factory::create_tree_node(), debug_level, DEBUG_LEVEL_PARANOIC, find_identifier_nodeID(), FIRST_TOKEN, GET_INDEX_NODE, tree_node::get_kind(), get_next_available_tree_node_id(), INDENT_DBG_MEX, new_tree_node_id(), Param, STR, THROW_ASSERT, TOK, TOK_STRG, and tree_nodes.

Referenced by CompilerWrapper::FillTreeManager().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ new_tree_node_id()

unsigned int tree_manager::new_tree_node_id ( const unsigned int  ask = 0)

Return a new node id in the intermediate representation.

Parameters
askis the requested id; if it is not used will be returned otherwise a new id
Returns
the new node is

Definition at line 323 of file tree_manager.cpp.

References GetTreeReindex(), last_node_id, and tree_nodes.

Referenced by dead_code_elimination::add_gimple_nop(), PhiOpt::ApplyIfMerge(), PhiOpt::ApplyIfRemove(), PhiOpt::ApplyMultiMerge(), PhiOpt::ApplyMultiRemove(), collapse_into(), tree_manipulation::create_binary_operation(), tree_manipulation::create_extract_bit_expr(), tree_manipulation::create_function_decl(), tree_manipulation::create_gimple_call(), tree_manipulation::create_gimple_cond(), tree_manipulation::create_gimple_modify_stmt(), tree_manipulation::create_gimple_return(), tree_manipulation::create_goto(), tree_manipulation::create_identifier_node(), tree_manipulation::create_label(), tree_manipulation::create_lut_expr(), PragmaAnalysis::create_map_pragma(), PragmaAnalysis::create_omp_pragma(), tree_manipulation::create_parm_decl(), tree_manipulation::create_phi_node(), tree_manipulation::create_quaternary_operation(), tree_manipulation::create_result_decl(), tree_manipulation::create_ssa_name(), tree_manipulation::create_ternary_operation(), tree_manipulation::create_translation_unit_decl(), tree_manipulation::create_unary_operation(), create_unique_const(), tree_manipulation::create_var_decl(), tree_manipulation::CreateAddrExpr(), tree_manipulation::CreateAndExpr(), tree_manipulation::CreateCallExpr(), tree_manipulation::CreateEqExpr(), tree_manipulation::CreateNopExpr(), tree_manipulation::CreateNotExpr(), tree_manipulation::CreateOrExpr(), tree_manipulation::CreateUnsigned(), tree_manipulation::CreateVectorBooleanType(), tree_manipulation::GetBitsizeType(), tree_manipulation::GetBooleanType(), tree_manipulation::GetCustomIntegerType(), tree_manipulation::GetFunctionType(), tree_manipulation::GetPointerType(), tree_manipulation::GetSignedIntegerType(), tree_manipulation::GetSizeType(), tree_manipulation::GetUnsignedIntegerType(), tree_manipulation::GetUnsignedLongLongType(), tree_manipulation::GetVoidType(), SwitchFix::InternalExec(), rebuild_initialization::InternalExec(), operations_cfg_computation::InternalExec(), dead_code_elimination::kill_uses(), dead_code_elimination::kill_vdef(), rebuild_initialization2::look_for_ROMs(), merge_tree_managers(), multi_way_if::MergeCondCond(), multi_way_if::MergeCondMulti(), multi_way_if::MergeMultiCond(), and multi_way_if::MergeMultiMulti().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print()

void tree_manager::print ( std::ostream &  os) const

Function that prints the class tree_manager.

Parameters
Paramis the set of the parameter
osis the stream where tree_manager will be printed

Definition at line 283 of file tree_manager.cpp.

References CompilerWrapper::bambu_ir_info, last_node_id, and tree_nodes.

Referenced by FrontendFlowStep::PrintTreeManager().

Here is the caller graph for this function:

◆ PrintGimple()

void tree_manager::PrintGimple ( std::ostream &  os,
const bool  use_uid 
) const

Function that prints the bodies of function in gimple format.

Parameters
osis the stream where bodies will be printed
use_uidtells if uid of gimple index has to be used

Definition at line 301 of file tree_manager.cpp.

References function_decl_nodes.

Referenced by collapse_into(), and FrontendFlowStep::PrintTreeManager().

Here is the caller graph for this function:

◆ RecursiveReplaceTreeNode()

void tree_manager::RecursiveReplaceTreeNode ( tree_nodeRef tn,
const tree_nodeRef  old_node,
const tree_nodeRef new_node,
const tree_nodeRef stmt,
bool  definition 
)

Replace the occurrences of tree node old_node with new_node in statement identified by tn.

Operates recursively. NOTE: tn must be a reference since we are replacing the tree_node in other tree_node fields

Parameters
tnis the statement from which the recursion begin. It must be a statement.
old_nodeis the node whose occurrences have to be replace
new_nodeis the node that replaces occurrences of old_node
stmtis the statement from which the recursion originates (necessary to update ssa_nodes usage information)
definitionis true if old_node is a ssa_name in the left part of a gimple_assign

Check if we need to update uses or definitions

Definition at line 965 of file tree_manager.cpp.

References test_panda::arg, CASE_BINARY_EXPRESSION, CASE_CPP_NODES, CASE_FAKE_NODES, CASE_PRAGMA_NODES, CASE_QUATERNARY_EXPRESSION, CASE_TERNARY_EXPRESSION, CASE_TYPE_NODES, CASE_UNARY_EXPRESSION, tree_helper::ComputeSsaUses(), counter, DEBUG_LEVEL_PARANOIC, GET_CONST_NODE, GET_FUNCTION_DEBUG_LEVEL, GET_INDEX_NODE, tree_node::get_kind(), GET_NODE, INDENT_DBG_MEX, tree_node::index, Param, STR, THROW_ASSERT, THROW_ERROR, and tree_node::ToString().

Referenced by collapse_into(), FunctionCallTypeCleanup::ParametersTypeCleanup(), and ReplaceTreeNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReplaceTreeNode()

void tree_manager::ReplaceTreeNode ( const tree_nodeRef stmt,
const tree_nodeRef old_node,
const tree_nodeRef new_node 
)

Replace the occurrences of tree node old_node with new_node in statement identified by tn.

Operates recursively.

Parameters
tnis the statement from which the recursion begin. It must be a statement.
old_nodeis the node whose occurrences have to be replace
new_nodeis thenode that replaces occurrences of old_node

Temporary variable used to pass first argument of RecursiveReplaceTreeNode by reference. Since it is a gimple_node it has not to be replaced

Definition at line 953 of file tree_manager.cpp.

References GET_NODE, RecursiveReplaceTreeNode(), STR, THROW_ASSERT, and tree_node::ToString().

Referenced by add_identifier_node(), tree_manipulation::InlineFunctionCall(), compute_implicit_calls::InternalExec(), MultipleEntryIfReduction::InternalExec(), PhiOpt::InternalExec(), dead_code_elimination::kill_uses(), Bit_Value_opt::optimize(), lut_transformation::ProcessBasicBlock(), Bit_Value_opt::propagateValue(), PhiOpt::RemoveCondExpr(), InterfaceInfer::setReadInterface(), PhiOpt::SinglePhiOptimization(), and tree_manipulation::VersionFunctionCall().

Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator<< [1/2]

std::ostream& operator<< ( std::ostream &  os,
const tree_manager s 
)
friend

Friend definition of the << operator.

Definition at line 364 of file tree_manager.hpp.

◆ operator<< [2/2]

std::ostream& operator<< ( std::ostream &  os,
const tree_managerRef s 
)
friend

Friend definition of the << operator.

Pointer version.

Definition at line 373 of file tree_manager.hpp.

Field Documentation

◆ added_goto

unsigned int tree_manager::added_goto
private

the number of added goto

Definition at line 113 of file tree_manager.hpp.

Referenced by add_goto(), and get_added_goto().

◆ already_visited

CustomUnorderedSet<tree_nodeRef> tree_manager::already_visited
private

set of already examined addr_expr used to avoid circular recursion

Definition at line 107 of file tree_manager.hpp.

◆ collapse_into_counter

unsigned int tree_manager::collapse_into_counter
private

Index of current call of collapse_into_counter.

Definition at line 145 of file tree_manager.hpp.

Referenced by collapse_into().

◆ debug_level

int tree_manager::debug_level
private

◆ find_cache

CustomUnorderedMapUnstable<std::string, unsigned int> tree_manager::find_cache
private

cache for tree_manager::find

Definition at line 88 of file tree_manager.hpp.

Referenced by find().

◆ function_decl_nodes

std::map<unsigned int, tree_nodeRef> tree_manager::function_decl_nodes
private

Variable containing set of function_declaration with their index node.

Definition at line 101 of file tree_manager.hpp.

Referenced by add_function(), function_index_mngl(), get_function_decl_node_n(), GetAllFunctions(), GetFunction(), and PrintGimple().

◆ identifiers_unique_table

CustomUnorderedMapUnstable<std::string, unsigned int> tree_manager::identifiers_unique_table
private

this table stores all identifier_nodes with their nodeID.

Definition at line 131 of file tree_manager.hpp.

Referenced by find_identifier_nodeID().

◆ last_node_id

unsigned int tree_manager::last_node_id
private

◆ n_pl

unsigned int tree_manager::n_pl
private

the number of parallel loops

Definition at line 110 of file tree_manager.hpp.

Referenced by add_parallel_loop(), and get_n_pl().

◆ next_vers

unsigned int tree_manager::next_vers
private

Next version number for ssa variables.

Definition at line 142 of file tree_manager.hpp.

Referenced by get_next_vers().

◆ Param

const ParameterConstRef tree_manager::Param
private

◆ removable_pointer_plus

unsigned int tree_manager::removable_pointer_plus
private

the number of removable pointer_plus

Definition at line 119 of file tree_manager.hpp.

Referenced by get_removable_pointer_plus(), and increment_removable_pointer_plus().

◆ removed_pointer_plus

unsigned int tree_manager::removed_pointer_plus
private

the number of removed pointer_plus

Definition at line 116 of file tree_manager.hpp.

Referenced by get_removed_pointer_plus(), and increment_removed_pointer_plus().

◆ stack

std::deque<tree_nodeRef> tree_manager::stack
private

list of examining statements during collapse_into recursion

Definition at line 104 of file tree_manager.hpp.

◆ tree_nodes

OrderedMapStd<unsigned int, tree_nodeRef> tree_manager::tree_nodes
private

◆ unique_cst_map

CustomUnorderedMap<std::pair<std::string, unsigned int>, tree_nodeRef> tree_manager::unique_cst_map
private

Definition at line 133 of file tree_manager.hpp.

Referenced by create_unique_const().

◆ unremoved_pointer_plus

unsigned int tree_manager::unremoved_pointer_plus
private

the number of unremoved pointer_plus

Definition at line 122 of file tree_manager.hpp.

Referenced by get_unremoved_pointer_plus(), and increment_unremoved_pointer_plus().

◆ uses_erase_temp

CustomUnorderedMap<ssa_name*, tree_nodeRef> tree_manager::uses_erase_temp
private

Map containing temporary information for ssa_name uses deletion.

Definition at line 139 of file tree_manager.hpp.


The documentation for this class was generated from the following files:

Generated on Mon Feb 12 2024 13:04:07 for PandA-2024.02 by doxygen 1.8.13