46 #ifndef TREE_HELPER_HPP 47 #define TREE_HELPER_HPP 64 template <
typename value>
100 const bool without_transformation,
const bool before);
216 static std::set<tree_nodeConstRef, TreeNodeConstSorter>
226 const bool without_transformation);
1006 std::vector<unsigned long long>& dims);
1026 std::vector<unsigned long long>& dims,
unsigned long long& elts_bitsize);
1054 std::vector<unsigned long long>& indexes,
1055 std::vector<unsigned long long>& size_indexes,
unsigned int& base_object);
1190 bool print_storage =
false,
unsigned int var = 0,
1192 const std::string& tail =
"");
1206 bool print_qualifiers =
false,
bool print_storage =
false,
1209 const std::string& prefix =
"",
const std::string& tail =
"");
1291 static void get_required_values(std::vector<std::tuple<unsigned int, unsigned int>>& required,
1391 serialization get_serialization(
const std::string& name)
const;
1398 bool is_transparent(
const std::string& name)
const;
static bool IsSameType(const tree_nodeConstRef &tn0, const tree_nodeConstRef &tn1)
Given two nodes tells if they have same base type (const is not considered: const double == double) ...
CustomOrderedSet< std::string > headers
Set of headers file containg standard and system types.
static bool IsStore(const tree_nodeConstRef &tn, const CustomOrderedSet< unsigned int > &fun_mem_data)
Return true if the tree node is a gimple_assign writing something which will be allocated in memory...
static bool is_a_struct(const tree_managerConstRef &TM, const unsigned int index)
Return if treenode index is a record.
This struct specifies the integer_cst node.
static std::vector< tree_nodeConstRef > CGetFieldTypes(const tree_nodeConstRef &type)
Return the fields type of a variable of type struct.
static tree_nodeConstRef GetFormalIth(const tree_nodeConstRef &obj, unsigned int parm_index)
Return the type of the ith formal parameter in case index_obj is a call_expr.
static const std::set< std::string > TLM_SC_builtin_scalar_type
store the set of TLM SystemC class for which the size corresponds to the sum of the size of template ...
static bool IsUnionType(const tree_nodeConstRef &type)
Return if treenode is an union.
static bool IsComplexType(const tree_nodeConstRef &type)
Return if treenode is a complex.
static bool is_a_nop_function_decl(const function_decl *fd)
This struct specifies the field bloc (basic block).
static int debug_level
debug level (set by Parameter)
static std::string name_function(const tree_managerConstRef &tm, const unsigned int index)
Return the name of the function.
static bool is_a_variable(const tree_managerConstRef &TM, const unsigned int index)
FIXME: to be remove after substitution with IsVariableType.
static std::vector< unsigned long long > GetArrayDimensions(const tree_nodeConstRef &node)
Return the dimension of the array.
static unsigned int GetElements(const tree_managerConstRef &TM, const unsigned int index)
Given an array or a vector return the element type.
static size_t CountPointers(const tree_nodeConstRef &)
Computes how many pointers are included in a tree node.
static unsigned long long AccessedMaximumBitsize(const tree_nodeConstRef &type_node, unsigned long long bitsize)
return the maximum bitsize associated with the elements accessible through type_node ...
static unsigned long long get_array_num_elements(const tree_managerConstRef &TM, const unsigned int index)
Return the total number of elements of the the base type in the array.
static bool IsExternDeclaration(const tree_nodeConstRef &decl)
static bool is_out_port(const tree_managerConstRef &TM, const unsigned int index)
This function test if a given index is a SystemC output port.
static unsigned int get_field_idx(const tree_managerConstRef &TM, const unsigned int index, unsigned int idx)
Return the idx element of the fields declared in an union or a record type.
This class collects some utility functions used to extract information from tree-based data structure...
static bool IsFunctionPointerType(const tree_nodeConstRef &type)
Return true if the treenode is of type function pointer type.
static bool is_int(const tree_managerConstRef &TM, const unsigned int index)
Return true if the treenode is of integer type.
CustomOrderedSet< std::string > transparent
Set of not opaque functions.
static bool IsConstant(const tree_nodeConstRef &node)
Return if a tree node is a constant object.
static std::set< tree_nodeConstRef, TreeNodeConstSorter > GetTypesToBeDeclaredAfter(const tree_nodeConstRef &tn, const bool without_transformation)
Return the types to be declared after declaring index type.
static unsigned int get_var_alignment(const tree_managerConstRef &TM, unsigned int var)
Return the var alignment.
static std::string get_asm_string(const tree_managerConstRef &TM, const unsigned int node_index)
return the string associated with the gimple_asm
This struct specifies the statement_list node.
static bool LastStatement(const tree_nodeConstRef &statement)
Return true if statement must be the last of a basic block.
static bool is_unsigned(const tree_managerConstRef &TM, const unsigned int index)
Return true if the treenode is of unsigned integer type.
static tree_nodeConstRef CGetArrayBaseType(const tree_nodeConstRef &type)
static bool IsArrayEquivType(const tree_nodeConstRef &type)
Return true if treenode is an array or it is equivalent to an array (record recursively having a sing...
static bool has_function_return(const tree_managerConstRef &tm, const unsigned int index)
Return true if the function index returns a not void type, false otherwise.
static bool is_a_misaligned_vector(const tree_managerConstRef &TM, const unsigned int index)
Return true if the treenode index is a a misaligned access to a vector data object.
static std::string print_type(const tree_managerConstRef &TM, unsigned int type, bool global=false, bool print_qualifiers=false, bool print_storage=false, unsigned int var=0, const var_pp_functorConstRef &vppf=var_pp_functorConstRef(), const std::string &prefix="", const std::string &tail="")
Print a type and its variable in case var is not zero.
static bool is_builtin_channel(const tree_managerConstRef &TM, const unsigned int index)
This function test if a given index is a SystemC builtin channel.
static bool is_real(const tree_managerConstRef &TM, const unsigned int index)
Return true if the treenode is of real type.
struct definition of the function_decl tree node.
This class manages the tree structures extracted from the raw file.
static std::string return_C_qualifiers(const TreeVocabularyTokenTypes_TokenEnum quals, bool real_const)
return the qualifiers in C format
static bool is_static(const tree_managerConstRef &TM, const unsigned int index)
FIXME: to be remove after substitution with IsStaticDeclaration.
static tree_nodeConstRef CGetElements(const tree_nodeConstRef &type)
Given an array or a vector return the element type.
static bool is_clock(const tree_managerConstRef &TM, const unsigned int index)
This function test if a given index as parm is a SystemC sc_clock.
static bool is_natural(const tree_managerConstRef &TM, const unsigned int index)
Return true if the treenode is a ssa_name greater or equal to zero.
static bool is_parameter(const tree_managerConstRef &TM, const unsigned int index)
return true in case the index corresponds to a parameter in ssa form or not
static bool IsFunctionDeclaration(const tree_nodeConstRef &type)
Return true if treenode is a function_decl.
static bool IsVoidType(const tree_nodeConstRef &type)
Return true if the treenode is of void type.
static bool is_channel(const tree_managerConstRef &TM, const unsigned int index)
This function test if a given index is a SystemC channel.
static bool IsVolatile(const tree_nodeConstRef &tn)
return true in case the tree node corresponds to a volatile variable
static unsigned long long GetArrayElementSize(const tree_nodeConstRef &node)
Return the size (in bits) of the base element of the array.
static std::string print_function_name(const tree_managerConstRef &TM, const function_decl *fd)
Return the name of the function in a string.
static std::string getFunctionTypeString(const tree_nodeRef &FT)
Return a string describing the functino type.
static unsigned int get_multi_way_if_pos(const tree_managerConstRef &TM, unsigned int node_id, unsigned int cond)
return the position of con in the gimple_multi_way_if conditions
static const std::set< std::string > SC_tmpl_class
store the set of SystemC class for which the type correspond to the template parameter ...
static unsigned int get_type_index(const tree_managerConstRef &TM, const unsigned int index, long long int &vec_size, bool &is_a_pointer, bool &is_a_function)
Return the treenode index of the type of index.
This struct specifies the binfo node.
static bool is_an_enum(const tree_managerConstRef &TM, const unsigned int index)
Return if treenode index is an enumeral type.
static void get_required_values(std::vector< std::tuple< unsigned int, unsigned int >> &required, const tree_nodeRef &tn)
static bool is_packed_access(const tree_managerConstRef &TreeM, unsigned int node_index)
Check if the access is on a packed data structure or not.
static void get_used_variables(bool first_level_only, const tree_nodeConstRef &t, CustomUnorderedSet< unsigned int > &list_of_variable)
Return the list of tree nodes associated with the variable used by the node t.
static bool IsEnumType(const tree_nodeConstRef &type)
Return if treenode index is an enumeral type.
static bool is_a_function(const tree_managerConstRef &TM, const unsigned int index)
Return if treenode index is a function_decl.
static bool is_packed(const tree_managerConstRef &TreeM, unsigned int node_index)
FIXME: to be remove after substitution with IsPackedType.
static bool IsInLibbambu(const tree_managerConstRef &TM, const unsigned int index)
Return true if the decl node or type is in libbambu.
Abstract pure class for the tree structure.
static std::string GetMangledFunctionName(const function_decl *fd)
Return the mangled function name.
static bool IsVariableType(const tree_nodeConstRef &node)
Return true if the treenode is a valid variable.
static std::string GetTemplateTypeName(const tree_nodeConstRef &type)
Return the name of template without parameters.
static tree_nodeConstRef GetUnqualifiedType(const tree_nodeConstRef &type)
Return the unqualified version of a type.
static bool IsScalarType(const tree_nodeConstRef &type)
Return true if the treenode is an int, an unsigned, a real or a Boolean data type.
static bool HasToBeDeclared(const tree_managerConstRef &TM, const tree_nodeConstRef &type)
Return true if the type has to be declared.
static bool IsUnsignedIntegerType(const tree_nodeConstRef &type)
Return true if the treenode is of unsigned integer type.
static bool is_system(const tree_managerConstRef &TM, const unsigned int index)
Return true if variable or type is a system one.
static bool IsSignedIntegerType(const tree_nodeConstRef &type)
Return true if the treenode is of integer type.
static bool IsArrayType(const tree_nodeConstRef &type)
Return true if treenode is an array.
static unsigned long long AccessedMinimunBitsize(const tree_nodeConstRef &type_node, unsigned long long bitsize)
return the minimum bitsize associated with the elements accessible through type_node ...
static unsigned long long get_array_data_bitsize(const tree_managerConstRef &TM, const unsigned int index)
Return the size (in bits) of the base element of the array.
static unsigned long long Size(const tree_nodeConstRef &tn)
Return the size of a tree object.
static unsigned int GetUnqualified(const tree_managerConstRef &TM, unsigned int type)
Return the unqualified version of a type.
static bool is_const_type(const tree_managerConstRef &TM, const unsigned int index)
Return if the treenode is of const type.
static bool IsBooleanType(const tree_nodeConstRef &type)
Return true if the treenode is of bool type.
static bool IsSystemType(const tree_nodeConstRef &type)
Return true if variable or type is a system one.
static bool is_signal(const tree_managerConstRef &TM, const unsigned int index)
This function test if a given index is a SystemC sc_signal.
static tree_nodeRef GetFieldIdx(const tree_nodeConstRef &type, unsigned int idx)
Return the element of the fields declared in an union or a record type.
static void compute_ssa_uses_rec_ptr(const tree_nodeConstRef &tn, CustomOrderedSet< const ssa_name *> &ssa_uses)
recursively compute the pointers to the ssa_name variables used in a statement
static std::set< tree_nodeConstRef, TreeNodeConstSorter > GetTypesToBeDeclaredBefore(const tree_nodeConstRef &tn, const bool without_transformation)
Return the types to be declared before declaring index type.
static bool is_virtual(const tree_managerConstRef &TM, const unsigned int index)
return true in case the ssa_name is virtual
static bool is_module(const tree_managerConstRef &TM, unsigned int index)
This function test if a given index is a SystemC module.
static std::tuple< std::string, unsigned int, unsigned int > GetSourcePath(const tree_nodeConstRef &node, bool &is_system)
Return where a function or a type is defined.
static integer_cst_t get_integer_cst_value(const integer_cst *ic)
Convert a integer_cst in a long long value.
static bool IsFunctionType(const tree_nodeConstRef &type)
Return true if the treenode is of type function type.
static bool is_a_void(const tree_managerConstRef &TM, const unsigned int index)
Return true if the treenode is of void type.
static bool is_scalar(const tree_managerConstRef &TM, const unsigned int var)
Return true if the treenode is an int, an unsigned, a real or a Boolean data type.
CONSTREF_FORWARD_DECL(tree_manager)
static std::string return_qualifier_prefix(const TreeVocabularyTokenTypes_TokenEnum quals)
return the prefix given a qualifier
redefinition of set to manage ordered/unordered structures
REF_FORWARD_DECL(tree_manager)
static bool IsVectorType(const tree_nodeConstRef &type)
Return true if the treenode is a vector.
static std::string GetRecordTypeName(const tree_nodeConstRef &type)
Return the name of the class.
Base class functor used by prettyPrintVertex to print variables.
static std::string NormalizeTypename(const std::string &id)
Return normalized name of types and variables.
static bool IsStaticDeclaration(const tree_nodeConstRef &decl)
serialization
Specify the type of serialization that a function must have.
static bool is_function_type(const tree_managerConstRef &TM, const unsigned int index)
Return true if the treenode is of type function type.
static bool is_a_pointer(const tree_managerConstRef &TM, const unsigned int index)
Return if treenode index is a pointer.
static bool has_omp_simd(const statement_list *sl)
Check if omp simd pragmas are present in given statement list.
static size_t AllocatedMemorySize(const tree_nodeConstRef ¶meter)
Compute the memory (in bytes) to be allocated to store a parameter or a variable. ...
used to avoid expansion of c library function or type
static unsigned int GetRealType(const tree_managerConstRef &TM, unsigned int index)
Return the real type.
static bool is_an_addr_expr(const tree_managerConstRef &TM, const unsigned int index)
Return if treenode index is an address expression.
TreeVocabularyTokenTypes_TokenEnum
static bool is_volatile(const tree_managerConstRef &TM, const unsigned int index)
return true in case the index corresponds to a volatile variable
Template definition of refcount.
static tree_nodeRef find_obj_type_ref_function(const tree_nodeConstRef &tn)
Given the tree_node of an obj_type_ref return the tree_node of the called function.
~tree_helper()
Destructor.
static bool is_ssa_name(const tree_managerConstRef &TM, const unsigned int index)
Return true in case index is a ssa_name.
static bool is_event(const tree_managerConstRef &TM, const unsigned int index)
This function test if a given index is a SystemC event.
static bool is_port(const tree_managerConstRef &TM, const unsigned int index)
This function test if a given index is a SystemC port.
static std::string op_symbol(const tree_nodeConstRef &op)
Function return the symbol related with the operator op passed as parameter.
static unsigned int get_formal_ith(const tree_managerConstRef &TM, unsigned int index_obj, unsigned int parm_index)
return the type of the ith formal parameter in case index_obj is a call_expr
static bool look_for_binfo_inheritance(const binfo *b, const std::string &bcs)
Look for inheritance of a class.
static size_t GetFunctionSize(const tree_managerConstRef &TM, const unsigned int function_index)
Return the number of statement + the number of phi in the function.
static bool IsPackedType(const tree_nodeConstRef &type)
static bool is_function_pointer_type(const tree_managerConstRef &TM, const unsigned int index)
Return true if the treenode is of type function pointer type.
static tree_nodeConstRef GetBaseVariable(const tree_nodeConstRef &mem)
Retrun the base variable of a memory access.
struct definition of the type node structures.
CustomOrderedSet< tree_nodeRef > lib_types
Set of types which are in c system library.
static bool is_an_union(const tree_managerConstRef &TM, const unsigned int index)
Return if treenode index is an union.
static bool is_concat_bit_ior_expr(const tree_managerConstRef &TM, const unsigned int index)
check if a given tree node is a concatenation operation
CustomOrderedSet< std::string > internal_serialize
Set of functions which need only internal serialization.
static void get_array_dimensions(const tree_managerConstRef &TM, const unsigned int index, std::vector< unsigned long long > &dims)
Return the dimension of the array.
static bool is_fully_resolved(const tree_managerConstRef &TM, const unsigned int index, CustomOrderedSet< unsigned int > &res_set)
FIXME: to be remove after substitution with IsPointerResolved.
static bool is_simple_pointer_plus_test(const tree_managerConstRef &TM, const unsigned int index)
check if a given tree node is a simple pointer plus expression
static std::string PrintType(const tree_managerConstRef &TM, const tree_nodeConstRef &type, bool global=false, bool print_qualifiers=false, bool print_storage=false, const tree_nodeConstRef &var=nullptr, const var_pp_functorConstRef &vppf=var_pp_functorConstRef(), const std::string &prefix="", const std::string &tail="")
Print a type and its variable in case var is not zero.
static bool is_a_complex(const tree_managerConstRef &TM, const unsigned int index)
Return if treenode index is a complex.
static tree_nodeConstRef CGetType(const tree_nodeConstRef &node)
Return the treenode of the type of node.
static bool IsStructType(const tree_nodeConstRef &type)
Return true if treenode is a record.
static bool is_extern(const tree_managerConstRef &TM, const unsigned int index)
FIXME: to be remove after substitution with IsExternDeclaration.
CustomOrderedSet< std::string > no_serialize
Set of functions which don't need serialization.
static bool is_inout_port(const tree_managerConstRef &TM, const unsigned int index)
This function test if a given index is a SystemC in-output port.
static tree_nodeConstRef CGetPointedType(const tree_nodeConstRef &pointer)
Return the pointed type of a pointer object.
static bool is_bool(const tree_managerConstRef &TM, const unsigned int index)
Return true if the treenode is of bool type.
static unsigned int get_base_index(const tree_managerConstRef &TM, const unsigned int index)
Retrun the base address of a memory access.
static bool IsLut(const tree_nodeConstRef &tn)
Return true in case the right operation is a lut_expr.
static std::string get_type_name(const tree_managerConstRef &TM, const unsigned int index)
Return name of the type.
This struct specifies the ssa_name node.
static std::string GetFunctionName(const tree_managerConstRef &TM, const tree_nodeConstRef &decl)
Return the name of the function.
static bool is_a_vector(const tree_managerConstRef &TM, const unsigned int index)
Return true if the treenode index is a vector.
static integer_cst_t GetConstValue(const tree_nodeConstRef &tn, bool is_signed=true)
Get value from integer constant.
static unsigned int get_array_var(const tree_managerConstRef &TM, const unsigned int index, bool is_written, bool &two_dim_p)
Return the tree node index of the array variable written or read.
static bool IsAligned(const tree_managerConstRef &TM, unsigned int type)
Return true if type has not default alignment.
static void extract_array_indexes(const tree_managerConstRef &TM, const unsigned int index, std::vector< unsigned long long > &indexes, std::vector< unsigned long long > &size_indexes, unsigned int &base_object)
Return the indexes of the array_ref.
static bool is_constant(const tree_managerConstRef &TM, const unsigned int index)
Return if a tree node is a constant object.
refcount< const var_pp_functor > var_pp_functorConstRef
static bool IsPointerType(const tree_nodeConstRef &type)
Return true if treenode index is a pointer.
static std::string GetTypeName(const tree_nodeConstRef &type)
Return name of the type.
tree_helper()
Constructor.
static bool IsPointerResolved(const tree_nodeConstRef &ptr, CustomOrderedSet< unsigned int > &res_set)
static tree_nodeConstRef GetFunctionReturnType(const tree_nodeConstRef &function, bool void_as_null=true)
Return the return type of a function.
static void RecursiveGetTypesToBeDeclared(std::set< tree_nodeConstRef, TreeNodeConstSorter > &returned_types, const tree_nodeConstRef &type, const bool recursion, const bool without_transformation, const bool before)
Return the types to be declared before/after declaring type.
static void ComputeSsaUses(const tree_nodeRef &, TreeNodeMap< size_t > &uses)
recursively compute the references to the ssa_name variables used in a statement
static unsigned int get_pointed_type(const tree_managerConstRef &TM, const unsigned int index)
Return the tree_node index of the pointed type of a pointer object;.
static bool is_SC_BIND_PROXY_NIL(const tree_managerConstRef &TM, const unsigned int index)
This function test if a given index as parm is a SC_BIND_PROXY_NIL.
static std::vector< tree_nodeConstRef > GetParameterTypes(const tree_nodeConstRef &ftype)
Return the tree node of parameter types.
static bool IsLoad(const tree_nodeConstRef &tn, const CustomOrderedSet< unsigned int > &fun_mem_data)
Return true if the tree node is a gimple_assign reading something which will be allocated in memory...
static bool IsConstType(const tree_nodeConstRef &type)
Return true if the treenode is of const type.
static bool HasReturnType(const tree_managerConstRef &tm, const unsigned int index)
Return true if the function index returns a not void type, false otherwise.
static bool IsPositiveIntegerValue(const tree_nodeConstRef &type)
Return true if the treenode is a ssa_name greater or equal to zero.
static void get_parameter_types(const tree_managerConstRef &TM, const unsigned int index, std::list< unsigned int > ¶ms)
Return the tree node of parameter types.
static unsigned long long GetArrayTotalSize(const tree_nodeConstRef &node)
Return the total number of elements of the the base type in the array.
A map with key tree_nodeRef.
static const std::set< std::string > SC_builtin_scalar_type
store the set of SystemC class for which the template parameter correspond to the bit size of the typ...
static bool is_an_array(const tree_managerConstRef &TM, const unsigned int index)
Return if treenode index is an array or it is equivalent to an array (record recursively having a sin...
static bool IsRealType(const tree_nodeConstRef &type)
Return true if the treenode is of real type.
static bool is_in_port(const tree_managerConstRef &TM, const unsigned int index)
This function test if a given index is a SystemC input port.
static void get_array_dim_and_bitsize(const tree_managerConstRef &TM, const unsigned int index, std::vector< unsigned long long > &dims, unsigned long long &elts_bitsize)
Return the dimension of the array.