46 #ifndef TREE_MANAGER_HPP 47 #define TREE_MANAGER_HPP 49 #include "config_HAVE_UNORDERED.hpp" 79 #define BUILTIN_SRCP "<built-in>:0:0" 158 std::string& symbol_scope,
unsigned int node_id,
165 std::string& symbol_scope,
167 unsigned int node_id);
277 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string>& tree_node_schema);
284 unsigned int find(
enum kind tree_node_type,
285 const std::map<TreeVocabularyTokenTypes_TokenEnum, std::string>& tree_node_schema);
328 unsigned int function_index(
const std::string& function_name)
const;
352 void print(std::ostream& os)
const;
359 void PrintGimple(std::ostream& os,
const bool use_uid)
const;
459 identifiers_unique_table[
str] = nodeID;
tree_nodeRef create_unique_const(const std::string &val, const tree_nodeConstRef &type)
void increment_unremoved_pointer_plus()
Increment the number of not removed pointer plus.
unsigned int next_vers
Next version number for ssa variables.
unsigned int get_removed_pointer_plus() const
Return the number of removed pointer plus.
void add_parallel_loop()
increment the number a parallel loop
const ParameterConstRef Param
Set of parameters.
void increment_removable_pointer_plus()
Increment the number of removable pointer plus.
const CustomUnorderedSet< unsigned int > GetAllFunctions() const
Returns all the functions in the tree_manager.
const tree_nodeRef CGetTreeReindex(const unsigned int i) const
Return a tree_reindex wrapping the i-th tree_node.
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...
struct definition of the function_decl tree node.
unsigned int get_removable_pointer_plus() const
Return the number of not removed pointer plus.
This class manages the tree structures extracted from the raw file.
unsigned int last_node_id
last node_id used
friend std::ostream & operator<<(std::ostream &os, const tree_managerRef &s)
Friend definition of the << operator.
unsigned int get_next_available_tree_node_id() const
return the next available tree node id.
enum kind int REF_FORWARD_DECL(tree_manager)
void AddTreeNode(const unsigned int i, const tree_nodeRef &curr)
Add to the tree manager the current node.
unsigned int get_unremoved_pointer_plus() const
Return the number of not removed pointer plus.
CustomUnorderedSet< tree_nodeRef > already_visited
set of already examined addr_expr used to avoid circular recursion
absl::flat_hash_map< T, U, Hash, Eq, Alloc > CustomUnorderedMapUnstable
unsigned int get_next_vers()
Return the next unused version number for ssa variables.
unsigned int added_goto
the number of added goto
redefinition of map to manage ordered/unordered structures
const tree_nodeConstRef CGetTreeNode(const unsigned int i) const
Abstract pure class for the tree structure.
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...
tree_manager(const ParameterConstRef &Param)
This is the constructor of the tree_manager which initializes the vector of functions.
unsigned int function_index_mngl(const std::string &function_name) const
Return the index of a function given its mangled name.
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.
unsigned int function_index(const std::string &function_name) const
Return the index of a function given its name.
bool is_top_function(const function_decl *fd) const
is_top_function checks if a function is one of the application top functions.
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 tre...
absl::flat_hash_map< T, U, Hash, Eq, Alloc > CustomUnorderedMap
CONSTREF_FORWARD_DECL(Parameter)
unsigned int new_tree_node_id(const unsigned int ask=0)
Return a new node id in the intermediate representation.
tree_nodeRef CreateUniqueRealCst(long double value, const tree_nodeConstRef &type)
memoization of integer constants
int debug_level
The debug level.
void add_function(unsigned int index, tree_nodeRef curr)
Add to the function_decl_nodes the current node.
CustomUnorderedMapUnstable< std::string, unsigned int > identifiers_unique_table
this table stores all identifier_nodes with their nodeID.
unsigned int n_pl
the number of parallel loops
bool check_ssa_uses(unsigned int fun_id) const
check_ssa_uses check if the uses of a ssa are correct
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 re...
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.
void increment_removed_pointer_plus()
Increment the number of removed pointer plus.
tree_nodeRef CreateUniqueIntegerCst(integer_cst_t value, const tree_nodeConstRef &type)
memoization of integer constants
redefinition of set to manage ordered/unordered structures
tree_nodeRef GetTreeReindex(const unsigned int i)
Return a tree_reindex wrapping the i-th tree_node.
unsigned long get_function_decl_node_n() const
Return the number of function_decl_node.
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...
unsigned int get_implementation_node(unsigned int decl_node) const
Return the index of function_decl node that implements the declaration node.
void add_goto()
Increment the number of added gotos.
unsigned int unremoved_pointer_plus
the number of unremoved pointer_plus
void merge_tree_managers(const tree_managerRef &source_tree_manager)
merge two tree manager: this with TM_source
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.
std::map< unsigned int, tree_nodeRef > function_decl_nodes
Variable containing set of function_declaration with their index node.
friend std::ostream & operator<<(std::ostream &os, const tree_manager &s)
Friend definition of the << operator.
bool is_CPP() const
is_CPP return true in case we have at least one CPP source code
tree_nodeRef GetTreeNode(const unsigned int index) const
Return the index-th tree_node (modifiable version)
TreeVocabularyTokenTypes_TokenEnum
Template definition of refcount.
std::map< _Key, _Tp, _Compare, _Alloc > OrderedMapStd
CustomUnorderedMap< ssa_name *, tree_nodeRef > uses_erase_temp
Map containing temporary information for ssa_name uses deletion.
unsigned int find_identifier_nodeID(const std::string &str) const
Return the nodeID of the identifier_node representing string str.
OrderedMapStd< unsigned int, tree_nodeRef > tree_nodes
Variable containing set of tree_nodes.
bool is_tree_node(unsigned int i) const
Return true if there exists a tree node associated with the given id, false otherwise.
std::unordered_map< T, U, Hash, Eq, Alloc > UnorderedMapStd
Autoheader include.
This file collects some hash functors.
unsigned int get_n_pl() const
return the number of parallel loops
std::deque< tree_nodeRef > stack
list of examining statements during collapse_into recursion
unsigned int collapse_into_counter
Index of current call of collapse_into_counter.
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 rec...
unsigned int get_added_goto() const
Return the number of added gotos.
This struct specifies the ssa_name node.
void print(std::ostream &os) const
Function that prints the class tree_manager.
CustomUnorderedMapUnstable< std::string, unsigned int > find_cache
cache for tree_manager::find
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 symb...
void add_identifier_node(unsigned int nodeID, const std::string &str)
Add an identifier_node to the corresponding unique table.
tree_nodeRef GetFunction(const std::string &function_name) const
Return the index of a function given its name.
unsigned int find_sc_main_node() const
Determine the index node of "sc_main" function in tree_node vector.
struct definition of the declaration node structures.
CustomUnorderedMap< std::pair< std::string, unsigned int >, tree_nodeRef > unique_cst_map
unsigned int removable_pointer_plus
the number of removable pointer_plus
unsigned int removed_pointer_plus
the number of removed pointer_plus
void PrintGimple(std::ostream &os, const bool use_uid) const
Function that prints the bodies of function in gimple format.