PandA-2024.02
tree_helper.hpp
Go to the documentation of this file.
1 /*
2  *
3  * _/_/_/ _/_/ _/ _/ _/_/_/ _/_/
4  * _/ _/ _/ _/ _/_/ _/ _/ _/ _/ _/
5  * _/_/_/ _/_/_/_/ _/ _/_/ _/ _/ _/_/_/_/
6  * _/ _/ _/ _/ _/ _/ _/ _/ _/
7  * _/ _/ _/ _/ _/ _/_/_/ _/ _/
8  *
9  * ***********************************************
10  * PandA Project
11  * URL: http://panda.dei.polimi.it
12  * Politecnico di Milano - DEIB
13  * System Architectures Group
14  * ***********************************************
15  * Copyright (C) 2004-2024 Politecnico di Milano
16  *
17  * This file is part of the PandA framework.
18  *
19  * The PandA framework is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <http://www.gnu.org/licenses/>.
31  *
32  */
46 #ifndef TREE_HELPER_HPP
47 #define TREE_HELPER_HPP
48 
49 #include "custom_set.hpp"
50 #include "panda_types.hpp"
51 #include "refcount.hpp"
52 
53 #include <cstddef>
54 #include <list>
55 #include <string>
56 #include <tuple>
57 #include <vector>
58 
59 struct binfo;
60 struct integer_cst;
61 struct function_decl;
62 struct ssa_name;
63 struct statement_list;
64 template <typename value>
74 
79 {
80  private:
82  static const std::set<std::string> SC_tmpl_class;
83 
85  static const std::set<std::string> SC_builtin_scalar_type;
86 
88  static const std::set<std::string> TLM_SC_builtin_scalar_type;
89 
98  static void RecursiveGetTypesToBeDeclared(std::set<tree_nodeConstRef, TreeNodeConstSorter>& returned_types,
99  const tree_nodeConstRef& type, const bool recursion,
100  const bool without_transformation, const bool before);
101 
107  static void ComputeSsaUses(const tree_nodeRef&, TreeNodeMap<size_t>& uses);
108 
109  public:
111  static int debug_level;
112 
118  static unsigned long long Size(const tree_nodeConstRef& tn);
119 
125  static std::string GetTemplateTypeName(const tree_nodeConstRef& type);
126 
132  static std::string GetRecordTypeName(const tree_nodeConstRef& type);
133 
139  static
141  std::string
142  name_function(const tree_managerConstRef& tm, const unsigned int index);
143 
150  static
152  std::string
154 
161  static std::tuple<std::string, unsigned int, unsigned int> GetSourcePath(const tree_nodeConstRef& node,
162  bool& is_system);
163 
168  static
170  bool
171  has_function_return(const tree_managerConstRef& tm, const unsigned int index);
172 
178  static bool HasReturnType(const tree_managerConstRef& tm, const unsigned int index);
179 
184  static std::string getFunctionTypeString(const tree_nodeRef& FT);
185 
192  static void get_used_variables(bool first_level_only, const tree_nodeConstRef& t,
193  CustomUnorderedSet<unsigned int>& list_of_variable);
194 
201  static bool look_for_binfo_inheritance(const binfo* b, const std::string& bcs);
202 
209 
216  static std::set<tree_nodeConstRef, TreeNodeConstSorter>
217  GetTypesToBeDeclaredBefore(const tree_nodeConstRef& tn, const bool without_transformation);
218 
225  static std::set<tree_nodeConstRef, TreeNodeConstSorter> GetTypesToBeDeclaredAfter(const tree_nodeConstRef& tn,
226  const bool without_transformation);
227 
236  static
238  unsigned int
239  get_type_index(const tree_managerConstRef& TM, const unsigned int index, long long int& vec_size,
240  bool& is_a_pointer, bool& is_a_function);
241 
247  static
249  unsigned int
250  get_type_index(const tree_managerConstRef& TM, const unsigned int index);
251 
258  static tree_nodeConstRef GetFunctionReturnType(const tree_nodeConstRef& function, bool void_as_null = true);
259 
265  static
267  unsigned int
268  get_pointed_type(const tree_managerConstRef& TM, const unsigned int index);
269 
274  static tree_nodeConstRef CGetPointedType(const tree_nodeConstRef& pointer);
275 
282  static
284  unsigned int
285  GetElements(const tree_managerConstRef& TM, const unsigned int index);
286 
293 
300  static bool IsSameType(const tree_nodeConstRef& tn0, const tree_nodeConstRef& tn1);
301 
308  static
310  std::string
311  get_type_name(const tree_managerConstRef& TM, const unsigned int index);
312 
318  static std::string GetTypeName(const tree_nodeConstRef& type);
319 
326  static
328  void
329  get_parameter_types(const tree_managerConstRef& TM, const unsigned int index, std::list<unsigned int>& params);
330 
336  static std::vector<tree_nodeConstRef> GetParameterTypes(const tree_nodeConstRef& ftype);
337 
342  static std::vector<tree_nodeConstRef> CGetFieldTypes(const tree_nodeConstRef& type);
343 
350  static
352  unsigned int
353  get_field_idx(const tree_managerConstRef& TM, const unsigned int index, unsigned int idx);
354 
361  static tree_nodeRef GetFieldIdx(const tree_nodeConstRef& type, unsigned int idx);
362 
367  static tree_nodeConstRef CGetType(const tree_nodeConstRef& node);
368 
375  static
377  bool
378  is_system(const tree_managerConstRef& TM, const unsigned int index);
379 
385  static bool IsSystemType(const tree_nodeConstRef& type);
386 
392  static
394  bool
395  IsInLibbambu(const tree_managerConstRef& TM, const unsigned int index);
396 
402  static bool IsInLibbambu(const tree_nodeConstRef& type);
403 
409  static
411  bool
412  is_an_enum(const tree_managerConstRef& TM, const unsigned int index);
413 
419  static bool IsEnumType(const tree_nodeConstRef& type);
420 
426  static
428  bool
429  is_a_struct(const tree_managerConstRef& TM, const unsigned int index);
430 
436  static bool IsStructType(const tree_nodeConstRef& type);
437 
444  static
446  bool
447  is_an_union(const tree_managerConstRef& TM, const unsigned int index);
448 
454  static bool IsUnionType(const tree_nodeConstRef& type);
455 
462  static
464  bool
465  is_a_complex(const tree_managerConstRef& TM, const unsigned int index);
466 
472  static bool IsComplexType(const tree_nodeConstRef& type);
473 
480  static
482  bool
483  is_an_array(const tree_managerConstRef& TM, const unsigned int index);
484 
491  static bool IsArrayEquivType(const tree_nodeConstRef& type);
492 
499  static bool IsArrayType(const tree_nodeConstRef& type);
500 
506 
512  static
514  bool
515  is_a_pointer(const tree_managerConstRef& TM, const unsigned int index);
516 
522  static bool IsPointerType(const tree_nodeConstRef& type);
523 
529  static
531  bool
532  is_a_function(const tree_managerConstRef& TM, const unsigned int index);
533 
539  static bool IsFunctionDeclaration(const tree_nodeConstRef& type);
540 
546  static
548  bool
549  is_a_vector(const tree_managerConstRef& TM, const unsigned int index);
550 
556  static bool IsVectorType(const tree_nodeConstRef& type);
557 
563  static bool is_a_misaligned_vector(const tree_managerConstRef& TM, const unsigned int index);
564 
571  static bool is_an_addr_expr(const tree_managerConstRef& TM, const unsigned int index);
572 
578  static bool HasToBeDeclared(const tree_managerConstRef& TM, const tree_nodeConstRef& type);
579 
586  static
588  bool
589  is_const_type(const tree_managerConstRef& TM, const unsigned int index);
590 
596  static bool IsConstType(const tree_nodeConstRef& type);
597 
603  static
605  bool
606  is_bool(const tree_managerConstRef& TM, const unsigned int index);
607 
613  static bool IsBooleanType(const tree_nodeConstRef& type);
614 
620  static
622  bool
623  is_a_void(const tree_managerConstRef& TM, const unsigned int index);
624 
630  static bool IsVoidType(const tree_nodeConstRef& type);
631 
637  static
639  bool
640  is_natural(const tree_managerConstRef& TM, const unsigned int index);
641 
647  static bool IsPositiveIntegerValue(const tree_nodeConstRef& type);
648 
654  static
656  bool
657  is_int(const tree_managerConstRef& TM, const unsigned int index);
658 
664  static bool IsSignedIntegerType(const tree_nodeConstRef& type);
665 
672  static
674  bool
675  is_real(const tree_managerConstRef& TM, const unsigned int index);
676 
682  static bool IsRealType(const tree_nodeConstRef& type);
683 
689  static
691  bool
692  is_unsigned(const tree_managerConstRef& TM, const unsigned int index);
693 
699  static bool IsUnsignedIntegerType(const tree_nodeConstRef& type);
700 
706  static
708  bool
709  is_scalar(const tree_managerConstRef& TM, const unsigned int var);
710 
716  static bool IsScalarType(const tree_nodeConstRef& type);
717 
718  static
720  bool
721  is_a_variable(const tree_managerConstRef& TM, const unsigned int index);
722 
728  static bool IsVariableType(const tree_nodeConstRef& node);
729 
730  static
732  bool
733  is_static(const tree_managerConstRef& TM, const unsigned int index);
734 
735  static bool IsStaticDeclaration(const tree_nodeConstRef& decl);
736 
737  static
739  bool
740  is_extern(const tree_managerConstRef& TM, const unsigned int index);
741 
742  static bool IsExternDeclaration(const tree_nodeConstRef& decl);
743 
749  static
751  bool
752  is_function_type(const tree_managerConstRef& TM, const unsigned int index);
753 
759  static bool IsFunctionType(const tree_nodeConstRef& type);
760 
766  static
768  bool
769  is_function_pointer_type(const tree_managerConstRef& TM, const unsigned int index);
770 
776  static bool IsFunctionPointerType(const tree_nodeConstRef& type);
777 
783  static
785  unsigned int
786  get_base_index(const tree_managerConstRef& TM, const unsigned int index);
787 
794 
795  static
797  bool
798  is_fully_resolved(const tree_managerConstRef& TM, const unsigned int index,
800 
801  static bool IsPointerResolved(const tree_nodeConstRef& ptr, CustomOrderedSet<unsigned int>& res_set);
802 
807  static std::string return_qualifier_prefix(const TreeVocabularyTokenTypes_TokenEnum quals);
808 
814  static std::string return_C_qualifiers(const TreeVocabularyTokenTypes_TokenEnum quals, bool real_const);
815 
826  static bool is_module(const tree_managerConstRef& TM, unsigned int index);
827 
834  static bool is_channel(const tree_managerConstRef& TM, const unsigned int index);
835 
842  static bool is_builtin_channel(const tree_managerConstRef& TM, const unsigned int index);
843 
850  static bool is_signal(const tree_managerConstRef& TM, const unsigned int index);
851 
858  static bool is_port(const tree_managerConstRef& TM, const unsigned int index);
859 
866  static bool is_in_port(const tree_managerConstRef& TM, const unsigned int index);
867 
874  static bool is_out_port(const tree_managerConstRef& TM, const unsigned int index);
875 
882  static bool is_inout_port(const tree_managerConstRef& TM, const unsigned int index);
883 
890  static bool is_event(const tree_managerConstRef& TM, const unsigned int index);
891 
898  static bool is_clock(const tree_managerConstRef& TM, const unsigned int index);
899 
906  static bool is_SC_BIND_PROXY_NIL(const tree_managerConstRef& TM, const unsigned int index);
907 
909 
916  static bool is_ssa_name(const tree_managerConstRef& TM, const unsigned int index);
917 
924  static
926  bool
927  is_volatile(const tree_managerConstRef& TM, const unsigned int index);
928 
934  static bool IsVolatile(const tree_nodeConstRef& tn);
935 
942  static bool is_parameter(const tree_managerConstRef& TM, const unsigned int index);
943 
950  static bool is_virtual(const tree_managerConstRef& TM, const unsigned int index);
951 
956  static
960 
967  static integer_cst_t GetConstValue(const tree_nodeConstRef& tn, bool is_signed = true);
968 
976  static unsigned int get_array_var(const tree_managerConstRef& TM, const unsigned int index, bool is_written,
977  bool& two_dim_p);
978 
984  static
986  unsigned long long
987  get_array_data_bitsize(const tree_managerConstRef& TM, const unsigned int index);
988 
994  static unsigned long long GetArrayElementSize(const tree_nodeConstRef& node);
995 
1002  static
1004  void
1005  get_array_dimensions(const tree_managerConstRef& TM, const unsigned int index,
1006  std::vector<unsigned long long>& dims);
1007 
1013  static std::vector<unsigned long long> GetArrayDimensions(const tree_nodeConstRef& node);
1014 
1022  static
1024  void
1025  get_array_dim_and_bitsize(const tree_managerConstRef& TM, const unsigned int index,
1026  std::vector<unsigned long long>& dims, unsigned long long& elts_bitsize);
1027 
1033  static
1035  unsigned long long
1036  get_array_num_elements(const tree_managerConstRef& TM, const unsigned int index);
1037 
1043  static unsigned long long GetArrayTotalSize(const tree_nodeConstRef& node);
1044 
1053  static void extract_array_indexes(const tree_managerConstRef& TM, const unsigned int index,
1054  std::vector<unsigned long long>& indexes,
1055  std::vector<unsigned long long>& size_indexes, unsigned int& base_object);
1056 
1063  static bool is_concat_bit_ior_expr(const tree_managerConstRef& TM, const unsigned int index);
1064 
1071  static bool is_simple_pointer_plus_test(const tree_managerConstRef& TM, const unsigned int index);
1072 
1079  static
1081  bool
1082  is_constant(const tree_managerConstRef& TM, const unsigned int index);
1083 
1089  static bool IsConstant(const tree_nodeConstRef& node);
1090 
1096  static std::string op_symbol(const tree_nodeConstRef& op);
1097 
1103  static std::string op_symbol(const tree_node* op);
1104 
1111  static
1113  unsigned int
1114  GetUnqualified(const tree_managerConstRef& TM, unsigned int type);
1115 
1122 
1129  static
1131  unsigned int
1132  GetRealType(const tree_managerConstRef& TM, unsigned int index);
1133 
1140 
1144  static bool IsAligned(const tree_managerConstRef& TM, unsigned int type);
1145 
1146  static bool IsAligned(const tree_nodeConstRef& tn);
1147 
1154  static unsigned int get_var_alignment(const tree_managerConstRef& TM, unsigned int var);
1155 
1160  static std::string NormalizeTypename(const std::string& id);
1161 
1167  static std::string GetMangledFunctionName(const function_decl* fd);
1168 
1173  static std::string print_function_name(const tree_managerConstRef& TM, const function_decl* fd);
1174 
1186  static
1188  std::string
1189  print_type(const tree_managerConstRef& TM, unsigned int type, bool global = false, bool print_qualifiers = false,
1190  bool print_storage = false, unsigned int var = 0,
1191  const var_pp_functorConstRef& vppf = var_pp_functorConstRef(), const std::string& prefix = "",
1192  const std::string& tail = "");
1193 
1205  static std::string PrintType(const tree_managerConstRef& TM, const tree_nodeConstRef& type, bool global = false,
1206  bool print_qualifiers = false, bool print_storage = false,
1207  const tree_nodeConstRef& var = nullptr,
1209  const std::string& prefix = "", const std::string& tail = "");
1210 
1214  static
1216  unsigned int
1217  get_formal_ith(const tree_managerConstRef& TM, unsigned int index_obj, unsigned int parm_index);
1218 
1226  static tree_nodeConstRef GetFormalIth(const tree_nodeConstRef& obj, unsigned int parm_index);
1227 
1228  static
1230  bool
1231  is_packed(const tree_managerConstRef& TreeM, unsigned int node_index);
1232 
1233  static bool IsPackedType(const tree_nodeConstRef& type);
1234 
1241  static bool is_packed_access(const tree_managerConstRef& TreeM, unsigned int node_index);
1242 
1246  static unsigned long long AccessedMaximumBitsize(const tree_nodeConstRef& type_node, unsigned long long bitsize);
1247 
1251  static unsigned long long AccessedMinimunBitsize(const tree_nodeConstRef& type_node, unsigned long long bitsize);
1252 
1257  static size_t AllocatedMemorySize(const tree_nodeConstRef& parameter);
1258 
1264  static size_t CountPointers(const tree_nodeConstRef&);
1265 
1273  static unsigned int get_multi_way_if_pos(const tree_managerConstRef& TM, unsigned int node_id, unsigned int cond);
1274 
1281 
1288 
1289  static bool is_a_nop_function_decl(const function_decl* fd);
1290 
1291  static void get_required_values(std::vector<std::tuple<unsigned int, unsigned int>>& required,
1292  const tree_nodeRef& tn);
1293 
1299  static bool LastStatement(const tree_nodeConstRef& statement);
1300 
1307  static size_t GetFunctionSize(const tree_managerConstRef& TM, const unsigned int function_index);
1308 
1315  static std::string get_asm_string(const tree_managerConstRef& TM, const unsigned int node_index);
1316 
1323  static bool IsStore(const tree_nodeConstRef& tn, const CustomOrderedSet<unsigned int>& fun_mem_data);
1324 
1331  static bool IsLoad(const tree_nodeConstRef& tn, const CustomOrderedSet<unsigned int>& fun_mem_data);
1332 
1339  static bool IsLut(const tree_nodeConstRef& tn);
1340 
1347  static bool has_omp_simd(const statement_list* sl);
1348 
1350  tree_helper();
1351 
1353  ~tree_helper();
1354 };
1355 
1358 {
1359  private:
1362 
1365 
1368 
1371 
1374 
1375  public:
1380  {
1382  internal,
1383  total
1384  };
1385 
1391  serialization get_serialization(const std::string& name) const;
1392 
1398  bool is_transparent(const std::string& name) const;
1399 
1405  void check_lib_type(const tree_nodeRef& var);
1406 
1412  bool virtual operator()(const tree_nodeRef& t) const;
1413 
1415  FunctionExpander();
1416 
1418  virtual ~FunctionExpander() = default;
1419 };
1421 #endif
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.
Definition: tree_node.hpp:3242
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 ...
Definition: tree_helper.hpp:88
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...
Definition: tree_helper.hpp:78
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.
Definition: tree_node.hpp:4662
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.
Definition: tree_node.hpp:2759
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 ...
Definition: tree_helper.hpp:82
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.
Definition: tree_node.hpp:1713
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.
Definition: tree_node.hpp:139
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.
No serialization.
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)
#define index(x, y)
Definition: Keccak.c:74
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 &parameter)
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.
Definition: APInt.hpp:53
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.
Definition: tree_node.hpp:1318
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&#39;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.
Definition: tree_node.hpp:4523
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 > &params)
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.
Definition: tree_helper.hpp:65
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...
Definition: tree_helper.hpp:85
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.
int sl
Definition: adpcm.c:105
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.

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