93 "sc_inout",
"sc_port",
"sc_export"};
96 "sc_int",
"sc_uint",
"sc_biguint",
"sc_bigint",
"sc_lv",
"sc_in_rv",
97 "sc_out_rv",
"sc_inout_rv",
"sc_bv",
"sc_signal_rv"};
101 "tlm_blocking_put_if",
"tlm_blocking_get_if",
"tlm_nonblocking_get_if",
"tlm_nonblocking_put_if",
115 while(bitstring.size() > 1)
117 if(bitstring_is_signed)
119 if(bitstring.at(0) !=
'U' and (bitstring.at(0) == bitstring.at(1)))
121 bitstring = bitstring.substr(1);
130 if((bitstring.at(0) ==
'X' && bitstring.at(1) ==
'X') || (bitstring.at(0) ==
'0' && bitstring.at(1) !=
'X'))
132 bitstring = bitstring.substr(1);
134 else if(bitstring.at(0) ==
'0' && bitstring.at(1) ==
'X')
136 bitstring = bitstring.substr(1);
137 bitstring = bitstring.substr(1);
138 bitstring =
'0' + bitstring;
146 while(bitstring.at(0) ==
'X' && bitstring.size() > 1)
148 bitstring = bitstring.substr(1);
157 "---Getting size of " + t->get_kind_text() +
" " +
STR(t->index) +
": " + t->ToString());
158 switch(t->get_kind())
162 const auto sa = GetPointerS<const ssa_name>(t);
163 if(!sa->bit_values.empty())
167 return Size(sa->type);
171 return bv_test.size();
173 return sa->var ?
Size(sa->var) :
Size(sa->type);
177 return static_cast<unsigned long long>(
GetConstValue(GetPointerS<const pointer_type>(t)->size));
179 case reference_type_K:
181 return static_cast<unsigned long long>(
GetConstValue(GetPointerS<const reference_type>(t)->size));
185 const auto at = GetPointerS<const array_type>(t);
188 const auto ic = GetPointer<const integer_cst>(
GET_CONST_NODE(at->size));
191 return static_cast<unsigned long long>(
GetConstValue(at->size));
212 case enumeral_type_K:
214 const auto et = GetPointerS<const enumeral_type>(t);
216 if(et->min && et->max && GET_CONST_NODE(et->min)->get_kind() == integer_cst_K &&
221 if(et->unsigned_flag)
223 return max.minBitwidth(
false);
232 if(!GetPointerS<const type_node>(t)->size)
239 return static_cast<unsigned long long>(retval);
245 case type_pack_expansion_K:
246 case type_argument_pack_K:
249 case function_type_K:
254 if(!GetPointerS<const type_node>(t)->size)
258 return static_cast<unsigned long long>(
GetConstValue(GetPointerS<const type_node>(t)->size));
262 const auto it = GetPointerS<const integer_type>(t);
263 const auto prec = it->prec;
264 const auto algn = it->algn;
265 if(prec != algn && prec % algn)
271 return static_cast<unsigned long long>(
GetConstValue(it->size));
283 return static_cast<unsigned long long>(retval);
291 case aggr_init_expr_K:
301 case target_mem_ref461_K:
306 case function_decl_K:
310 case array_range_ref_K:
313 case case_label_expr_K:
315 case identifier_node_K:
318 case namespace_decl_K:
320 case qual_union_type_K:
322 case statement_list_K:
324 case target_mem_ref_K:
325 case template_type_parm_K:
326 case translation_unit_decl_K:
327 case template_decl_K:
332 case typename_type_K:
336 case gimple_assign_K:
342 case gimple_multi_way_if_K:
345 case gimple_pragma_K:
346 case gimple_predict_K:
348 case gimple_return_K:
349 case gimple_switch_K:
366 if(type->
get_kind() == tree_reindex_K)
370 if(type->
get_kind() == record_type_K)
372 const auto rect = GetPointer<const record_type>(
type);
375 for(
auto& list_of_fld :
rect->list_of_flds)
377 if(
GET_NODE(list_of_fld)->get_kind() == type_decl_K)
379 const auto td = GetPointer<const type_decl>(
GET_CONST_NODE(list_of_fld));
380 if(
GET_NODE(td->name)->get_kind() == identifier_node_K)
382 const auto idn = GetPointer<const identifier_node>(
GET_CONST_NODE(td->name));
394 if(type->
get_kind() == tree_reindex_K)
398 if(type->
get_kind() == record_type_K)
400 const auto rect = GetPointer<const record_type>(
type);
406 if(
GET_NODE(td->name)->get_kind() == identifier_node_K)
408 const auto idn = GetPointer<const identifier_node>(
GET_CONST_NODE(td->name));
425 if(decl->
get_kind() == tree_reindex_K)
429 if(decl->
get_kind() == function_decl_K)
431 const auto fd = GetPointerS<const function_decl>(decl);
434 else if(decl->
get_kind() == addr_expr_K)
483 if(name->
get_kind() == identifier_node_K)
485 const auto in = GetPointer<const identifier_node>(name);
486 if(in->operator_flag)
544 res =
"__internal_" + res;
554 std::string include_name;
555 unsigned int line_number = 0;
556 unsigned int column_number = 0;
557 if(GetPointer<const type_node>(node))
559 const auto tn = GetPointerS<const type_node>(node);
560 if(tn->name && GetPointer<const decl_node>(
GET_CONST_NODE(tn->name)))
566 if(GetPointer<const union_type>(node))
568 const auto& list_of_flds = GetPointerS<const union_type>(node)->list_of_flds;
569 if(!list_of_flds.empty())
572 if(GetPointer<const decl_node>(field))
574 const auto dn = GetPointerS<const decl_node>(field);
575 include_name = dn->include_name;
576 line_number = dn->line_number;
577 column_number = dn->column_number;
578 is_system = dn->operating_system_flag or dn->library_system_flag;
582 if(GetPointer<const record_type>(node))
584 const auto& list_of_flds = GetPointerS<const record_type>(node)->list_of_flds;
585 if(!list_of_flds.empty())
588 if(GetPointer<const decl_node>(field))
590 const auto dn = GetPointerS<const decl_node>(field);
591 include_name = dn->include_name;
592 line_number = dn->line_number;
593 column_number = dn->column_number;
594 is_system = dn->operating_system_flag or dn->library_system_flag;
600 if(GetPointer<const decl_node>(node))
602 const auto dn = GetPointerS<const decl_node>(node);
603 include_name = dn->include_name;
604 line_number = dn->line_number;
605 column_number = dn->column_number;
606 is_system = dn->operating_system_flag or dn->library_system_flag;
608 if(include_name !=
"<built-in>")
611 const auto canon_path = std::filesystem::weakly_canonical(include_name, ec);
614 include_name = canon_path.string();
617 return std::tuple<std::string, unsigned int, unsigned int>(include_name, line_number, column_number);
629 switch(t->get_kind())
633 const auto rd = GetPointer<const result_decl>(t);
643 const auto vd = GetPointer<const var_decl>(t);
653 const auto sn = GetPointer<const ssa_name>(t);
658 const auto vd = GetPointer<const var_decl>(
GET_CONST_NODE(sn->var));
669 case function_decl_K:
671 const auto fd = GetPointer<const function_decl>(t);
672 bool expand_p = !first_level_only;
673 auto vend = fd->list_of_args.end();
675 if(fd->body && expand_p)
677 for(
auto i = fd->list_of_args.begin(); i != vend; ++i)
686 case statement_list_K:
688 const auto sl = GetPointer<const statement_list>(t);
689 auto end =
sl->list_of_stmt.end();
690 auto i =
sl->list_of_stmt.begin();
700 auto ib_end =
sl->list_of_bloc.end();
701 for(
auto ib =
sl->list_of_bloc.begin(); ib != ib_end; ++ib)
703 for(
const auto& stmt : ib->second->CGetStmtList())
713 const auto tv = GetPointer<const tree_vec>(t);
714 auto end = tv->list_of_op.end();
715 for(
auto i = tv->list_of_op.begin(); i != end; ++i)
723 const auto gc = GetPointer<const gimple_cond>(t);
727 case gimple_assign_K:
729 const auto me = GetPointer<const gimple_assign>(t);
738 case gimple_return_K:
740 const auto re = GetPointer<const gimple_return>(t);
749 const auto ue = GetPointer<const unary_expr>(t);
759 const auto be = GetPointer<const binary_expr>(t);
766 const auto tern = GetPointer<const ternary_expr>(t);
775 const auto qe = GetPointer<const quaternary_expr>(t);
784 const auto le = GetPointer<const lut_expr>(t);
817 case gimple_switch_K:
819 const auto s = GetPointer<const gimple_switch>(t);
823 case gimple_multi_way_if_K:
825 const auto gmwi = GetPointer<const gimple_multi_way_if>(t);
826 for(
const auto& cond : gmwi->list_of_cond)
844 case case_label_expr_K:
849 const auto co = GetPointer<const constructor>(t);
850 for(
const auto& i : co->list_of_idx_valu)
857 case aggr_init_expr_K:
859 const auto ce = GetPointer<const call_expr>(t);
860 for(
const auto&
arg : ce->args)
868 const auto ce = GetPointer<const gimple_call>(t);
869 for(
const auto&
arg : ce->args)
877 const auto ae = GetPointer<const gimple_asm>(t);
894 auto tl = GetPointer<const tree_list>(t);
895 std::list<const tree_list*> tl_list;
898 tl_list.push_back(tl);
899 tl = tl->chan ? GetPointer<const tree_list>(
GET_CONST_NODE(tl->chan)) :
nullptr;
901 for(
auto tl_current0 : tl_list)
903 if(tl_current0->purp)
907 if(tl_current0->valu)
916 const auto fe = GetPointer<const gimple_for>(t);
924 const auto we = GetPointer<const gimple_while>(t);
935 case gimple_pragma_K:
936 case gimple_predict_K:
938 case identifier_node_K:
939 case namespace_decl_K:
941 case target_mem_ref_K:
942 case target_mem_ref461_K:
943 case translation_unit_decl_K:
944 case template_decl_K:
953 THROW_ERROR(std::string(
"Node not yet supported ") + t->get_kind_text());
964 if(rt && rt->get_maybe_name() == bcs)
987 const auto otr = GetPointer<const obj_type_ref>(curr_tn);
989 THROW_ASSERT(otr->type && otr->op1 && otr->op2,
"obj_type_ref has missing fields");
993 const auto t_pt = GetPointer<const pointer_type>(
GET_CONST_NODE(otr->type));
1008 THROW_ERROR(std::string(
"not supported case for obj_type_ref(") +
STR(ind) + std::string(
")"));
1013 const auto rt = GetPointer<const record_type>(
type);
1017 rt = GetPointer<record_type>(
GET_NODE(pt->ptd));
1024 THROW_ERROR(std::string(
"not supported case for obj_type_ref(") +
STR(ind) + std::string(
")"));
1029 for(
auto& list_of_fnc : rt->list_of_fncs)
1031 const auto fd = GetPointer<const function_decl>(
GET_CONST_NODE(list_of_fnc));
1040 THROW_ERROR(std::string(
"not supported case for obj_type_ref(") +
STR(ind) + std::string(
")"));
1045 THROW_ERROR(std::string(
"not supported case for obj_type_ref(") +
STR(ind) + std::string(
")"));
1047 THROW_ERROR(std::string(
"obj_type_ref Function not found (") +
STR(ind) + std::string(
")"));
1060 if(GetPointer<const decl_node>(
type))
1062 return GetPointer<const decl_node>(
type)->operating_system_flag ||
1063 GetPointer<const decl_node>(
type)->library_system_flag;
1065 if(GetPointer<const type_node>(
type))
1067 return GetPointer<const type_node>(
type)->system_flag;
1081 if(GetPointer<const decl_node>(
type) && GetPointer<const decl_node>(
type)->libbambu_flag)
1085 if(GetPointer<const type_node>(
type) && GetPointer<const type_node>(
type)->libbambu_flag)
1092 std::set<tree_nodeConstRef, TreeNodeConstSorter>
1095 std::set<tree_nodeConstRef, TreeNodeConstSorter> rt;
1100 std::set<tree_nodeConstRef, TreeNodeConstSorter>
1103 std::set<tree_nodeConstRef, TreeNodeConstSorter> rt;
1110 const bool without_transformation,
const bool before)
1114 "-->Getting types to be declared " +
STR(before ?
"before " :
"after ") +
STR(
type));
1115 switch(
type->get_kind())
1117 case pointer_type_K:
1125 case reference_type_K:
1129 const auto rt = GetPointerS<const reference_type>(
type);
1139 const auto* tn = GetPointerS<const type_node>(
type);
1140 if(recursion && tn->name && GET_CONST_NODE(tn->name)->get_kind() == type_decl_K)
1143 "---Inserting " +
STR(_type) +
" in the types to be declared");
1144 returned_types.insert(_type);
1160 "---Inserting " +
STR(_type) +
" in the types to be declared");
1161 returned_types.insert(_type);
1166 const auto* rt = GetPointerS<const record_type>(
type);
1167 if(rt->unql && (GetPointerS<const record_type>(GET_CONST_NODE(rt->unql))->name || without_transformation))
1173 "---Inserting " +
STR(rt->unql) +
" in the types to be declared");
1174 returned_types.insert(rt->unql);
1181 for(
const auto& field_type : field_types)
1184 "-->Considering field type (" +
STR(field_type->index) +
") " +
STR(field_type));
1185 bool pointer_to_unnamed_structure = [&]() {
1191 if(GetPointer<const record_type>(pointed_type) &&
1192 GET_CONST_NODE(GetPointer<const record_type>(pointed_type)->name)->get_kind() != type_decl_K)
1196 if(GetPointer<const union_type>(pointed_type) &&
1197 GET_CONST_NODE(GetPointer<const union_type>(pointed_type)->name)->get_kind() != type_decl_K)
1207 if(!
IsPointerType(field_type) || !pointer_to_unnamed_structure)
1214 if(pointer_to_unnamed_structure)
1221 "<--Considered field type (" +
STR(field_type->index) +
") " +
STR(field_type));
1235 "---Inserting " +
STR(_type) +
" in the types to be declared");
1236 returned_types.insert(_type);
1241 const auto ut = GetPointerS<const union_type>(
type);
1242 if(ut->unql && (GetPointerS<const union_type>(GET_CONST_NODE(ut->unql))->name || without_transformation))
1248 "---Inserting " +
STR(ut->unql) +
" in the types to be declared");
1249 returned_types.insert(ut->unql);
1256 for(
const auto& field_type : field_types)
1259 "-->Considering field type (" +
STR(field_type->index) +
") " +
STR(field_type));
1260 const auto pointer_to_unnamed_structure = [&]() {
1266 if(GetPointer<const record_type>(pointed_type) &&
1267 GET_CONST_NODE(GetPointer<const record_type>(pointed_type)->name)->get_kind() != type_decl_K)
1271 if(GetPointer<const union_type>(pointed_type) &&
1272 GET_CONST_NODE(GetPointer<const union_type>(pointed_type)->name)->get_kind() != type_decl_K)
1282 if(!
IsPointerType(field_type) || !pointer_to_unnamed_structure)
1289 if(pointer_to_unnamed_structure)
1296 "<--Considered field type (" +
STR(field_type->index) +
") " +
STR(field_type));
1303 case enumeral_type_K:
1310 "---Inserting " +
STR(_type) +
" in the types to be declared");
1311 returned_types.insert(_type);
1316 const auto* et = GetPointerS<const enumeral_type>(
type);
1317 if(et->unql && GetPointerS<const enumeral_type>(GET_CONST_NODE(et->unql))->name)
1322 "---Inserting " +
STR(et->unql) +
" in the types to be declared");
1323 returned_types.insert(et->unql);
1329 case boolean_type_K:
1331 case nullptr_type_K:
1332 case type_pack_expansion_K:
1333 case complex_type_K:
1334 case integer_type_K:
1339 const auto* tn = GetPointerS<const type_node>(
type);
1340 if(tn->name && GET_CONST_NODE(tn->name)->get_kind() == type_decl_K)
1343 "---Inserting " +
STR(_type) +
" in the types to be declared");
1344 returned_types.insert(_type);
1354 case function_type_K:
1374 case aggr_init_expr_K:
1375 case case_label_expr_K:
1377 case identifier_node_K:
1380 case qual_union_type_K:
1383 case statement_list_K:
1385 case target_mem_ref_K:
1386 case target_mem_ref461_K:
1387 case template_type_parm_K:
1388 case type_argument_pack_K:
1391 case typename_type_K:
1411 STR(
"<--Got types to be declared ") + (before ?
"before" :
"after") +
" " +
STR(
type));
1423 return utype ? utype : _type;
1429 is_a_pointer =
false;
1430 is_a_function =
false;
1435 THROW_ASSERT(Type,
"expected a type index " +
STR(index) +
" " + T->ToString());
1437 const auto type_index = Type->index;
1438 if(Type->get_kind() == pointer_type_K)
1440 is_a_pointer =
true;
1442 else if(Type->get_kind() == reference_type_K)
1444 is_a_pointer =
true;
1446 else if(Type->get_kind() == array_type_K)
1448 const auto at = GetPointer<const array_type>(Type);
1451 is_a_pointer =
true;
1454 else if(T->get_kind() == function_decl_K)
1456 is_a_function =
true;
1465 switch(tn->get_kind())
1467 case function_decl_K:
1469 const auto fd = GetPointerS<const function_decl>(tn);
1474 case function_type_K:
1482 case boolean_type_K:
1484 case aggr_init_expr_K:
1485 case case_label_expr_K:
1487 case nullptr_type_K:
1488 case type_pack_expansion_K:
1489 case complex_type_K:
1492 case enumeral_type_K:
1494 case identifier_node_K:
1495 case integer_type_K:
1498 case namespace_decl_K:
1500 case pointer_type_K:
1502 case qual_union_type_K:
1505 case reference_type_K:
1509 case statement_list_K:
1511 case target_mem_ref_K:
1512 case target_mem_ref461_K:
1513 case template_type_parm_K:
1514 case type_argument_pack_K:
1515 case translation_unit_decl_K:
1516 case template_decl_K:
1521 case typename_type_K:
1542 if(fun_type->
get_kind() == function_type_K || fun_type->
get_kind() == method_type_K)
1544 const auto ft = GetPointerS<const function_type>(fun_type);
1545 THROW_ASSERT(ft,
"NodeId is not related to a valid function type");
1546 if(!void_as_null ||
GET_CONST_NODE(ft->retn)->get_kind() != void_type_K)
1562 switch(T->get_kind())
1564 case(pointer_type_K):
1566 const auto pt = GetPointer<const pointer_type>(T);
1569 case reference_type_K:
1571 const auto rt = GetPointer<const reference_type>(T);
1574 case(function_type_K):
1576 const auto ft = GetPointer<const function_type>(T);
1579 case(method_type_K):
1581 const auto mt = GetPointer<const method_type>(T);
1587 case boolean_type_K:
1589 case aggr_init_expr_K:
1590 case case_label_expr_K:
1592 case nullptr_type_K:
1593 case type_pack_expansion_K:
1594 case complex_type_K:
1597 case enumeral_type_K:
1599 case function_decl_K:
1600 case identifier_node_K:
1601 case integer_type_K:
1604 case namespace_decl_K:
1607 case qual_union_type_K:
1613 case statement_list_K:
1615 case target_mem_ref_K:
1616 case target_mem_ref461_K:
1617 case template_type_parm_K:
1618 case type_argument_pack_K:
1619 case translation_unit_decl_K:
1620 case template_decl_K:
1625 case typename_type_K:
1643 THROW_ASSERT(
false,
"Index " +
STR(index) +
" does not correspond to a pointer type");
1652 switch(pointer->get_kind())
1654 case pointer_type_K:
1656 const auto pt = GetPointerS<const pointer_type>(pointer);
1659 case reference_type_K:
1661 const auto pt = GetPointerS<const reference_type>(pointer);
1664 case function_type_K:
1666 const auto ft = GetPointerS<const function_type>(pointer);
1671 const auto mt = GetPointerS<const method_type>(pointer);
1677 case boolean_type_K:
1679 case aggr_init_expr_K:
1680 case case_label_expr_K:
1682 case nullptr_type_K:
1683 case type_pack_expansion_K:
1684 case complex_type_K:
1686 case enumeral_type_K:
1687 case identifier_node_K:
1688 case integer_type_K:
1691 case qual_union_type_K:
1696 case statement_list_K:
1698 case target_mem_ref_K:
1699 case target_mem_ref461_K:
1700 case template_type_parm_K:
1701 case type_argument_pack_K:
1704 case typename_type_K:
1722 THROW_UNREACHABLE(
STR(pointer) +
":" + pointer->get_kind_text() +
" does not correspond to a pointer type");
1736 const auto at = GetPointer<const array_type>(
type);
1741 const auto vt = GetPointer<const vector_type>(
type);
1753 unsigned int type_index =
type->index;
1754 THROW_ASSERT(GetPointer<const type_node>(
type),
"Node type not type_node");
1755 const auto tn = GetPointer<const type_node>(
type);
1761 name = GetPointer<const type_decl>(
GET_CONST_NODE(tn->name))->name;
1764 return "Internal_" +
STR(type_index);
1772 "Not an identifier node:" +
STR(index));
1773 const auto id = GetPointer<const identifier_node>(
GET_CONST_NODE(name));
1778 return "Internal_" +
STR(type_index);
1787 std::string(
"expected a type_decl got ") +
type->get_kind_text());
1789 switch(
type->get_kind())
1791 case pointer_type_K:
1795 case reference_type_K:
1801 const auto rect = GetPointerS<const record_type>(
type);
1810 const auto idn = GetPointerS<const identifier_node>(
GET_CONST_NODE(td->name));
1830 return "_unnamed_" +
STR(
type->index);
1836 else if(
rect->tmpl_args)
1839 THROW_ASSERT(rtv->lngt == 1 || nt ==
"sc_port",
"Expected just one element");
1844 THROW_ERROR(
"Unexpected template parameter pattern");
1850 const auto unt = GetPointerS<const union_type>(
type);
1856 const auto td = GetPointerS<const type_decl>(
GET_CONST_NODE(unt->name));
1859 const auto idn = GetPointerS<const identifier_node>(
GET_CONST_NODE(td->name));
1867 else if(
GET_CONST_NODE(unt->name)->get_kind() == identifier_node_K)
1869 const auto idn = GetPointerS<const identifier_node>(
GET_CONST_NODE(unt->name));
1870 nt =
"union " + idn->strg;
1879 return "_unnamed_" +
STR(
type->index);
1887 THROW_ERROR(
"Unexpected template parameter pattern");
1893 const auto at = GetPointerS<const array_type>(
type);
1894 std::string vec_size_string;
1898 const auto it = GetPointer<const integer_type>(domain);
1899 THROW_ASSERT(it,
"expected an integer type as array domain");
1902 const auto ic = GetPointer<const integer_cst>(
GET_CONST_NODE(it->max));
1906 vec_size_string =
"[" +
STR(vec_size) +
"]";
1910 vec_size_string =
"[]";
1916 case enumeral_type_K:
1918 const auto et = GetPointerS<const enumeral_type>(
type);
1923 const auto td = GetPointerS<const type_decl>(
GET_CONST_NODE(et->name));
1924 const auto in = GetPointerS<const identifier_node>(
GET_CONST_NODE(td->name));
1927 else if(
GET_CONST_NODE(et->name)->get_kind() == identifier_node_K)
1929 const auto in = GetPointerS<const identifier_node>(
GET_CONST_NODE(et->name));
1930 return "enum " + in->strg;
1933 return "enum Internal_" +
STR(
type->index);
1935 case boolean_type_K:
1936 case integer_type_K:
1938 case nullptr_type_K:
1939 case type_pack_expansion_K:
1941 case complex_type_K:
1945 const auto tnode = GetPointerS<const type_node>(
type);
1948 if(
type->get_kind() == integer_type_K)
1956 const auto tdecl = GetPointerS<const type_decl>(
GET_CONST_NODE(tnode->name));
1958 const auto idn = GetPointerS<const identifier_node>(
GET_CONST_NODE(tdecl->name));
1961 else if(
GET_CONST_NODE(tnode->name)->get_kind() == identifier_node_K)
1963 const auto idn = GetPointerS<const identifier_node>(
GET_CONST_NODE(tnode->name));
1973 case function_type_K:
1977 if(GetPointerS<const function_type>(
type)->prms)
1994 auto tl = GetPointerS<const tree_list>(
type);
2000 std::list<const tree_list*> tl_list;
2004 tl_list.push_back(tl);
2006 for(
const auto& valu : tl_list)
2012 case tree_reindex_K:
2019 case aggr_init_expr_K:
2020 case case_label_expr_K:
2022 case identifier_node_K:
2025 case qual_union_type_K:
2028 case statement_list_K:
2030 case target_mem_ref_K:
2031 case target_mem_ref461_K:
2032 case template_type_parm_K:
2033 case type_argument_pack_K:
2035 case typename_type_K:
2044 case placeholder_expr_K:
2058 std::list<unsigned int>&
params)
2061 std::transform(pv.begin(), pv.end(), std::back_inserter(params),
2067 std::vector<tree_nodeConstRef>
params;
2072 "Type " +
STR(Type) +
" from " +
STR(ftype) +
" does not correspond to a function type");
2077 params.push_back(tl->valu);
2081 params.push_back(tl->valu);
2091 return tn0_type->get_kind() == tn1_type->get_kind() &&
Size(tn0_type) ==
Size(tn1_type) &&
2092 (tn0_type->get_kind() != integer_type_K || GetPointerS<const integer_type>(tn0_type)->unsigned_flag ==
2093 GetPointerS<const integer_type>(tn1_type)->unsigned_flag) &&
2094 (tn0_type->get_kind() != enumeral_type_K || GetPointerS<const enumeral_type>(tn0_type)->unsigned_flag ==
2095 GetPointerS<const enumeral_type>(tn1_type)->unsigned_flag);
2102 long long int vec_size;
2103 return get_type_index(TM, index, vec_size, is_a_pointer, is_a_function);
2109 std::vector<tree_nodeConstRef> ret;
2110 if(
type->get_kind() == record_type_K)
2112 const auto rt = GetPointerS<const record_type>(
type);
2113 for(
const auto& list_of_fld : rt->list_of_flds)
2123 ret.push_back(
CGetType(list_of_fld));
2126 else if(
type->get_kind() == union_type_K)
2128 const auto ut = GetPointerS<const union_type>(
type);
2129 for(
const auto& list_of_fld : ut->list_of_flds)
2131 ret.push_back(
CGetType(list_of_fld));
2149 THROW_ASSERT(GetPointer<const record_type>(type) || GetPointer<const union_type>(type),
2150 "expected record or union type");
2151 const auto rt = GetPointer<const record_type>(
type);
2152 const auto ut = GetPointer<const union_type>(
type);
2155 THROW_ASSERT(idx < rt->list_of_flds.size(),
"unexpected index for list of fields");
2156 return rt->list_of_flds[idx];
2160 THROW_ASSERT(idx < ut->list_of_flds.size(),
"unexpected index for list of fields");
2161 return ut->list_of_flds[idx];
2170 switch(node->get_kind())
2173 case aggr_init_expr_K:
2175 const auto ce = GetPointerS<const call_expr>(node);
2180 case gimple_return_K:
2182 case gimple_switch_K:
2183 case gimple_label_K:
2188 case gimple_multi_way_if_K:
2189 case gimple_pragma_K:
2199 const auto en = GetPointerS<const expr_node>(node);
2200 THROW_ASSERT(en && en->type, std::string(
"this NODE does not have a type: ") + node->get_kind_text());
2205 const auto gp = GetPointerS<const gimple_phi>(node);
2208 case gimple_assign_K:
2210 const auto gm = GetPointerS<const gimple_assign>(node);
2215 const auto ic = GetPointerS<const integer_cst>(node);
2220 const auto rc = GetPointerS<const real_cst>(node);
2225 const auto sc = GetPointerS<const string_cst>(node);
2226 return sc->type ? sc->type : _node;
2230 const auto vc = GetPointerS<const vector_cst>(node);
2231 return vc->type ? vc->type : _node;
2235 const auto cc = GetPointerS<const complex_cst>(node);
2236 return cc->type ? cc->type : _node;
2240 const auto c = GetPointerS<const constructor>(node);
2252 const auto dn = GetPointerS<const decl_node>(node);
2257 const auto sa = GetPointerS<const ssa_name>(node);
2260 case target_mem_ref_K:
2262 const auto tm = GetPointerS<const target_mem_ref>(node);
2265 case target_mem_ref461_K:
2267 const auto tm = GetPointerS<const target_mem_ref461>(node);
2271 case gimple_while_K:
2273 const auto gw = GetPointerS<const gimple_while>(node);
2282 case case_label_expr_K:
2283 case gimple_predict_K:
2284 case identifier_node_K:
2285 case statement_list_K:
2357 if(already_visited.count(_type->index))
2361 already_visited.insert(_type->index);
2363 if(
type->get_kind() == record_type_K)
2365 const auto rt = GetPointerS<const record_type>(
type);
2366 for(
const auto& fld : rt->list_of_flds)
2380 else if(
type->get_kind() == union_type_K)
2382 const auto ut = GetPointerS<const union_type>(
type);
2383 for(
const auto& fld : ut->list_of_flds)
2389 else if(
type->get_kind() == array_type_K)
2391 const auto at = GetPointerS<const array_type>(
type);
2395 else if(
type->get_kind() == vector_type_K)
2397 const auto vt = GetPointerS<const vector_type>(
type);
2403 listOfTypes.push_back(_type);
2409 std::list<tree_nodeConstRef> listOfTypes;
2412 if(listOfTypes.empty())
2418 for(
const auto& fld : GetPointerS<const record_type>(
GET_CONST_NODE(t))->list_of_flds)
2420 if(GetPointerS<const field_decl>(
GET_CONST_NODE(fld))->is_bitfield())
2428 if(ceil_pow2(sizeFlds) != sizeFlds)
2432 for(
const auto& fldType : listOfTypes)
2472 std::list<tree_nodeConstRef> listOfTypes;
2477 THROW_ASSERT(!listOfTypes.empty(),
"at least one type is expected");
2478 return listOfTypes.front();
2500 const auto at = GetPointerS<const array_type>(
GET_CONST_NODE(Type));
2517 if(type->
get_kind() == tree_reindex_K)
2521 return type->
get_kind() == function_decl_K;
2551 const auto vt = GetPointer<const vector_type>(
GET_CONST_NODE(Type));
2553 return vt->algn !=
Size(Type);
2565 "Tree node " +
STR(
type) +
" is not a type_node but " +
type->get_kind_text());
2566 if(GetPointer<const type_node>(
type)->name)
2569 if(name->get_kind() == type_decl_K)
2571 const auto td = GetPointer<const type_decl>(name);
2572 if(td->include_name ==
"<built-in>")
2576 if(GetPointer<const complex_type>(
type))
2579 std::vector<std::string> splitted =
SplitString(name1,
" ");
2580 if(splitted.size() > 1 &&
2581 (splitted[0] ==
"_Complex" || splitted[0] ==
"__complex__" || splitted[0] ==
"complex"))
2589 return type->get_kind() == record_type_K ||
type->get_kind() == union_type_K ||
type->get_kind() == enumeral_type_K;
2616 const auto ptd =
GET_CONST_NODE(GetPointerS<const pointer_type>(Type)->ptd);
2640 return type_name ==
"sc_logic" || type_name ==
"sc_in_resolved" || type_name ==
"sc_inout_resolved" ||
2641 type_name ==
"sc_out_resolved" || type_name ==
"sc_in_clk" || type_name ==
"sc_inout_clk" ||
2642 type_name ==
"sc_out_clk" || type_name ==
"sc_bit" || type_name ==
"sc_clock";
2667 if(GetPointer<const ssa_name>(
type) && GetPointer<const ssa_name>(
type)->
min)
2669 const auto& minimum = GetPointer<const ssa_name>(
type)->
min;
2672 return min_value >= 0;
2689 return !GetPointerS<const enumeral_type>(
GET_CONST_NODE(Type))->unsigned_flag;
2693 return !GetPointerS<const integer_type>(
GET_CONST_NODE(Type))->unsigned_flag;
2696 return type_name ==
"sc_int";
2724 return GetPointerS<const enumeral_type>(
GET_CONST_NODE(Type))->unsigned_flag;
2728 return GetPointerS<const integer_type>(
GET_CONST_NODE(Type))->unsigned_flag;
2731 return type_name ==
"sc_uint" || type_name ==
"sc_lv" || type_name ==
"sc_in_rv" || type_name ==
"sc_out_rv" ||
2732 type_name ==
"sc_inout_rv" || type_name ==
"sc_bv" || type_name ==
"sc_signal_rv";
2747 THROW_ASSERT(index > 0,
"expected positive non zero numbers");
2748 const std::string mod_st =
"sc_module";
2749 const std::string mod_name_st =
"sc_module_name";
2750 const std::string ifc_st =
"sc_interface";
2751 const auto* rt = GetPointer<const record_type>(TM->
CGetTreeNode(index));
2754 const auto bi = GetPointer<const binfo>(
GET_CONST_NODE(rt->binf));
2768 return rec_name ==
"sc_fifo" || rec_name ==
"tlm_fifo" || rec_name ==
"sc_mutex" || rec_name ==
"sc_semaphore";
2773 THROW_ASSERT(index > 0,
"expected positive non zero numbers");
2774 const std::string mod_st =
"sc_module";
2775 const std::string ifc_st =
"sc_interface";
2776 const auto* rt = GetPointer<const record_type>(TM->
CGetTreeNode(index));
2779 const auto bi = GetPointer<const binfo>(
GET_CONST_NODE(rt->binf));
2797 rt->get_maybe_name().find(
"sc_signal<") == 0 ||
2798 rt->get_maybe_name().find(
"sc_signal_resolved") == 0 ||
2799 rt->get_maybe_name().find(
"sc_signal_rv<") == 0 ||
2800 rt->get_maybe_name().find(
"sc_buffer") == 0)
2804 THROW_ASSERT(index > 0,
"expected positive non zero numbers");
2805 const std::string ifc_st =
"sc_interface";
2806 const std::string pch_st =
"sc_prim_channel";
2807 const std::string sig_st =
"sc_signal";
2808 const std::string clock_st =
"sc_clock";
2809 const auto* rt = GetPointer<const record_type>(TM->
CGetTreeNode(index));
2812 const auto bi = GetPointer<const binfo>(
GET_CONST_NODE(rt->binf));
2815 rt->get_maybe_name() != clock_st)
2825 THROW_ASSERT(index > 0,
"expected positive non zero numbers");
2826 const std::string ifc_st =
"sc_interface";
2827 const std::string pch_st =
"sc_prim_channel";
2828 const std::string clock_st =
"sc_clock";
2829 const auto* rt = GetPointer<const record_type>(TM->
CGetTreeNode(index));
2832 const auto bi = GetPointer<const binfo>(
GET_CONST_NODE(rt->binf));
2834 rt->get_maybe_name() == clock_st))
2844 THROW_ASSERT(index > 0,
"expected positive non zero numbers");
2846 if(curr_tn->get_kind() == addr_expr_K)
2848 curr_tn =
GET_CONST_NODE(GetPointer<const addr_expr>(curr_tn)->op);
2850 if(curr_tn->get_kind() == var_decl_K)
2852 const auto vd = GetPointer<const var_decl>(curr_tn);
2853 if(vd->name &&
GET_CONST_NODE(vd->name)->get_kind() == identifier_node_K)
2855 const auto id = GetPointer<const identifier_node>(
GET_CONST_NODE(vd->name));
2856 std::string strg =
id->strg;
2857 return strg.find(
"SC_BIND_PROXY_NIL") != std::string::npos;
2864 rt->get_maybe_name().find(
"sc_in<") == 0 ||
2865 rt->get_maybe_name().find(
"sc_in_rv<") == 0 ||
2866 rt->get_maybe_name().find(
"sc_in_resolved") == 0 ||
2867 rt->get_maybe_name().find(
"sc_in_clk") == 0 ||
2868 rt->get_maybe_name().find(
"sc_out<") == 0 ||
2869 rt->get_maybe_name().find(
"sc_out_rv<") == 0 ||
2870 rt->get_maybe_name().find(
"sc_out_resolved") == 0 ||
2871 rt->get_maybe_name().find(
"sc_out_clk") == 0 ||
2872 rt->get_maybe_name().find(
"sc_inout<") == 0 ||
2873 rt->get_maybe_name().find(
"sc_inout_rv<") == 0 ||
2874 rt->get_maybe_name().find(
"sc_inout_resolved") == 0 ||
2875 rt->get_maybe_name().find(
"sc_inout_clk") == 0 ||
2876 rt->get_maybe_name().find(
"sc_fifo_in<") == 0 ||
2877 rt->get_maybe_name().find(
"sc_fifo_out<") == 0
2881 THROW_ASSERT(index > 0,
"expected positive non zero numbers");
2882 const std::string port_st =
"sc_port";
2883 const std::string sc_export_st =
"sc_export";
2884 const auto* rt = GetPointer<const record_type>(TM->
CGetTreeNode(index));
2887 const auto bi = GetPointer<const binfo>(
GET_CONST_NODE(rt->binf));
2898 THROW_ASSERT(index > 0,
"expected positive non zero numbers");
2899 const std::string sc_in_st =
"sc_in";
2900 const auto* rt = GetPointer<const record_type>(TM->
CGetTreeNode(index));
2903 const auto bi = GetPointer<const binfo>(
GET_CONST_NODE(rt->binf));
2914 THROW_ASSERT(index > 0,
"expected positive non zero numbers");
2915 const std::string sc_out_st =
2917 const auto* rt = GetPointer<const record_type>(TM->
CGetTreeNode(index));
2920 const auto bi = GetPointer<const binfo>(
GET_CONST_NODE(rt->binf));
2931 THROW_ASSERT(index > 0,
"expected positive non zero numbers");
2932 const std::string sc_inout_st =
"sc_inout";
2933 const auto* rt = GetPointer<const record_type>(TM->
CGetTreeNode(index));
2936 const auto bi = GetPointer<const binfo>(
GET_CONST_NODE(rt->binf));
2947 THROW_ASSERT(index > 0,
"expected positive non zero numbers");
2948 const std::string event_st =
"sc_event";
2949 const auto* rt = GetPointer<const record_type>(TM->
CGetTreeNode(index));
2952 const auto bi = GetPointer<const binfo>(
GET_CONST_NODE(rt->binf));
2978 case function_decl_K:
2984 case aggr_init_expr_K:
2989 case case_label_expr_K:
2993 case identifier_node_K:
2994 case namespace_decl_K:
2995 case statement_list_K:
2998 case target_mem_ref_K:
2999 case target_mem_ref461_K:
3000 case translation_unit_decl_K:
3001 case template_decl_K:
3029 case gimple_assign_K:
3031 const auto ga = GetPointerS<const gimple_assign>(
GET_CONST_NODE(node));
3032 if(ga->temporary_address)
3034 const auto ae = GetPointer<const addr_expr>(
GET_CONST_NODE(ga->op1));
3041 const auto ppe = GetPointer<const pointer_plus_expr>(
GET_CONST_NODE(ga->op1));
3048 const auto ne = GetPointer<const nop_expr>(
GET_CONST_NODE(ga->op1));
3055 const auto vce = GetPointer<const view_convert_expr>(
GET_CONST_NODE(ga->op1));
3068 else if(GetPointer<const pointer_plus_expr>(
GET_CONST_NODE(ga->op1)))
3070 const auto ppe = GetPointer<const pointer_plus_expr>(
GET_CONST_NODE(ga->op1));
3075 const auto ne = GetPointer<const nop_expr>(
GET_CONST_NODE(ga->op1));
3078 else if(GetPointer<const view_convert_expr>(
GET_CONST_NODE(ga->op1)))
3080 const auto vce = GetPointer<const view_convert_expr>(
GET_CONST_NODE(ga->op1));
3093 case target_mem_ref461_K:
3095 const auto tmr = GetPointer<const target_mem_ref461>(
GET_CONST_NODE(node));
3098 case component_ref_K:
3100 const auto cr = GetPointer<const component_ref>(
GET_CONST_NODE(node));
3103 case realpart_expr_K:
3105 const auto rpe = GetPointer<const realpart_expr>(
GET_CONST_NODE(node));
3108 case imagpart_expr_K:
3110 const auto rpe = GetPointer<const imagpart_expr>(
GET_CONST_NODE(node));
3113 case bit_field_ref_K:
3115 const auto bfr = GetPointer<const bit_field_ref>(
GET_CONST_NODE(node));
3118 case pointer_plus_expr_K:
3120 const auto ppe = GetPointer<const pointer_plus_expr>(
GET_CONST_NODE(node));
3123 case view_convert_expr_K:
3125 const auto vce = GetPointer<const view_convert_expr>(
GET_CONST_NODE(node));
3130 const auto ae = GetPointer<const addr_expr>(
GET_CONST_NODE(node));
3135 const auto ar = GetPointer<const array_ref>(
GET_CONST_NODE(node));
3146 case aggr_init_expr_K:
3147 case case_label_expr_K:
3149 case identifier_node_K:
3150 case statement_list_K:
3151 case target_mem_ref_K:
3155 case bit_and_expr_K:
3156 case bit_ior_expr_K:
3157 case bit_xor_expr_K:
3159 case ceil_div_expr_K:
3160 case ceil_mod_expr_K:
3161 case complex_expr_K:
3162 case compound_expr_K:
3163 case eh_filter_expr_K:
3165 case exact_div_expr_K:
3167 case floor_div_expr_K:
3168 case floor_mod_expr_K:
3171 case goto_subroutine_K:
3175 case lrotate_expr_K:
3183 case mult_highpart_expr_K:
3185 case ordered_expr_K:
3187 case postdecrement_expr_K:
3188 case postincrement_expr_K:
3189 case predecrement_expr_K:
3190 case preincrement_expr_K:
3193 case round_div_expr_K:
3194 case round_mod_expr_K:
3195 case rrotate_expr_K:
3198 case trunc_div_expr_K:
3199 case trunc_mod_expr_K:
3200 case truth_and_expr_K:
3201 case truth_andif_expr_K:
3202 case truth_or_expr_K:
3203 case truth_orif_expr_K:
3204 case truth_xor_expr_K:
3205 case try_catch_expr_K:
3213 case unordered_expr_K:
3214 case widen_sum_expr_K:
3215 case widen_mult_expr_K:
3216 case with_size_expr_K:
3217 case vec_lshift_expr_K:
3218 case vec_rshift_expr_K:
3219 case widen_mult_hi_expr_K:
3220 case widen_mult_lo_expr_K:
3221 case vec_pack_trunc_expr_K:
3222 case vec_pack_sat_expr_K:
3223 case vec_pack_fix_trunc_expr_K:
3224 case vec_extracteven_expr_K:
3225 case vec_extractodd_expr_K:
3226 case vec_interleavehigh_expr_K:
3227 case vec_interleavelow_expr_K:
3228 case extract_bit_expr_K:
3233 case function_decl_K:
3235 case namespace_decl_K:
3237 case translation_unit_decl_K:
3238 case template_decl_K:
3248 case gimple_label_K:
3249 case gimple_multi_way_if_K:
3252 case gimple_pragma_K:
3253 case gimple_predict_K:
3255 case gimple_return_K:
3256 case gimple_switch_K:
3257 case gimple_while_K:
3260 case with_cleanup_expr_K:
3261 case obj_type_ref_K:
3264 case vec_cond_expr_K:
3265 case vec_perm_expr_K:
3266 case dot_prod_expr_K:
3267 case ternary_plus_expr_K:
3268 case ternary_pm_expr_K:
3269 case ternary_mp_expr_K:
3270 case ternary_mm_expr_K:
3273 case bit_ior_concat_expr_K:
3275 case alignof_expr_K:
3277 case bit_not_expr_K:
3280 case cleanup_point_expr_K:
3282 case convert_expr_K:
3284 case fix_ceil_expr_K:
3285 case fix_floor_expr_K:
3286 case fix_round_expr_K:
3287 case fix_trunc_expr_K:
3289 case indirect_ref_K:
3290 case misaligned_indirect_ref_K:
3294 case non_lvalue_expr_K:
3296 case reference_expr_K:
3297 case reinterpret_cast_expr_K:
3299 case static_cast_expr_K:
3301 case truth_not_expr_K:
3304 case reduc_max_expr_K:
3305 case reduc_min_expr_K:
3306 case reduc_plus_expr_K:
3307 case vec_unpack_hi_expr_K:
3308 case vec_unpack_lo_expr_K:
3309 case vec_unpack_float_hi_expr_K:
3310 case vec_unpack_float_lo_expr_K:
3312 case array_range_ref_K:
3316 case sat_plus_expr_K:
3317 case sat_minus_expr_K:
3318 case extractvalue_expr_K:
3319 case insertvalue_expr_K:
3320 case extractelement_expr_K:
3321 case insertelement_expr_K:
3342 THROW_ASSERT(_node && _node->
get_kind() == tree_reindex_K,
"expected valid tree node reindex");
3344 switch(node->get_kind())
3348 const auto sn = GetPointerS<const ssa_name>(node);
3349 if(sn->use_set->is_a_singleton())
3351 if(
GET_CONST_NODE(sn->use_set->variables.front())->get_kind() == function_decl_K)
3353 return sn->use_set->variables.front();
3390 case indirect_ref_K:
3392 const auto ir = GetPointerS<const indirect_ref>(node);
3395 case misaligned_indirect_ref_K:
3397 const auto mir = GetPointerS<const misaligned_indirect_ref>(node);
3402 const auto mr = GetPointerS<const mem_ref>(node);
3407 const auto ar = GetPointerS<const array_ref>(node);
3410 case component_ref_K:
3412 const auto cr = GetPointerS<const component_ref>(node);
3415 case realpart_expr_K:
3417 const auto rpe = GetPointerS<const realpart_expr>(node);
3420 case imagpart_expr_K:
3422 const auto rpe = GetPointerS<const imagpart_expr>(node);
3425 case bit_field_ref_K:
3427 const auto bfr = GetPointerS<const bit_field_ref>(node);
3430 case target_mem_ref_K:
3432 const auto tmr = GetPointerS<const target_mem_ref>(node);
3448 "tree_helper::GetBaseVariable::target_mem_ref_K - variable type pattern not supported: " +
3453 case target_mem_ref461_K:
3455 const auto tmr = GetPointerS<const target_mem_ref461>(node);
3472 "tree_helper::GetBaseVariable::target_mem_ref461_K - variable type pattern not supported: " +
3479 const auto ae = GetPointerS<const addr_expr>(node);
3482 switch(addr_expr_op->get_kind())
3494 const auto ar = GetPointerS<const array_ref>(addr_expr_op);
3509 case aggr_init_expr_K:
3510 case case_label_expr_K:
3515 case function_decl_K:
3516 case identifier_node_K:
3519 case namespace_decl_K:
3522 case statement_list_K:
3524 case target_mem_ref_K:
3525 case target_mem_ref461_K:
3526 case translation_unit_decl_K:
3527 case template_decl_K:
3546 THROW_ERROR(
"addr_expr-array_ref[0] pattern not supported: " +
3547 std::string(addr_expr_op->get_kind_text()) +
" @" +
STR(node));
3556 case array_range_ref_K:
3560 case aggr_init_expr_K:
3561 case case_label_expr_K:
3566 case function_decl_K:
3567 case identifier_node_K:
3570 case namespace_decl_K:
3572 case statement_list_K:
3574 case target_mem_ref_K:
3575 case target_mem_ref461_K:
3576 case translation_unit_decl_K:
3577 case template_decl_K:
3595 THROW_ERROR(
"addr_expr pattern not supported: " + std::string(addr_expr_op->get_kind_text()) +
" @" +
3600 case view_convert_expr_K:
3602 const auto vc = GetPointerS<const view_convert_expr>(node);
3605 switch(vc_expr_op->get_kind())
3609 const auto sn = GetPointerS<const ssa_name>(
GET_CONST_NODE(vc->op));
3614 const auto pd = GetPointer<const parm_decl>(
GET_CONST_NODE(sn->var));
3621 THROW_ERROR(
"view_convert_expr pattern currently not supported: " +
3622 GET_NODE(vc->op)->get_kind_text() +
" @" +
STR(node));
3642 case aggr_init_expr_K:
3643 case case_label_expr_K:
3647 case function_decl_K:
3648 case identifier_node_K:
3650 case namespace_decl_K:
3653 case statement_list_K:
3655 case translation_unit_decl_K:
3656 case template_decl_K:
3658 case target_mem_ref_K:
3659 case target_mem_ref461_K:
3675 THROW_ERROR(
"view_convert_expr pattern not supported: " + std::string(vc_expr_op->get_kind_text()) +
3683 case aggr_init_expr_K:
3684 case case_label_expr_K:
3686 case identifier_node_K:
3687 case statement_list_K:
3691 case bit_and_expr_K:
3692 case bit_ior_expr_K:
3693 case bit_xor_expr_K:
3695 case ceil_div_expr_K:
3696 case ceil_mod_expr_K:
3697 case complex_expr_K:
3698 case compound_expr_K:
3699 case eh_filter_expr_K:
3701 case exact_div_expr_K:
3703 case floor_div_expr_K:
3704 case floor_mod_expr_K:
3707 case goto_subroutine_K:
3711 case lrotate_expr_K:
3719 case mult_highpart_expr_K:
3721 case ordered_expr_K:
3723 case pointer_plus_expr_K:
3724 case postdecrement_expr_K:
3725 case postincrement_expr_K:
3726 case predecrement_expr_K:
3727 case preincrement_expr_K:
3730 case round_div_expr_K:
3731 case round_mod_expr_K:
3732 case rrotate_expr_K:
3735 case trunc_div_expr_K:
3736 case trunc_mod_expr_K:
3737 case truth_and_expr_K:
3738 case truth_andif_expr_K:
3739 case truth_or_expr_K:
3740 case truth_orif_expr_K:
3741 case truth_xor_expr_K:
3742 case try_catch_expr_K:
3750 case unordered_expr_K:
3751 case widen_sum_expr_K:
3752 case widen_mult_expr_K:
3753 case with_size_expr_K:
3754 case vec_cond_expr_K:
3755 case vec_perm_expr_K:
3756 case vec_lshift_expr_K:
3757 case vec_rshift_expr_K:
3758 case widen_mult_hi_expr_K:
3759 case widen_mult_lo_expr_K:
3760 case vec_pack_trunc_expr_K:
3761 case vec_pack_sat_expr_K:
3762 case vec_pack_fix_trunc_expr_K:
3763 case vec_extracteven_expr_K:
3764 case vec_extractodd_expr_K:
3765 case vec_interleavehigh_expr_K:
3766 case vec_interleavelow_expr_K:
3773 case function_decl_K:
3775 case namespace_decl_K:
3776 case translation_unit_decl_K:
3777 case template_decl_K:
3780 case array_range_ref_K:
3783 case with_cleanup_expr_K:
3784 case obj_type_ref_K:
3787 case dot_prod_expr_K:
3788 case ternary_plus_expr_K:
3789 case ternary_pm_expr_K:
3790 case ternary_mp_expr_K:
3791 case ternary_mm_expr_K:
3794 case bit_ior_concat_expr_K:
3796 case alignof_expr_K:
3798 case bit_not_expr_K:
3801 case cleanup_point_expr_K:
3803 case convert_expr_K:
3805 case fix_ceil_expr_K:
3806 case fix_floor_expr_K:
3807 case fix_round_expr_K:
3808 case fix_trunc_expr_K:
3813 case non_lvalue_expr_K:
3815 case reference_expr_K:
3816 case reinterpret_cast_expr_K:
3818 case static_cast_expr_K:
3820 case truth_not_expr_K:
3823 case reduc_max_expr_K:
3824 case reduc_min_expr_K:
3825 case reduc_plus_expr_K:
3826 case vec_unpack_hi_expr_K:
3827 case vec_unpack_lo_expr_K:
3828 case vec_unpack_float_hi_expr_K:
3829 case vec_unpack_float_lo_expr_K:
3832 case extract_bit_expr_K:
3833 case sat_plus_expr_K:
3834 case sat_minus_expr_K:
3835 case extractvalue_expr_K:
3836 case insertvalue_expr_K:
3837 case extractelement_expr_K:
3838 case insertelement_expr_K:
3861 THROW_ASSERT(_node,
"expected positive non zero numbers");
3863 switch(node->get_kind())
3867 const auto sn = GetPointerS<const ssa_name>(node);
3868 if(sn->use_set->is_fully_resolved())
3870 for(
const auto& v : sn->use_set->variables)
3872 res_set.insert(v->index);
3897 case indirect_ref_K:
3899 const auto ir = GetPointerS<const indirect_ref>(node);
3902 case misaligned_indirect_ref_K:
3904 const auto mir = GetPointerS<const misaligned_indirect_ref>(node);
3909 const auto mr = GetPointerS<const mem_ref>(node);
3914 const auto ar = GetPointerS<const array_ref>(node);
3917 case component_ref_K:
3919 const auto cr = GetPointerS<const component_ref>(node);
3922 case realpart_expr_K:
3924 const auto rpe = GetPointerS<const realpart_expr>(node);
3927 case imagpart_expr_K:
3929 const auto rpe = GetPointerS<const imagpart_expr>(node);
3932 case bit_field_ref_K:
3934 const auto bfr = GetPointerS<const bit_field_ref>(node);
3937 case target_mem_ref_K:
3939 const auto tmr = GetPointerS<const target_mem_ref>(node);
3953 case target_mem_ref461_K:
3955 const auto tmr = GetPointerS<const target_mem_ref461>(node);
3967 const auto ae = GetPointerS<const addr_expr>(node);
3970 case view_convert_expr_K:
3972 const auto vc = GetPointerS<const view_convert_expr>(node);
3978 case aggr_init_expr_K:
3979 case case_label_expr_K:
3981 case identifier_node_K:
3982 case statement_list_K:
3986 case bit_and_expr_K:
3987 case bit_ior_expr_K:
3988 case bit_xor_expr_K:
3990 case ceil_div_expr_K:
3991 case ceil_mod_expr_K:
3992 case complex_expr_K:
3993 case compound_expr_K:
3994 case eh_filter_expr_K:
3996 case exact_div_expr_K:
3998 case floor_div_expr_K:
3999 case floor_mod_expr_K:
4002 case goto_subroutine_K:
4006 case lrotate_expr_K:
4014 case mult_highpart_expr_K:
4016 case ordered_expr_K:
4018 case pointer_plus_expr_K:
4019 case postdecrement_expr_K:
4020 case postincrement_expr_K:
4021 case predecrement_expr_K:
4022 case preincrement_expr_K:
4025 case round_div_expr_K:
4026 case round_mod_expr_K:
4027 case rrotate_expr_K:
4030 case trunc_div_expr_K:
4031 case trunc_mod_expr_K:
4032 case truth_and_expr_K:
4033 case truth_andif_expr_K:
4034 case truth_or_expr_K:
4035 case truth_orif_expr_K:
4036 case truth_xor_expr_K:
4037 case try_catch_expr_K:
4045 case unordered_expr_K:
4046 case widen_sum_expr_K:
4047 case widen_mult_expr_K:
4048 case with_size_expr_K:
4049 case vec_cond_expr_K:
4050 case vec_perm_expr_K:
4051 case vec_lshift_expr_K:
4052 case vec_rshift_expr_K:
4053 case widen_mult_hi_expr_K:
4054 case widen_mult_lo_expr_K:
4055 case vec_pack_trunc_expr_K:
4056 case vec_pack_sat_expr_K:
4057 case vec_pack_fix_trunc_expr_K:
4058 case vec_extracteven_expr_K:
4059 case vec_extractodd_expr_K:
4060 case vec_interleavehigh_expr_K:
4061 case vec_interleavelow_expr_K:
4068 case function_decl_K:
4070 case namespace_decl_K:
4071 case translation_unit_decl_K:
4072 case template_decl_K:
4075 case array_range_ref_K:
4078 case with_cleanup_expr_K:
4079 case obj_type_ref_K:
4082 case dot_prod_expr_K:
4083 case ternary_plus_expr_K:
4084 case ternary_pm_expr_K:
4085 case ternary_mp_expr_K:
4086 case ternary_mm_expr_K:
4089 case bit_ior_concat_expr_K:
4091 case alignof_expr_K:
4093 case bit_not_expr_K:
4096 case cleanup_point_expr_K:
4098 case convert_expr_K:
4100 case fix_ceil_expr_K:
4101 case fix_floor_expr_K:
4102 case fix_round_expr_K:
4103 case fix_trunc_expr_K:
4108 case non_lvalue_expr_K:
4110 case reference_expr_K:
4111 case reinterpret_cast_expr_K:
4113 case static_cast_expr_K:
4115 case truth_not_expr_K:
4118 case reduc_max_expr_K:
4119 case reduc_min_expr_K:
4120 case reduc_plus_expr_K:
4121 case vec_unpack_hi_expr_K:
4122 case vec_unpack_lo_expr_K:
4123 case vec_unpack_float_hi_expr_K:
4124 case vec_unpack_float_lo_expr_K:
4126 case extract_bit_expr_K:
4127 case sat_plus_expr_K:
4128 case sat_minus_expr_K:
4129 case extractvalue_expr_K:
4130 case insertvalue_expr_K:
4131 case extractelement_expr_K:
4132 case insertelement_expr_K:
4142 "tree_helper::IsPointerResolved - variable type is not supported: " +
STR(node) +
"-" +
4143 std::string(node->get_kind_text()));
4156 const auto sa = GetPointer<const ssa_name>(node);
4166 return sa->volatile_flag;
4171 THROW_ASSERT(index > 0,
"expected positive non zero numbers");
4173 if(GetPointer<parm_decl>(node))
4177 const auto sn = GetPointer<ssa_name>(node);
4182 return GET_NODE(sn->CGetDefStmt())->get_kind() == gimple_nop_K && sn->var &&
4183 GET_NODE(sn->var)->get_kind() == parm_decl_K;
4188 THROW_ASSERT(index > 0,
"expected positive non zero numbers");
4190 const auto sn = GetPointer<ssa_name>(node);
4191 return sn !=
nullptr;
4196 THROW_ASSERT(index > 0,
"expected positive non zero numbers");
4198 const auto sn = GetPointer<ssa_name>(node);
4203 return sn->virtual_flag;
4214 const auto vd = GetPointer<const var_decl>(decl);
4217 const auto fd = GetPointer<const function_decl>(decl);
4224 return fd->static_flag;
4227 return vd->static_flag;
4238 const auto vd = GetPointer<const var_decl>(decl);
4241 const auto fd = GetPointer<const function_decl>(decl);
4248 return fd->undefined_flag;
4251 return vd->extern_flag;
4264 const auto quals = GetPointer<const type_node>(
GET_CONST_NODE(Type))->qual;
4313 return "__restrict__ ";
4321 return "volatile __restrict__ ";
4325 return real_const ?
"const " :
"/*const*/ ";
4329 return (real_const ?
"const" :
"/*const*/") + std::string(
" __restrict__ ");
4333 return (real_const ?
"const" :
"/*const*/") + std::string(
" volatile ");
4337 return (real_const ?
"const" :
"/*const*/") + std::string(
" volatile __restrict__ ");
4350 type->get_kind() == reference_type_K ||
type->get_kind() == boolean_type_K ||
4351 type->get_kind() == enumeral_type_K,
4352 "Expected a integer_type, pointer_type, reference_type, boolean_type, enumeral_type. Found: " +
4361 if(tn->
get_kind() == tree_reindex_K)
4366 const auto ic = GetPointer<const integer_cst>(tn);
4371 const auto bitwidth =
Size(ic->type);
4380 THROW_ASSERT(index > 0,
"expected positive non zero numbers");
4382 const auto gms = GetPointer<gimple_assign>(node);
4386 ar = GetPointer<array_ref>(
GET_NODE(gms->op0));
4390 ar = GetPointer<array_ref>(
GET_NODE(gms->op1));
4395 if(GetPointer<array_ref>(
GET_NODE(ar->op0)))
4397 ar = GetPointer<array_ref>(
GET_NODE(ar->op0));
4398 if(GetPointer<array_ref>(
GET_NODE(ar->op0)))
4400 THROW_ERROR(
"n-dimension array not yet supported (n > 2)");
4413 tmr = GetPointer<target_mem_ref>(
GET_NODE(gms->op0));
4417 tmr = GetPointer<target_mem_ref>(
GET_NODE(gms->op1));
4437 tmr461 = GetPointer<target_mem_ref461>(
GET_NODE(gms->op0));
4441 tmr461 = GetPointer<target_mem_ref461>(
GET_NODE(gms->op1));
4454 auto ae = GetPointer<addr_expr>(
GET_NODE(gms->op1));
4457 ar = GetPointer<array_ref>(
GET_NODE(ae->op));
4460 if(GetPointer<array_ref>(
GET_NODE(ar->op0)))
4462 ar = GetPointer<array_ref>(
GET_NODE(ar->op0));
4463 if(GetPointer<array_ref>(
GET_NODE(ar->op0)))
4465 THROW_ERROR(
"n-dimension array not yet supported (n > 2)");
4481 const auto ne = GetPointer<nop_expr>(
GET_NODE(gms->op1));
4484 ae = GetPointer<addr_expr>(
GET_NODE(ne->op));
4487 ar = GetPointer<array_ref>(
GET_NODE(ae->op));
4490 if(GetPointer<array_ref>(
GET_NODE(ar->op0)))
4492 ar = GetPointer<array_ref>(
GET_NODE(ar->op0));
4493 if(GetPointer<array_ref>(
GET_NODE(ar->op0)))
4495 THROW_ERROR(
"n-dimension array not yet supported (n > 2)");
4505 const auto vd = GetPointer<var_decl>(
GET_NODE(ae->op));
4524 const auto ga = GetPointer<gimple_assign>(node);
4527 const auto bie = GetPointer<bit_ior_expr>(
GET_NODE(ga->op1));
4534 const auto op0_ssa = GetPointer<ssa_name>(op0);
4535 const auto op1_ssa = GetPointer<ssa_name>(op1);
4536 if(!op0_ssa->bit_values.empty() && !op1_ssa->bit_values.empty())
4538 std::string::const_reverse_iterator it0 = op0_ssa->bit_values.rbegin();
4539 std::string::const_reverse_iterator it1 = op1_ssa->bit_values.rbegin();
4540 std::string::const_reverse_iterator it0_end = op0_ssa->bit_values.rend();
4541 std::string::const_reverse_iterator it1_end = op1_ssa->bit_values.rend();
4542 for(; it0 != it0_end && it1 != it1_end; ++it0, ++it1)
4544 if(*it0 !=
'0' && *it1 !=
'0')
4560 const auto ga = GetPointer<gimple_assign>(node);
4563 const auto ppe = GetPointer<pointer_plus_expr>(
GET_NODE(ga->op1));
4567 if(op1->
get_kind() == integer_cst_K)
4574 else if(op0->
get_kind() == ssa_name_K)
4576 auto temp_def =
GET_NODE(GetPointer<const ssa_name>(op0)->CGetDefStmt());
4577 const auto ga_def = GetPointer<gimple_assign>(temp_def);
4580 if(
GET_NODE(ga_def->op1)->get_kind() == addr_expr_K)
4601 switch(node->get_kind())
4608 case aggr_init_expr_K:
4609 case case_label_expr_K:
4611 case identifier_node_K:
4613 case statement_list_K:
4615 case target_mem_ref_K:
4616 case target_mem_ref461_K:
4650 case truth_or_expr_K:
4651 case truth_orif_expr_K:
4654 case truth_and_expr_K:
4655 case truth_andif_expr_K:
4658 case bit_ior_expr_K:
4661 case truth_xor_expr_K:
4662 case bit_xor_expr_K:
4666 case bit_and_expr_K:
4668 if(dynamic_cast<const addr_expr*>(op))
4670 const auto ae =
static_cast<const addr_expr*
>(op);
4672 if(GetPointer<const array_ref>(tn))
4674 const auto ar = GetPointerS<const array_ref>(tn);
4681 if(GetPointer<const string_cst>(tn))
4712 case vec_lshift_expr_K:
4716 case vec_rshift_expr_K:
4721 case pointer_plus_expr_K:
4722 case widen_sum_expr_K:
4729 case bit_not_expr_K:
4732 case truth_not_expr_K:
4736 case mult_highpart_expr_K:
4737 case indirect_ref_K:
4738 case misaligned_indirect_ref_K:
4739 case widen_mult_expr_K:
4742 case trunc_div_expr_K:
4743 case ceil_div_expr_K:
4744 case floor_div_expr_K:
4745 case round_div_expr_K:
4747 case exact_div_expr_K:
4750 case trunc_mod_expr_K:
4751 case ceil_mod_expr_K:
4752 case floor_mod_expr_K:
4753 case round_mod_expr_K:
4756 case predecrement_expr_K:
4759 case preincrement_expr_K:
4762 case postdecrement_expr_K:
4765 case postincrement_expr_K:
4768 case reference_expr_K:
4770 case realpart_expr_K:
4772 case imagpart_expr_K:
4774 case fix_trunc_expr_K:
4778 case alignof_expr_K:
4785 case aggr_init_expr_K:
4787 case case_label_expr_K:
4789 case cleanup_point_expr_K:
4790 case complex_expr_K:
4791 case compound_expr_K:
4794 case convert_expr_K:
4795 case eh_filter_expr_K:
4797 case fix_ceil_expr_K:
4798 case fix_floor_expr_K:
4799 case fix_round_expr_K:
4802 case goto_subroutine_K:
4803 case identifier_node_K:
4808 case lrotate_expr_K:
4811 case non_lvalue_expr_K:
4813 case ordered_expr_K:
4815 case reduc_max_expr_K:
4816 case reduc_min_expr_K:
4817 case reduc_plus_expr_K:
4818 case reinterpret_cast_expr_K:
4819 case rrotate_expr_K:
4823 case static_cast_expr_K:
4824 case statement_list_K:
4826 case target_mem_ref_K:
4827 case target_mem_ref461_K:
4831 case try_catch_expr_K:
4834 case unordered_expr_K:
4837 case vec_extracteven_expr_K:
4838 case vec_extractodd_expr_K:
4839 case vec_interleavehigh_expr_K:
4840 case vec_interleavelow_expr_K:
4841 case vec_pack_fix_trunc_expr_K:
4842 case vec_pack_sat_expr_K:
4843 case vec_pack_trunc_expr_K:
4844 case vec_unpack_float_hi_expr_K:
4845 case vec_unpack_float_lo_expr_K:
4846 case vec_unpack_hi_expr_K:
4847 case vec_unpack_lo_expr_K:
4848 case view_convert_expr_K:
4849 case widen_mult_hi_expr_K:
4850 case widen_mult_lo_expr_K:
4851 case with_size_expr_K:
4854 case extract_bit_expr_K:
4855 case sat_plus_expr_K:
4856 case sat_minus_expr_K:
4857 case extractvalue_expr_K:
4858 case extractelement_expr_K:
4884 if(node->get_kind() == record_type_K)
4886 const auto rt = GetPointerS<const record_type>(node);
4888 THROW_ASSERT(fd->get_kind() == field_decl_K,
"expected a field_decl");
4891 if(node->get_kind() == union_type_K)
4893 const auto ut = GetPointerS<const union_type>(node);
4895 THROW_ASSERT(fd->get_kind() == field_decl_K,
"expected a field_decl");
4898 if(node->get_kind() != array_type_K)
4902 const auto at = GetPointerS<const array_type>(node);
4905 unsigned long long return_value;
4906 if(elts->get_kind() == array_type_K)
4915 if(!fd || !fd->is_bitfield())
4917 return_value =
std::max(8ull, return_value);
4920 return return_value;
4924 std::vector<unsigned long long>& dims,
unsigned long long& elts_bitsize)
4930 dims.push_back(
Size(node) / elts_bitsize);
4934 const auto at = GetPointer<array_type>(node);
4943 const auto it = GetPointer<integer_type>(domn);
4954 const auto range_domain = max_value - min_value + 1;
4955 THROW_ASSERT(range_domain >= 0,
"Negative range not expected");
4956 dims.push_back(static_cast<unsigned long long>(range_domain));
4960 if(elts->
get_kind() == array_type_K)
4966 const auto etype =
CGetType(at->elts);
4967 elts_bitsize =
Size(etype);
4968 const auto fd = GetPointer<const field_decl>(
GET_CONST_NODE(etype));
4969 if(!fd || !fd->is_bitfield())
4971 elts_bitsize =
std::max(8ull, elts_bitsize);
4977 std::vector<unsigned long long>& dims)
4985 std::vector<unsigned long long> dims;
4986 std::function<void(const tree_nodeConstRef&)> get_array_dim_recurse;
4988 if(tn->get_kind() == record_type_K || tn->get_kind() == union_type_K)
4991 dims.push_back(
Size(tn) / elmt_bitsize);
4994 THROW_ASSERT(tn->get_kind() == array_type_K,
"array_type expected: @" +
STR(tn));
4995 const auto at = GetPointerS<const array_type>(tn);
4997 THROW_ASSERT(domn->get_kind() == integer_type_K,
"expected an integer type as domain");
4998 const auto it = GetPointerS<const integer_type>(domn);
5001 if(it->min &&
GET_CONST_NODE(it->min)->get_kind() == integer_cst_K && it->max &&
5013 const auto range_domain =
static_cast<unsigned long long>(max_value - min_value) + 1;
5014 dims.push_back(range_domain);
5022 if(elts->get_kind() == array_type_K)
5039 auto num_elements = 1ull;
5044 return num_elements;
5048 std::vector<unsigned long long>& indexes,
5049 std::vector<unsigned long long>& size_indexes,
unsigned int& base_object)
5052 THROW_ASSERT(node->get_kind() == array_ref_K,
"array_ref expected: @" +
STR(index));
5053 const auto ar = GetPointerS<const array_ref>(node);
5057 const auto nested_ar = GetPointerS<const array_ref>(
GET_CONST_NODE(ar->op0));
5058 const auto at = GetPointerS<const array_type>(
GET_CONST_NODE(nested_ar->type));
5060 THROW_ASSERT(domn->get_kind() == integer_type_K,
"expected an integer type as domain");
5061 const auto it = GetPointerS<const integer_type>(domn);
5073 const auto range_domain =
static_cast<unsigned long long>(max_value - min_value) + 1;
5074 size_indexes.push_back(range_domain);
5083 return utype ? utype->
index : 0;
5089 if(GetPointer<const type_node>(
type) && GetPointerS<const type_node>(
type)->unql)
5091 return GetPointerS<const type_node>(
type)->unql;
5104 const auto tn = GetPointer<const type_node>(
type);
5106 return tn->unql && tn->algn != GetPointerS<const type_node>(
GET_CONST_NODE(tn->unql))->algn;
5112 const auto vd = GetPointer<const var_decl>(varnode);
5115 return vd->algn < 8 ? 1 : (vd->algn / 8);
5122 static const std::regex rbase(
"[.:$]+");
5123 static const std::regex rtmpl(
"[*&<>\\-]|[, ]+");
5124 std::string norm_typename;
5125 std::regex_replace(std::back_inserter(norm_typename),
id.cbegin(),
id.cend(), rbase,
"_");
5126 const auto tmpl_start = norm_typename.find_first_of(
'<');
5127 if(tmpl_start != std::string::npos)
5129 const auto tmpl_end = norm_typename.find_last_of(
'>');
5131 auto norm_template = norm_typename.substr(0, tmpl_start);
5132 std::regex_replace(std::back_inserter(norm_template), norm_typename.cbegin() +
static_cast<long int>(tmpl_start),
5133 norm_typename.cbegin() +
static_cast<long int>(tmpl_end + 1
U), rtmpl,
"_");
5134 return norm_template;
5136 return norm_typename;
5140 bool print_qualifiers,
bool print_storage,
unsigned int var,
5142 const std::string& tail)
5145 return PrintType(TM, t, global, print_qualifiers, print_storage,
5152 const std::string& tail)
5154 bool skip_var_printing =
false;
5158 "-->Printing type " +
STR(original_type) +
"(" +
STR(node_type) +
") - Var " +
STR(var));
5164 if(node_var->
get_kind() == var_decl_K)
5166 const auto vd = GetPointerS<const var_decl>(node_var);
5173 if(vd->static_flag || vd->static_static_flag)
5180 switch(node_type->get_kind())
5182 case function_decl_K:
5184 const auto fd = GetPointerS<const function_decl>(node_type);
5186 if(fd->undefined_flag)
5190 else if(fd->static_flag)
5194 else if(fd->mngl && function_name !=
"main")
5196 res =
"\n#ifdef __cplusplus\nextern \"C\"\n#endif\n";
5198 const auto dn = GetPointer<const decl_node>(node_type);
5202 if(ftype->
get_kind() == function_type_K || ftype->
get_kind() == method_type_K)
5204 const auto ft = GetPointerS<const function_type>(ftype);
5209 THROW_ERROR(std::string(
"tree node not currently supported ") + node_type->get_kind_text());
5215 res += function_name;
5217 if(!fd->list_of_args.empty())
5219 for(
unsigned int i = 0; i < (fd->list_of_args.size()); i++)
5225 res +=
PrintType(TM,
CGetType(fd->list_of_args[i]), global, print_qualifiers, print_storage,
5226 fd->list_of_args[i], vppf);
5232 skip_var_printing =
true;
5234 res =
PrintType(TM,
type, global, print_qualifiers, print_storage,
nullptr, vppf);
5237 else if(GetPointer<const function_type>(ftype)->prms)
5239 if(ftype->
get_kind() == function_type_K)
5241 const auto ft = GetPointerS<const function_type>(ftype);
5244 else if(ftype->
get_kind() == method_type_K)
5246 const auto mt = GetPointerS<const method_type>(ftype);
5251 THROW_ERROR(std::string(
"tree node not currently supported ") + node_type->get_kind_text());
5254 if((!fd->list_of_args.empty() || GetPointerS<const function_type>(ftype)->prms) &&
5255 GetPointerS<const function_type>(ftype)->varargs_flag)
5264 const auto td = GetPointerS<const type_decl>(node_type);
5268 if(name->get_kind() == identifier_node_K)
5270 const auto in = GetPointerS<const identifier_node>(name);
5273 if(typename_value ==
"char" && GetPointer<const integer_type>(
GET_CONST_NODE(td->type)) &&
5274 GetPointer<const integer_type>(
GET_CONST_NODE(td->type))->unsigned_flag)
5276 res +=
"unsigned " + typename_value;
5279 else if(typename_value ==
"__va_list_tag")
5285 const auto splitted =
SplitString(typename_value,
" ");
5286 if((splitted[0] ==
"_Complex" || splitted[0] ==
"__complex__" || splitted[0] ==
"complex"))
5288 res +=
"__complex__";
5289 for(
unsigned int ci = 1u; ci < splitted.size(); ci++)
5291 res +=
" " + splitted[ci];
5296 res += typename_value;
5301 res += typename_value;
5306 THROW_ERROR(std::string(
"Node not yet supported: ") + node_type->get_kind_text());
5311 THROW_ERROR(std::string(
"Node not yet supported: ") + node_type->get_kind_text());
5313 skip_var_printing =
true;
5316 case identifier_node_K:
5318 const auto in = GetPointerS<const identifier_node>(node_type);
5320 skip_var_printing =
true;
5324 case integer_type_K:
5326 case complex_type_K:
5328 case boolean_type_K:
5330 case nullptr_type_K:
5331 case type_pack_expansion_K:
5333 const auto tn = GetPointerS<const type_node>(node_type);
5335 if(node_var && !tn->name)
5337 const auto is_global_var =
5338 GetPointer<const var_decl>(node_var) &&
5339 (!(GetPointer<const var_decl>(node_var)->scpe) ||
5340 (
GET_CONST_NODE(GetPointer<const var_decl>(node_var)->scpe)->get_kind() == translation_unit_decl_K));
5343 else if(global || print_qualifiers)
5347 if(tn->name && (
GET_CONST_NODE(tn->name)->get_kind() != type_decl_K || !tn->system_flag))
5350 if(name->get_kind() == identifier_node_K)
5352 const auto in = GetPointerS<const identifier_node>(name);
5355 else if(name->get_kind() == type_decl_K)
5361 THROW_ERROR(std::string(
"Node not yet supported: ") +
5362 node_type->get_kind_text());
5365 else if(node_type->get_kind() == complex_type_K)
5367 const auto ct = GetPointerS<const complex_type>(node_type);
5375 if(GetPointer<const complex_type>(node_type)->unsigned_flag)
5379 if(GetPointer<const complex_type>(node_type)->real_flag)
5385 else if(tn->algn == 64)
5389 else if(tn->algn == 80)
5393 else if(tn->algn == 128)
5395 res +=
"__float128";
5399 THROW_ERROR(std::string(
"Complex Real type not yet supported ") +
STR(original_type));
5408 else if(tn->algn == 16)
5412 else if(tn->algn == 32)
5416 else if(tn->algn == 64)
5422 THROW_ERROR(std::string(
"Node not yet supported: ") + node_type->get_kind_text() +
STR(node_var));
5427 else if(node_type->get_kind() == vector_type_K)
5429 const auto vt = GetPointerS<const vector_type>(node_type);
5439 res +=
"int __attribute__((vector_size(" +
STR(
Size(node_type) * 4) +
")))";
5445 THROW_ASSERT(vt->elts,
"expected the type of the elements of the vector");
5447 const auto vector_size = [&]() ->
unsigned int {
5448 unsigned int v = vt->algn / 8;
5458 res +=
" __attribute__((vector_size(" +
STR(vector_size) +
")))";
5464 switch(node_type->get_kind())
5466 case integer_type_K:
5468 const auto it = GetPointerS<const integer_type>(node_type);
5469 if(it->unsigned_flag)
5473 if(it->prec != tn->algn)
5477 res +=
"int __attribute__((vector_size(16)))";
5479 else if(it->prec > 32)
5481 res +=
"long long int";
5483 else if(it->prec > 16)
5487 else if(it->prec > 8)
5496 else if(tn->algn == 8)
5500 else if(tn->algn == 16)
5504 else if(tn->algn == 32)
5508 else if(tn->algn == 64)
5512 else if(tn->algn == 128)
5514 res +=
"int __attribute__((vector_size(16)))";
5518 res +=
"_BitInt(" +
STR(tn->algn) +
")";
5522 case enumeral_type_K:
5527 case boolean_type_K:
5532 const auto rt = GetPointerS<const real_type>(node_type);
5537 else if(rt->prec == 64)
5541 else if(rt->prec == 80)
5545 else if(rt->prec == 128)
5547 res +=
"__float128";
5551 THROW_ERROR(std::string(
"Real type not yet supported ") +
STR(original_type));
5555 case type_pack_expansion_K:
5557 res +=
"<type_pack_expansion>";
5564 case aggr_init_expr_K:
5565 case case_label_expr_K:
5567 case nullptr_type_K:
5568 case complex_type_K:
5570 case function_type_K:
5571 case identifier_node_K:
5575 case pointer_type_K:
5576 case qual_union_type_K:
5578 case reference_type_K:
5581 case statement_list_K:
5583 case target_mem_ref_K:
5584 case target_mem_ref461_K:
5585 case template_type_parm_K:
5586 case type_argument_pack_K:
5589 case typename_type_K:
5605 THROW_ERROR(std::string(
"Node not yet supported ") + node_type->get_kind_text() +
" " +
5606 STR(original_type));
5611 case pointer_type_K:
5612 case reference_type_K:
5614 if(node_type->get_kind() == pointer_type_K)
5616 const auto tree_type = GetPointerS<const pointer_type>(node_type);
5617 if(tree_type->name &&
GET_CONST_NODE(tree_type->name)->get_kind() == type_decl_K)
5619 const auto td = GetPointerS<const type_decl>(
GET_CONST_NODE(tree_type->name));
5620 if(td->name &&
GET_CONST_NODE(td->name)->get_kind() == identifier_node_K)
5622 const auto id = GetPointerS<const identifier_node>(
GET_CONST_NODE(td->name));
5623 if(id->strg ==
"va_list")
5630 const auto rt = GetPointerS<const record_type>(
GET_CONST_NODE(tree_type->ptd));
5631 if(tree_type->ptd &&
GET_NODE(tree_type->ptd)->get_kind() == record_type_K && rt->name &&
5634 const auto td = GetPointerS<const type_decl>(
GET_CONST_NODE(rt->name));
5635 if(td->name &&
GET_CONST_NODE(td->name)->get_kind() == identifier_node_K)
5637 const auto id = GetPointerS<const identifier_node>(
GET_CONST_NODE(td->name));
5638 if(id->strg ==
"va_list" || id->strg ==
"__va_list_tag")
5648 res =
PrintType(TM, tree_type->ptd, global, print_qualifiers, print_storage, var, vppf, prefix + res, tail);
5649 skip_var_printing =
true;
5655 const auto tree_type = GetPointerS<const reference_type>(node_type);
5657 PrintType(TM, tree_type->refd, global, print_qualifiers, print_storage, var, vppf, prefix + res, tail);
5658 skip_var_printing =
true;
5663 case function_type_K:
5665 const auto ft = GetPointerS<const function_type>(node_type);
5666 res +=
PrintType(TM, ft->retn, global,
true);
5667 res +=
"(" + prefix;
5671 res +=
" " + (*vppf)(node_var->
index);
5676 res +=
PrintType(TM, ft->prms, global,
true);
5678 if(ft->varargs_flag && ft->prms)
5682 else if(ft->varargs_flag)
5684 THROW_ERROR(
"ISO C requires a named parameter before '...'");
5687 skip_var_printing =
true;
5692 const auto mt = GetPointerS<const method_type>(node_type);
5696 res +=
"(" + prefix;
5700 res +=
" " + (*vppf)(node_var->
index);
5708 skip_var_printing =
true;
5713 const auto at = GetPointerS<const array_type>(node_type);
5720 std::string local_prefix;
5721 std::string local_tail;
5727 if(array_length->get_kind() == integer_cst_K)
5729 const auto tn = GetPointerS<const type_node>(
GET_CONST_NODE(at->elts));
5734 else if(array_length->get_kind() == var_decl_K)
5750 local_prefix +=
"(" + prefix;
5755 local_prefix +=
" " + (*vppf)(node_var->
index);
5759 local_tail =
")" + local_tail;
5762 res +=
PrintType(TM, at->elts, global, print_qualifiers, print_storage,
nullptr,
nullptr,
"",
5763 local_prefix + tail + local_tail);
5765 if(node_var && node_var->
get_kind() == field_decl_K)
5767 unsigned int type_align = at->algn;
5768 unsigned int var_align;
5769 bool is_a_pointerP =
false;
5775 const auto fd = GetPointerS<const field_decl>(node_var);
5776 var_align = fd->algn;
5777 is_a_pointerP =
GET_CONST_NODE(fd->type)->get_kind() == pointer_type_K ||
5783 var_align = type_align;
5787 var_align = type_align;
5791 const auto vd = GetPointerS<const var_decl>(node_var);
5792 var_align = vd->algn;
5793 is_a_pointerP =
GET_CONST_NODE(vd->type)->get_kind() == pointer_type_K ||
5795 is_static = vd->static_flag;
5801 case aggr_init_expr_K:
5802 case case_label_expr_K:
5805 case function_decl_K:
5806 case identifier_node_K:
5808 case namespace_decl_K:
5810 case statement_list_K:
5812 case target_mem_ref_K:
5813 case target_mem_ref461_K:
5814 case translation_unit_decl_K:
5815 case template_decl_K:
5833 var_align = type_align;
5836 if(var_align > type_align && !is_a_pointerP && !is_static)
5838 res +=
" __attribute__((aligned(" +
STR(var_align / 8) +
")))";
5841 skip_var_printing =
true;
5845 case component_ref_K:
5847 const auto cr = GetPointer<const component_ref>(node_type);
5851 case enumeral_type_K:
5853 const auto et = GetPointer<const enumeral_type>(node_type);
5854 if(et->name && (
GET_CONST_NODE(et->name)->get_kind() == type_decl_K || et->unql))
5860 res +=
"enum " +
PrintType(TM, et->name, global);
5864 res +=
"Internal_" +
STR(node_type->index);
5868 res +=
"enum Internal_" +
STR(node_type->index);
5874 const auto rt = GetPointerS<const record_type>(node_type);
5876 if(rt->name && (
GET_CONST_NODE(rt->name)->get_kind() == type_decl_K || (rt->unql && !rt->system_flag)))
5878 res += (rt->unql ?
"" :
"struct ") +
PrintType(TM, rt->name, global);
5882 const auto struct_name =
PrintType(TM, rt->name, global);
5883 if(struct_name ==
"_IO_FILE")
5894 res +=
"Internal_" +
STR(node_type->index);
5898 res +=
"struct Internal_" +
STR(node_type->index);
5902 std::stringstream ss;
5903 const auto& tmpl_args = GetPointerS<const tree_vec>(
GET_CONST_NODE(rt->tmpl_args))->list_of_op;
5904 for(
const auto& targ : tmpl_args)
5914 const auto ut = GetPointerS<const union_type>(node_type);
5916 if(ut->name && (
GET_NODE(ut->name)->get_kind() == type_decl_K || (ut->unql && !ut->system_flag)))
5922 res +=
"union " +
PrintType(TM, ut->name, global);
5926 res +=
"Internal_" +
STR(node_type->index);
5930 res +=
"union Internal_" +
STR(node_type->index);
5936 THROW_ASSERT(!node_var,
"Received something of unexpected");
5937 auto lnode = GetPointer<const tree_list>(node_type);
5938 res +=
PrintType(TM, lnode->valu, global, print_qualifiers);
5941 std::list<tree_nodeRef> prmtrs;
5944 lnode = GetPointer<const tree_list>(
GET_CONST_NODE(lnode->chan));
5947 prmtrs.push_back(lnode->valu);
5950 for(
const auto& valu : prmtrs)
5952 res +=
"," +
PrintType(TM, valu, global, print_qualifiers);
5956 case template_type_parm_K:
5958 const auto ttp = GetPointer<const template_type_parm>(node_type);
5959 res +=
PrintType(TM, ttp->name, global, print_qualifiers);
5962 case typename_type_K:
5964 const auto tt = GetPointer<const typename_type>(node_type);
5965 res +=
PrintType(TM, tt->name, global, print_qualifiers);
5968 case template_decl_K:
5970 const auto td = GetPointer<const template_decl>(node_type);
5976 const auto pd = GetPointer<const parm_decl>(node_type);
5977 if(pd->readonly_flag)
5979 res += print_qualifiers ?
"const " :
"/*const*/ ";
5981 res +=
PrintType(TM, pd->type, global, print_qualifiers);
5987 case aggr_init_expr_K:
5988 case case_label_expr_K:
5994 case namespace_decl_K:
5996 case qual_union_type_K:
6000 case statement_list_K:
6002 case target_mem_ref_K:
6003 case target_mem_ref461_K:
6004 case type_argument_pack_K:
6005 case translation_unit_decl_K:
6009 case vec_cond_expr_K:
6010 case vec_perm_expr_K:
6011 case bit_field_ref_K:
6013 case with_cleanup_expr_K:
6014 case obj_type_ref_K:
6017 case dot_prod_expr_K:
6018 case ternary_plus_expr_K:
6019 case ternary_pm_expr_K:
6020 case ternary_mp_expr_K:
6021 case ternary_mm_expr_K:
6024 case bit_ior_concat_expr_K:
6027 case insertvalue_expr_K:
6028 case insertelement_expr_K:
6038 THROW_UNREACHABLE(
"Type not yet supported " +
STR(original_type) +
" " + node_type->get_kind_text() +
" " +
6039 (node_var ?
STR(node_var) :
""));
6041 if(!skip_var_printing)
6047 res +=
" " + (*vppf)(node_var->
index);
6057 if(no_serialize.find(name) != no_serialize.end())
6061 if(internal_serialize.find(name) != internal_serialize.end())
6070 return (transparent.find(name) != transparent.end());
6076 if(var->
get_kind() == tree_reindex_K)
6084 THROW_ASSERT(GetPointer<decl_node>(curr_tn),
"Checking type of not a decl_node");
6085 const auto dn = GetPointer<decl_node>(curr_tn);
6086 std::string include_name = dn->include_name;
6087 auto it_end = headers.end();
6088 for(
auto it = headers.begin(); it != it_end; ++it)
6090 if(include_name.find(*it) != std::string::npos && dn->type)
6092 if(GetPointer<type_node>(
GET_NODE(dn->type)))
6094 lib_types.insert(
GET_NODE(dn->type));
6095 const auto tn = GetPointer<type_node>(
GET_NODE(dn->type));
6098 lib_types.insert(
GET_NODE(tn->unql));
6108 if(tn->
get_kind() == tree_reindex_K)
6116 THROW_ASSERT(GetPointer<type_node>(curr_tn) || GetPointer<function_decl>(curr_tn),
6117 "tn is not a node of type type_node nor function_decl");
6118 if(lib_types.find(curr_tn) != lib_types.end())
6122 if(curr_tn->
get_kind() == record_type_K)
6124 const auto rt = GetPointer<record_type>(curr_tn);
6130 const auto type = GetPointer<type_node>(curr_tn);
6133 const auto td = GetPointer<type_decl>(
GET_NODE(
type->name));
6136 std::string include_name = td->include_name;
6137 auto it_end = headers.end();
6138 for(
auto it = headers.begin(); it != it_end; ++it)
6140 if(include_name.find(*it) != std::string::npos)
6152 internal_serialize.insert(
"printf");
6153 transparent.insert(
"__builtin_va_start");
6154 headers.insert(
"stdio.h");
6160 if(obj->get_kind() == gimple_call_K)
6162 const auto gc = GetPointerS<const gimple_call>(obj);
6166 if(fn_type->get_kind() == pointer_type_K)
6168 const auto pt = GetPointerS<const pointer_type>(fn_type);
6170 const auto ft = GetPointer<const function_type>(
GET_CONST_NODE(pt->ptd));
6171 if(ft && ft->varargs_flag)
6175 else if(ft && ft->prms)
6177 auto tl = GetPointerS<const tree_list>(
GET_CONST_NODE(ft->prms));
6179 unsigned int ith = 0;
6180 if(parm_index == ith)
6188 if(parm_index == ith)
6200 THROW_ASSERT(fn_node->get_kind() == addr_expr_K,
"Unexpected pattern");
6201 const auto ue = GetPointerS<const unary_expr>(fn_node);
6203 THROW_ASSERT(fn->get_kind() == function_decl_K,
"Unexpected pattern");
6213 else if(obj->get_kind() == gimple_assign_K)
6215 const auto ga = GetPointerS<const gimple_assign>(obj);
6218 else if(obj->get_kind() == call_expr_K || obj->get_kind() == aggr_init_expr_K)
6220 const auto ce = GetPointerS<const call_expr>(obj);
6222 if(fn_type->get_kind() == pointer_type_K)
6224 const auto pt = GetPointerS<const pointer_type>(fn_type);
6226 const auto ft = GetPointer<const function_type>(
GET_CONST_NODE(pt->ptd));
6227 if(ft && ft->varargs_flag)
6231 else if(ft && ft->prms)
6233 auto tl = GetPointerS<const tree_list>(
GET_CONST_NODE(ft->prms));
6234 unsigned int ith = 0;
6235 if(parm_index == ith)
6243 if(parm_index == ith)
6255 THROW_ASSERT(fn_node->get_kind() == addr_expr_K,
"Unexpected pattern");
6256 const auto ue = GetPointerS<const unary_expr>(fn_node);
6268 else if(obj->get_kind() == function_decl_K)
6270 const auto fd = GetPointerS<const function_decl>(obj);
6271 unsigned int ith = 0;
6272 for(
const auto& i : fd->list_of_args)
6274 if(parm_index == ith)
6285 unsigned int parm_index)
6288 return t ? t->
index : 0;
6301 if(GetPointer<const decl_node>(
type)->packed_flag)
6306 if(GetPointer<const type_decl>(node_type))
6310 switch(node_type->get_kind())
6314 auto rt = GetPointerS<const record_type>(node_type);
6324 for(
auto& list_of_fld : rt->list_of_flds)
6326 const auto fd = GetPointer<const field_decl>(
GET_CONST_NODE(list_of_fld));
6327 if(fd && fd->packed_flag)
6336 auto ut = GetPointerS<const union_type>(node_type);
6348 for(
const auto& list_of_fld : ut->list_of_flds)
6350 const auto fd = GetPointerS<const field_decl>(
GET_CONST_NODE(list_of_fld));
6358 case enumeral_type_K:
6360 auto et = GetPointerS<const enumeral_type>(node_type);
6373 case pointer_type_K:
6374 case boolean_type_K:
6376 case nullptr_type_K:
6377 case type_pack_expansion_K:
6378 case complex_type_K:
6379 case function_type_K:
6380 case integer_type_K:
6384 case qual_union_type_K:
6386 case reference_type_K:
6388 case template_type_parm_K:
6389 case type_argument_pack_K:
6390 case typename_type_K:
6399 case aggr_init_expr_K:
6400 case case_label_expr_K:
6402 case identifier_node_K:
6404 case statement_list_K:
6406 case target_mem_ref_K:
6407 case target_mem_ref461_K:
6434 switch(t->get_kind())
6438 const auto mr = GetPointer<const mem_ref>(t);
6441 case target_mem_ref461_K:
6443 const auto tmr = GetPointer<const target_mem_ref461>(t);
6446 case component_ref_K:
6448 const auto cr = GetPointer<const component_ref>(t);
6450 if(GetPointer<const field_decl>(fd) && GetPointer<const field_decl>(fd)->packed_flag)
6456 case realpart_expr_K:
6457 case imagpart_expr_K:
6458 case bit_field_ref_K:
6466 const auto ae = GetPointer<const addr_expr>(t);
6471 const auto sn = GetPointer<const ssa_name>(t);
6472 const auto def_stmt = sn->CGetDefStmt();
6475 const auto ga = GetPointer<const gimple_assign>(
GET_CONST_NODE(def_stmt));
6476 if(ga->temporary_address)
6488 case aggr_init_expr_K:
6489 case case_label_expr_K:
6491 case identifier_node_K:
6492 case statement_list_K:
6493 case target_mem_ref_K:
6497 case bit_and_expr_K:
6498 case bit_ior_expr_K:
6499 case bit_xor_expr_K:
6501 case ceil_div_expr_K:
6502 case ceil_mod_expr_K:
6503 case complex_expr_K:
6504 case compound_expr_K:
6505 case eh_filter_expr_K:
6507 case exact_div_expr_K:
6509 case floor_div_expr_K:
6510 case floor_mod_expr_K:
6513 case goto_subroutine_K:
6517 case lrotate_expr_K:
6525 case mult_highpart_expr_K:
6527 case ordered_expr_K:
6530 case pointer_plus_expr_K:
6531 case postdecrement_expr_K:
6532 case postincrement_expr_K:
6533 case predecrement_expr_K:
6534 case preincrement_expr_K:
6537 case round_div_expr_K:
6538 case round_mod_expr_K:
6539 case rrotate_expr_K:
6542 case trunc_div_expr_K:
6543 case trunc_mod_expr_K:
6544 case truth_and_expr_K:
6545 case truth_andif_expr_K:
6546 case truth_or_expr_K:
6547 case truth_orif_expr_K:
6548 case truth_xor_expr_K:
6549 case try_catch_expr_K:
6557 case unordered_expr_K:
6558 case widen_sum_expr_K:
6559 case widen_mult_expr_K:
6560 case with_size_expr_K:
6561 case vec_lshift_expr_K:
6562 case vec_rshift_expr_K:
6563 case widen_mult_hi_expr_K:
6564 case widen_mult_lo_expr_K:
6565 case vec_pack_trunc_expr_K:
6566 case vec_pack_sat_expr_K:
6567 case vec_pack_fix_trunc_expr_K:
6568 case vec_extracteven_expr_K:
6569 case vec_extractodd_expr_K:
6570 case vec_interleavehigh_expr_K:
6571 case vec_interleavelow_expr_K:
6576 case function_decl_K:
6578 case namespace_decl_K:
6581 case translation_unit_decl_K:
6582 case template_decl_K:
6589 case with_cleanup_expr_K:
6590 case obj_type_ref_K:
6593 case vec_cond_expr_K:
6594 case vec_perm_expr_K:
6595 case dot_prod_expr_K:
6596 case ternary_plus_expr_K:
6597 case ternary_pm_expr_K:
6598 case ternary_mp_expr_K:
6599 case ternary_mm_expr_K:
6602 case bit_ior_concat_expr_K:
6604 case alignof_expr_K:
6606 case bit_not_expr_K:
6609 case cleanup_point_expr_K:
6611 case convert_expr_K:
6613 case fix_ceil_expr_K:
6614 case fix_floor_expr_K:
6615 case fix_round_expr_K:
6616 case fix_trunc_expr_K:
6618 case indirect_ref_K:
6619 case misaligned_indirect_ref_K:
6623 case non_lvalue_expr_K:
6625 case reference_expr_K:
6626 case reinterpret_cast_expr_K:
6628 case static_cast_expr_K:
6630 case truth_not_expr_K:
6633 case view_convert_expr_K:
6634 case reduc_max_expr_K:
6635 case reduc_min_expr_K:
6636 case reduc_plus_expr_K:
6637 case vec_unpack_hi_expr_K:
6638 case vec_unpack_lo_expr_K:
6639 case vec_unpack_float_hi_expr_K:
6640 case vec_unpack_float_lo_expr_K:
6642 case array_range_ref_K:
6645 case extract_bit_expr_K:
6646 case sat_plus_expr_K:
6647 case sat_minus_expr_K:
6653 case extractvalue_expr_K:
6654 case insertvalue_expr_K:
6655 case extractelement_expr_K:
6656 case insertelement_expr_K:
6662 THROW_ERROR(
"elements not yet supported: " + t->get_kind_text());
6675 const auto atype = GetPointerS<const array_type>(
type_node);
6680 const auto rt = GetPointerS<const record_type>(
type_node);
6681 for(
const auto& fli : rt->list_of_flds)
6712 const auto ut = GetPointerS<const union_type>(
type_node);
6713 for(
const auto& fli : ut->list_of_flds)
6724 case complex_type_K:
6729 case integer_type_K:
6730 case enumeral_type_K:
6731 case pointer_type_K:
6732 case reference_type_K:
6738 case function_decl_K:
6739 case function_type_K:
6744 case boolean_type_K:
6751 case aggr_init_expr_K:
6752 case case_label_expr_K:
6754 case nullptr_type_K:
6755 case type_pack_expansion_K:
6758 case identifier_node_K:
6761 case namespace_decl_K:
6764 case qual_union_type_K:
6768 case statement_list_K:
6770 case target_mem_ref_K:
6771 case target_mem_ref461_K:
6772 case template_type_parm_K:
6773 case type_argument_pack_K:
6774 case translation_unit_decl_K:
6775 case template_decl_K:
6780 case typename_type_K:
6806 const auto atype = GetPointerS<const array_type>(
type_node);
6811 const auto rt = GetPointerS<const record_type>(
type_node);
6812 for(
const auto& fli : rt->list_of_flds)
6843 const auto ut = GetPointerS<const union_type>(
type_node);
6844 for(
const auto& fli : ut->list_of_flds)
6855 case complex_type_K:
6860 case integer_type_K:
6861 case enumeral_type_K:
6862 case pointer_type_K:
6863 case reference_type_K:
6869 case boolean_type_K:
6876 case aggr_init_expr_K:
6877 case case_label_expr_K:
6879 case nullptr_type_K:
6880 case type_pack_expansion_K:
6883 case function_decl_K:
6884 case function_type_K:
6885 case identifier_node_K:
6889 case namespace_decl_K:
6892 case qual_union_type_K:
6896 case statement_list_K:
6898 case target_mem_ref_K:
6899 case target_mem_ref461_K:
6900 case template_type_parm_K:
6901 case type_argument_pack_K:
6902 case translation_unit_decl_K:
6903 case template_decl_K:
6908 case typename_type_K:
6934 const auto ae = GetPointer<const addr_expr>(parameter);
6938 switch(addr_expr_argument->get_kind())
6942 const array_ref* ar = GetPointer<array_ref>(addr_expr_argument);
6945 "<--Analyzed " + parameter->
ToString() +
" - Size is " +
STR(byte_parameter_size));
6946 return byte_parameter_size;
6948 case(component_ref_K):
6956 "<--Analyzed " + parameter->
ToString() +
" - Size is " +
STR(byte_parameter_size));
6957 return byte_parameter_size;
6959 case array_range_ref_K:
6963 case aggr_init_expr_K:
6964 case case_label_expr_K:
6967 case identifier_node_K:
6971 case statement_list_K:
6973 case target_mem_ref_K:
6974 case target_mem_ref461_K:
6981 case function_decl_K:
6983 case namespace_decl_K:
6985 case translation_unit_decl_K:
6986 case template_decl_K:
6989 case bit_field_ref_K:
6991 case with_cleanup_expr_K:
6992 case obj_type_ref_K:
6995 case dot_prod_expr_K:
6996 case ternary_plus_expr_K:
6997 case ternary_pm_expr_K:
6998 case ternary_mp_expr_K:
6999 case ternary_mm_expr_K:
7002 case bit_ior_concat_expr_K:
7004 case bit_and_expr_K:
7005 case bit_ior_expr_K:
7006 case bit_xor_expr_K:
7008 case ceil_div_expr_K:
7009 case ceil_mod_expr_K:
7010 case complex_expr_K:
7011 case compound_expr_K:
7012 case eh_filter_expr_K:
7014 case exact_div_expr_K:
7016 case floor_div_expr_K:
7017 case floor_mod_expr_K:
7020 case goto_subroutine_K:
7024 case lrotate_expr_K:
7033 case mult_highpart_expr_K:
7035 case ordered_expr_K:
7037 case pointer_plus_expr_K:
7038 case postdecrement_expr_K:
7039 case postincrement_expr_K:
7040 case predecrement_expr_K:
7041 case preincrement_expr_K:
7044 case round_div_expr_K:
7045 case round_mod_expr_K:
7046 case rrotate_expr_K:
7049 case trunc_div_expr_K:
7050 case trunc_mod_expr_K:
7051 case truth_and_expr_K:
7052 case truth_andif_expr_K:
7053 case truth_or_expr_K:
7054 case truth_orif_expr_K:
7055 case truth_xor_expr_K:
7056 case try_catch_expr_K:
7064 case unordered_expr_K:
7065 case widen_sum_expr_K:
7066 case widen_mult_expr_K:
7067 case with_size_expr_K:
7068 case vec_lshift_expr_K:
7069 case vec_rshift_expr_K:
7070 case widen_mult_hi_expr_K:
7071 case widen_mult_lo_expr_K:
7072 case vec_cond_expr_K:
7073 case vec_pack_trunc_expr_K:
7074 case vec_pack_sat_expr_K:
7075 case vec_pack_fix_trunc_expr_K:
7076 case vec_perm_expr_K:
7077 case vec_extracteven_expr_K:
7078 case vec_extractodd_expr_K:
7079 case vec_interleavehigh_expr_K:
7080 case vec_interleavelow_expr_K:
7082 case extract_bit_expr_K:
7083 case sat_plus_expr_K:
7084 case sat_minus_expr_K:
7085 case extractvalue_expr_K:
7086 case insertvalue_expr_K:
7087 case extractelement_expr_K:
7088 case insertelement_expr_K:
7098 THROW_UNREACHABLE(
"Unsupported addr_expr argument " + addr_expr_argument->get_kind_text());
7105 const auto at = GetPointer<const array_type>(parameter);
7108 const size_t bit_parameter_size =
Size(parameter);
7110 const size_t byte_parameter_size = bit_parameter_size / 8;
7112 "<--Analyzed " + parameter->
ToString() +
" - Size is " +
STR(byte_parameter_size));
7113 return byte_parameter_size;
7115 case(record_type_K):
7117 size_t fields_pointed_size = 0;
7118 const auto rt = GetPointer<const record_type>(parameter);
7119 const std::vector<tree_nodeRef>& list_of_fields = rt->list_of_flds;
7121 std::vector<tree_nodeRef>::const_iterator field, field_end = list_of_fields.end();
7122 for(field = list_of_fields.begin(); field != field_end; ++field)
7124 if(
GET_NODE(*field)->get_kind() == type_decl_K)
7128 if(
GET_NODE(*field)->get_kind() == function_decl_K)
7136 const size_t bit_parameter_size =
Size(parameter) + fields_pointed_size;
7138 const size_t byte_parameter_size = bit_parameter_size / 8;
7140 "<--Analyzed " + parameter->
ToString() +
" - Size is " +
STR(byte_parameter_size));
7141 return byte_parameter_size;
7143 case(component_ref_K):
7145 const auto cr = GetPointer<const component_ref>(parameter);
7148 THROW_ERROR(
"Offloading fields of union is not supported");
7152 "<--Analyzed " + parameter->
ToString() +
" - Size is " +
STR(byte_parameter_size));
7153 return byte_parameter_size;
7159 "<--Analyzed " + parameter->
ToString() +
" - Size is " +
STR(byte_parameter_size));
7160 return byte_parameter_size;
7162 case(enumeral_type_K):
7163 case(integer_type_K):
7167 const size_t bit_parameter_size =
Size(parameter);
7169 const size_t byte_parameter_size = bit_parameter_size / 8;
7171 "<--Analyzed " + parameter->
ToString() +
" - Size is " +
STR(byte_parameter_size));
7172 return byte_parameter_size;
7176 const auto mr = GetPointer<const mem_ref>(parameter);
7179 "<--Analyzed " + parameter->
ToString() +
" - Size is " +
STR(byte_parameter_size));
7180 return byte_parameter_size;
7186 const auto sn = GetPointer<const ssa_name>(parameter);
7187 if(sn && (
GET_NODE(sn->var)->get_kind() == parm_decl_K) && sn->CGetDefStmts().empty())
7192 const auto ptype =
CGetType(parameter);
7195 "<--Analyzed " + parameter->
ToString() +
" - Size is " +
STR(byte_parameter_size));
7196 return byte_parameter_size;
7199 case bit_field_ref_K:
7201 case boolean_type_K:
7203 case aggr_init_expr_K:
7204 case case_label_expr_K:
7206 case nullptr_type_K:
7207 case type_pack_expansion_K:
7209 case complex_type_K:
7213 case dot_prod_expr_K:
7214 case ternary_plus_expr_K:
7215 case ternary_pm_expr_K:
7216 case ternary_mp_expr_K:
7217 case ternary_mm_expr_K:
7220 case bit_ior_concat_expr_K:
7221 case function_decl_K:
7222 case identifier_node_K:
7227 case namespace_decl_K:
7228 case obj_type_ref_K:
7231 case pointer_type_K:
7232 case qual_union_type_K:
7237 case statement_list_K:
7239 case target_mem_ref_K:
7240 case target_mem_ref461_K:
7241 case template_type_parm_K:
7242 case type_argument_pack_K:
7243 case translation_unit_decl_K:
7244 case template_decl_K:
7249 case typename_type_K:
7255 case with_cleanup_expr_K:
7256 case function_type_K:
7257 case reference_type_K:
7260 case alignof_expr_K:
7262 case bit_not_expr_K:
7265 case cleanup_point_expr_K:
7267 case convert_expr_K:
7269 case fix_ceil_expr_K:
7270 case fix_floor_expr_K:
7271 case fix_round_expr_K:
7272 case fix_trunc_expr_K:
7274 case imagpart_expr_K:
7275 case indirect_ref_K:
7276 case misaligned_indirect_ref_K:
7280 case non_lvalue_expr_K:
7282 case realpart_expr_K:
7283 case reference_expr_K:
7284 case reinterpret_cast_expr_K:
7286 case static_cast_expr_K:
7288 case truth_not_expr_K:
7291 case view_convert_expr_K:
7292 case reduc_max_expr_K:
7293 case reduc_min_expr_K:
7294 case reduc_plus_expr_K:
7295 case vec_unpack_hi_expr_K:
7296 case vec_unpack_lo_expr_K:
7297 case vec_unpack_float_hi_expr_K:
7298 case vec_unpack_float_lo_expr_K:
7300 case bit_and_expr_K:
7301 case bit_ior_expr_K:
7302 case bit_xor_expr_K:
7304 case ceil_div_expr_K:
7305 case ceil_mod_expr_K:
7306 case complex_expr_K:
7307 case compound_expr_K:
7308 case eh_filter_expr_K:
7310 case exact_div_expr_K:
7312 case floor_div_expr_K:
7313 case floor_mod_expr_K:
7316 case goto_subroutine_K:
7320 case lrotate_expr_K:
7328 case mult_highpart_expr_K:
7330 case ordered_expr_K:
7332 case pointer_plus_expr_K:
7333 case postdecrement_expr_K:
7334 case postincrement_expr_K:
7335 case predecrement_expr_K:
7336 case preincrement_expr_K:
7339 case round_div_expr_K:
7340 case round_mod_expr_K:
7341 case rrotate_expr_K:
7344 case trunc_div_expr_K:
7345 case trunc_mod_expr_K:
7346 case truth_and_expr_K:
7347 case truth_andif_expr_K:
7348 case truth_or_expr_K:
7349 case truth_orif_expr_K:
7350 case truth_xor_expr_K:
7351 case try_catch_expr_K:
7359 case unordered_expr_K:
7360 case vec_cond_expr_K:
7361 case vec_perm_expr_K:
7362 case widen_sum_expr_K:
7363 case widen_mult_expr_K:
7364 case with_size_expr_K:
7365 case vec_lshift_expr_K:
7366 case vec_rshift_expr_K:
7367 case widen_mult_hi_expr_K:
7368 case widen_mult_lo_expr_K:
7369 case vec_pack_trunc_expr_K:
7370 case vec_pack_sat_expr_K:
7371 case vec_pack_fix_trunc_expr_K:
7372 case vec_extracteven_expr_K:
7373 case vec_extractodd_expr_K:
7374 case vec_interleavehigh_expr_K:
7375 case vec_interleavelow_expr_K:
7377 case extract_bit_expr_K:
7378 case sat_plus_expr_K:
7379 case sat_minus_expr_K:
7380 case extractvalue_expr_K:
7381 case insertvalue_expr_K:
7382 case extractelement_expr_K:
7383 case insertelement_expr_K:
7403 switch(tn->get_kind())
7405 case enumeral_type_K:
7406 case integer_type_K:
7416 case reference_type_K:
7417 case pointer_type_K:
7423 const auto rt = GetPointer<const record_type>(tn);
7424 const std::vector<tree_nodeRef> list_of_fields = rt->list_of_flds;
7425 std::vector<tree_nodeRef>::const_iterator field, field_end = list_of_fields.end();
7426 for(field = list_of_fields.begin(); field != field_end; ++field)
7428 if(
GET_NODE(*field)->get_kind() == type_decl_K)
7432 if(
GET_NODE(*field)->get_kind() == function_decl_K)
7443 case aggr_init_expr_K:
7444 case case_label_expr_K:
7446 case identifier_node_K:
7449 case qual_union_type_K:
7452 case statement_list_K:
7453 case target_mem_ref_K:
7454 case target_mem_ref461_K:
7455 case template_type_parm_K:
7456 case type_argument_pack_K:
7459 case typename_type_K:
7461 case function_decl_K:
7463 case namespace_decl_K:
7465 case translation_unit_decl_K:
7466 case template_decl_K:
7471 case boolean_type_K:
7473 case nullptr_type_K:
7474 case type_pack_expansion_K:
7475 case complex_type_K:
7476 case function_type_K:
7502 unsigned int looked_for_cond)
7505 const auto gmwi = GetPointer<const gimple_multi_way_if>(t);
7506 unsigned int pos = 0;
7507 for(
auto const& cond : gmwi->list_of_cond)
7509 if(cond.first && cond.first->index == looked_for_cond)
7515 THROW_ERROR(
"cond not found in gimple_multi_way_if " + t->ToString() +
" looked_for_cond " +
STR(looked_for_cond));
7523 const auto gn = GetPointer<const gimple_node>(curr_tn);
7530 if(!gn->vuses.empty())
7532 for(
const auto& vuse : gn->vuses)
7540 case tree_reindex_K:
7545 case gimple_return_K:
7547 const auto re = GetPointer<const gimple_return>(curr_tn);
7554 case gimple_assign_K:
7556 const auto me = GetPointer<const gimple_assign>(curr_tn);
7557 if(
GET_NODE(me->op0)->get_kind() != ssa_name_K)
7573 case aggr_init_expr_K:
7575 const auto ce = GetPointer<const call_expr>(curr_tn);
7577 for(
const auto&
arg : ce->args)
7585 const auto ce = GetPointer<const gimple_call>(curr_tn);
7587 for(
const auto&
arg : ce->args)
7595 const auto gc = GetPointer<const gimple_cond>(curr_tn);
7602 const auto ue = GetPointer<const unary_expr>(curr_tn);
7608 const auto be = GetPointer<const binary_expr>(curr_tn);
7614 case gimple_switch_K:
7616 const auto se = GetPointer<const gimple_switch>(curr_tn);
7622 const auto te = GetPointer<const ternary_expr>(curr_tn);
7633 const auto qe = GetPointer<const quaternary_expr>(curr_tn);
7648 const auto le = GetPointer<const lut_expr>(curr_tn);
7683 const auto c = GetPointer<const constructor>(curr_tn);
7684 for(
const auto& iv : c->list_of_idx_valu)
7700 const auto ae = GetPointer<const gimple_asm>(curr_tn);
7715 const auto ge = GetPointer<const gimple_goto>(curr_tn);
7721 auto tl = GetPointer<const tree_list>(curr_tn);
7722 std::list<const tree_list*> tl_list;
7725 tl_list.push_back(tl);
7726 tl = tl->chan ? GetPointer<const tree_list>(
GET_CONST_NODE(tl->chan)) :
nullptr;
7728 for(
const auto& tl_current0 : tl_list)
7730 if(tl_current0->purp)
7734 if(tl_current0->valu)
7741 case gimple_multi_way_if_K:
7743 const auto gmwi = GetPointer<const gimple_multi_way_if>(curr_tn);
7744 for(
const auto& cond : gmwi->list_of_cond)
7756 case function_decl_K:
7765 case gimple_label_K:
7770 case target_mem_ref_K:
7772 const auto tmr = GetPointer<const target_mem_ref>(curr_tn);
7788 case target_mem_ref461_K:
7790 const auto tmr = GetPointer<const target_mem_ref461>(curr_tn);
7808 ssa_uses.insert(GetPointer<const ssa_name>(curr_tn));
7813 case case_label_expr_K:
7818 case placeholder_expr_K:
7821 case gimple_predict_K:
7823 case gimple_pragma_K:
7824 case identifier_node_K:
7825 case namespace_decl_K:
7826 case statement_list_K:
7828 case translation_unit_decl_K:
7834 case gimple_while_K:
7835 case template_decl_K:
7860 "-->Computing ssa uses in " + curr_tn->ToString() +
" (" + curr_tn->get_kind_text() +
")");
7861 const auto gn = GetPointer<const gimple_node>(curr_tn);
7869 for(
const auto& vuse : gn->vuses)
7873 for(
const auto& vover : gn->vovers)
7880 switch(curr_tn->get_kind())
7882 case gimple_return_K:
7884 const auto re = GetPointerS<gimple_return>(curr_tn);
7891 case gimple_assign_K:
7893 const auto me = GetPointerS<gimple_assign>(curr_tn);
7894 if(
GET_NODE(me->op0)->get_kind() != ssa_name_K)
7910 case aggr_init_expr_K:
7912 const auto ce = GetPointerS<call_expr>(curr_tn);
7914 for(
const auto&
arg : ce->args)
7922 const auto ce = GetPointerS<gimple_call>(curr_tn);
7924 for(
const auto&
arg : ce->args)
7932 const auto gc = GetPointerS<gimple_cond>(curr_tn);
7939 const auto ue = GetPointerS<unary_expr>(curr_tn);
7940 if(
GET_NODE(ue->op)->get_kind() != function_decl_K)
7948 const auto be = GetPointerS<binary_expr>(curr_tn);
7954 case gimple_switch_K:
7956 const auto se = GetPointerS<gimple_switch>(curr_tn);
7962 const auto te = GetPointerS<ternary_expr>(curr_tn);
7973 const auto qe = GetPointerS<quaternary_expr>(curr_tn);
7988 const auto le = GetPointerS<lut_expr>(curr_tn);
8023 const auto c = GetPointerS<constructor>(curr_tn);
8024 for(
const auto& iv : c->list_of_idx_valu)
8042 const auto ae = GetPointerS<gimple_asm>(curr_tn);
8059 const auto ge = GetPointerS<gimple_goto>(curr_tn);
8065 auto tl = GetPointerS<const tree_list>(curr_tn);
8066 std::list<const tree_list*> tl_list;
8069 tl_list.push_back(tl);
8070 tl = tl->chan ? GetPointerS<const tree_list>(
GET_CONST_NODE(tl->chan)) :
nullptr;
8072 for(
const auto tl_current0 : tl_list)
8074 if(tl_current0->purp)
8078 if(tl_current0->valu)
8085 case gimple_multi_way_if_K:
8087 const auto gmwi = GetPointerS<gimple_multi_way_if>(curr_tn);
8088 for(
const auto& cond : gmwi->list_of_cond)
8099 const auto gp = GetPointerS<gimple_phi>(curr_tn);
8100 for(
const auto& def_edge : gp->CGetDefEdgesList())
8108 case function_decl_K:
8117 case gimple_label_K:
8122 case target_mem_ref_K:
8124 const auto tmr = GetPointerS<target_mem_ref>(curr_tn);
8140 case target_mem_ref461_K:
8142 const auto tmr = GetPointerS<target_mem_ref461>(curr_tn);
8163 case gimple_pragma_K:
8169 case case_label_expr_K:
8174 case gimple_predict_K:
8177 case identifier_node_K:
8178 case namespace_decl_K:
8179 case statement_list_K:
8181 case translation_unit_decl_K:
8182 case template_decl_K:
8187 case gimple_while_K:
8206 if(!
sl->list_of_stmt.empty())
8210 else if(!
sl->list_of_bloc.empty())
8212 auto bb_number =
sl->list_of_bloc.size();
8230 for(
const auto& lob_it :
sl->list_of_bloc)
8234 single_bb = lob_it.second;
8238 if(!single_bb->CGetStmtList().empty())
8240 const auto stmt_number = single_bb->CGetStmtList().size();
8245 const auto& single_stmt = single_bb->CGetStmtList().front();
8246 const auto gr = GetPointer<const gimple_return>(
GET_CONST_NODE(single_stmt));
8281 const auto co = GetPointerS<const constructor>(tn);
8284 for(
const auto& iv : co->list_of_idx_valu)
8291 required.emplace_back(tn->index, 0);
8306 required.emplace_back(tn->index, 0);
8309 case gimple_while_K:
8311 const auto we = GetPointerS<const gimple_while>(tn);
8317 const auto be = GetPointerS<const binary_expr>(tn);
8319 if(tn->get_kind() != assert_expr_K)
8327 const auto ue = GetPointerS<const unary_expr>(tn);
8328 if(tn->get_kind() == addr_expr_K )
8330 required.emplace_back(tn->index, 0);
8340 if(tn_kind == component_ref_K)
8342 const auto cr = GetPointerS<const component_ref>(tn);
8346 else if(tn_kind == bit_field_ref_K)
8348 const auto te = GetPointerS<const ternary_expr>(tn);
8353 else if(tn_kind == obj_type_ref_K || tn_kind == save_expr_K || tn_kind == vtable_ref_K ||
8354 tn_kind == with_cleanup_expr_K)
8356 THROW_ERROR(
"Operation not yet supported: " + std::string(tn->get_kind_text()));
8360 const auto te = GetPointerS<const ternary_expr>(tn);
8369 const auto le = GetPointerS<const lut_expr>(tn);
8404 const auto gc = GetPointerS<const gimple_cond>(tn);
8408 case gimple_switch_K:
8410 const auto se = GetPointerS<const gimple_switch>(tn);
8414 case gimple_multi_way_if_K:
8416 const auto gmwi = GetPointerS<const gimple_multi_way_if>(tn);
8417 for(
const auto& cond : gmwi->list_of_cond)
8428 const auto ar = GetPointerS<const array_ref>(tn);
8433 case target_mem_ref_K:
8435 const auto tmr = GetPointerS<const target_mem_ref>(tn);
8442 required.emplace_back(0, 0);
8450 required.emplace_back(0, 0);
8458 required.emplace_back(0, 0);
8466 required.emplace_back(0, 0);
8474 required.emplace_back(0, 0);
8478 case target_mem_ref461_K:
8480 const auto tmr = GetPointerS<const target_mem_ref461>(tn);
8487 required.emplace_back(0, 0);
8495 required.emplace_back(0, 0);
8503 required.emplace_back(0, 0);
8511 required.emplace_back(0, 0);
8519 required.emplace_back(0, 0);
8523 case gimple_assign_K:
8525 const auto gm = GetPointerS<const gimple_assign>(tn);
8526 if(!gm->init_assignment && !gm->clobber)
8531 if(op0_kind == component_ref_K || op0_kind == indirect_ref_K || op0_kind == misaligned_indirect_ref_K ||
8532 op0_kind == mem_ref_K || op0_kind == array_ref_K || op0_kind == target_mem_ref_K ||
8533 op0_kind == target_mem_ref461_K || op0_kind == bit_field_ref_K)
8540 bool is_a_vector_bitfield =
false;
8541 if(op1_kind == bit_field_ref_K)
8543 const auto bfr = GetPointerS<const bit_field_ref>(
GET_CONST_NODE(gm->op1));
8546 is_a_vector_bitfield =
true;
8549 if(op1_kind == component_ref_K || op1_kind == indirect_ref_K || op1_kind == misaligned_indirect_ref_K ||
8550 op1_kind == mem_ref_K || op1_kind == array_ref_K || op1_kind == target_mem_ref_K ||
8551 op1_kind == target_mem_ref461_K || (op1_kind == bit_field_ref_K && !is_a_vector_bitfield))
8553 required.emplace_back(0, 0);
8564 case gimple_return_K:
8566 const auto rt = GetPointerS<const gimple_return>(tn);
8575 const auto gp = GetPointerS<const gimple_phi>(tn);
8576 for(
const auto& def_edge : gp->CGetDefEdgesList())
8583 case gimple_label_K:
8586 case gimple_pragma_K:
8593 case aggr_init_expr_K:
8595 const auto ce = GetPointerS<const call_expr>(tn);
8596 for(
const auto&
arg : ce->args)
8604 const auto ce = GetPointerS<const gimple_call>(tn);
8608 const auto ue = GetPointerS<const unary_expr>(
GET_CONST_NODE(ce->fn));
8614 fd = GetPointerS<const function_decl>(
GET_CONST_NODE(temp_node));
8618 for(
const auto&
arg : ce->args)
8627 auto tl = GetPointerS<const tree_list>(tn);
8628 std::list<const tree_list*> tl_list;
8631 tl_list.push_back(tl);
8632 tl = tl->chan ? GetPointer<const tree_list>(
GET_CONST_NODE(tl->chan)) :
nullptr;
8634 for(
const auto tl_current0 : tl_list)
8642 const auto fd = GetPointerS<const field_decl>(tn);
8644 "non-constant field offset (variable lenght object) currently not supported: " +
8648 required.emplace_back(0, static_cast<unsigned int>(ull_value / 8));
8649 if(ull_value % 8 != 0)
8651 THROW_ERROR(
"bitfields are not yet supported: " + fd->ToString());
8657 const auto ga = GetPointerS<const gimple_asm>(tn);
8664 case array_range_ref_K:
8667 case case_label_expr_K:
8669 case function_decl_K:
8670 case identifier_node_K:
8671 case namespace_decl_K:
8672 case statement_list_K:
8674 case translation_unit_decl_K:
8675 case template_decl_K:
8684 case gimple_predict_K:
8688 THROW_ERROR(
"Operation not yet supported: " + std::string(tn->get_kind_text()));
8700 case tree_reindex_K:
8712 case gimple_assign_K:
8715 case gimple_label_K:
8717 case gimple_predict_K:
8725 case gimple_multi_way_if_K:
8727 case gimple_pragma_K:
8728 case gimple_return_K:
8729 case gimple_switch_K:
8730 case gimple_while_K:
8737 case aggr_init_expr_K:
8738 case case_label_expr_K:
8740 case identifier_node_K:
8742 case statement_list_K:
8744 case target_mem_ref_K:
8745 case target_mem_ref461_K:
8750 case placeholder_expr_K:
8777 const auto fd = GetPointer<const function_decl>(tn);
8779 THROW_ASSERT(fd->body,
"Function " + fd->ToString() +
" is without body");
8780 const auto sl = GetPointer<const statement_list>(
GET_NODE(fd->body));
8781 size_t ret_value = 0;
8782 for(
const auto&
block : sl->list_of_bloc)
8784 ret_value +=
block.second->CGetStmtList().size();
8785 ret_value +=
block.second->CGetPhiList().size();
8793 const auto gasm = GetPointer<const gimple_asm>(tn);
8801 const auto ga = GetPointer<const gimple_assign>(tn);
8807 auto store_candidate = op0_kind == bit_field_ref_K || op0_kind == component_ref_K || op0_kind == indirect_ref_K ||
8808 op0_kind == misaligned_indirect_ref_K || op0_kind == mem_ref_K || op0_kind == array_ref_K ||
8809 op0_kind == target_mem_ref_K || op0_kind == target_mem_ref461_K ||
8810 fun_mem_data.count(ga->op0->index);
8811 if(op0_kind == realpart_expr_K || op0_kind == imagpart_expr_K)
8813 const auto op = GetPointerS<const unary_expr>(
GET_CONST_NODE(ga->op0))->op;
8815 if(code0 == bit_field_ref_K || code0 == component_ref_K || code0 == indirect_ref_K ||
8816 code0 == misaligned_indirect_ref_K || code0 == mem_ref_K || code0 == array_ref_K ||
8817 code0 == target_mem_ref_K || code0 == target_mem_ref461_K)
8819 store_candidate =
true;
8821 if(code0 == var_decl_K && fun_mem_data.count(op->index))
8823 store_candidate =
true;
8830 const auto vc = GetPointerS<const view_convert_expr>(
GET_CONST_NODE(ga->op1));
8831 if(op0_type->get_kind() == record_type_K || op0_type->get_kind() == union_type_K)
8833 store_candidate =
true;
8836 if(vc_op_type->get_kind() == vector_type_K && op0_type->get_kind() == array_type_K)
8838 store_candidate =
true;
8841 return store_candidate;
8847 const auto ga = GetPointer<const gimple_assign>(tn);
8853 bool is_a_vector_bitfield =
false;
8855 if(op1_kind == bit_field_ref_K)
8857 const auto bfr = GetPointerS<const bit_field_ref>(
GET_CONST_NODE(ga->op1));
8860 is_a_vector_bitfield =
true;
8863 auto load_candidate = (op1_kind == bit_field_ref_K && !is_a_vector_bitfield) || op1_kind == component_ref_K ||
8864 op1_kind == indirect_ref_K || op1_kind == misaligned_indirect_ref_K || op1_kind == mem_ref_K ||
8865 op1_kind == array_ref_K || op1_kind == target_mem_ref_K || op1_kind == target_mem_ref461_K ||
8866 fun_mem_data.count(ga->op1->index);
8867 if(op1_kind == realpart_expr_K || op1_kind == imagpart_expr_K)
8869 const auto op = GetPointerS<const unary_expr>(
GET_CONST_NODE(ga->op1))->op;
8871 if((code1 == bit_field_ref_K && !is_a_vector_bitfield) || code1 == component_ref_K || code1 == indirect_ref_K ||
8872 code1 == bit_field_ref_K || code1 == misaligned_indirect_ref_K || code1 == mem_ref_K || code1 == array_ref_K ||
8873 code1 == target_mem_ref_K || code1 == target_mem_ref461_K)
8875 load_candidate =
true;
8877 if(code1 == var_decl_K && fun_mem_data.count(op->index))
8879 load_candidate =
true;
8883 if(op1_kind == view_convert_expr_K)
8885 const auto vc = GetPointerS<const view_convert_expr>(
GET_CONST_NODE(ga->op1));
8887 if(vc_op_type->get_kind() == record_type_K || vc_op_type->get_kind() == union_type_K)
8889 load_candidate =
true;
8892 if(vc_op_type->get_kind() == array_type_K && op0_type->get_kind() == vector_type_K)
8894 load_candidate =
true;
8897 return load_candidate;
8903 const auto ga = GetPointer<const gimple_assign>(tn);
8909 return op1->get_kind() == lut_expr_K;
8917 for(
const auto& stmt :
block.second->CGetStmtList())
8919 const auto gp = GetPointer<const gimple_pragma>(
GET_NODE(stmt));
8920 if(gp && gp->scope && GetPointer<const omp_pragma>(
GET_NODE(gp->scope)))
8922 const auto sp = GetPointer<const omp_simd_pragma>(
GET_NODE(gp->directive));
#define GET_NODE(t)
Macro used to hide implementation details when accessing a tree_node from another tree_node...
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) ...
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.
integer_cst_t value
The value of the integer cast.
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.
void check_lib_type(const tree_nodeRef &var)
Check if variable is defined in a c system library header; if yes adds its type to library type...
static bool IsComplexType(const tree_nodeConstRef &type)
Return if treenode is a complex.
static bool is_a_nop_function_decl(const function_decl *fd)
#define INDENT_DBG_MEX(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed;.
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 ...
File containing functions and utilities to support the printing of debug messagges.
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.
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.
std::string ToString() const
Print this node as string in gimple format.
static bool IsConstant(const tree_nodeConstRef &node)
Return if a tree node is a constant object.
#define CASE_BINARY_EXPRESSION
This macro collects all case labels for binary_expr objects.
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.
const tree_nodeRef CGetTreeReindex(const unsigned int i) const
Return a tree_reindex wrapping the i-th tree_node.
static unsigned int get_var_alignment(const tree_managerConstRef &TM, unsigned int var)
Return the var alignment.
tree_nodeRef get_base(size_t i) const
return the i-th element of baseinfo
char base
This version is stamped on May 10, 2016.
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.
tree_nodeRef name
name field contains an identifier_node used to represent a name.
const std::vector< std::string > SplitString(const std::string &input, const std::string &separators)
Function which splits a string into tokens.
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...
#define CASE_DECL_NODES
NOTE that cast_expr is a unary expression but it could not be included in the CASE_UNARY_EXPRESSION b...
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.
mathematical utility function not provided by standard libraries
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 std::string GetString(const enum kind k)
Given a kind, return the corresponding string.
static tree_nodeConstRef CGetElements(const tree_nodeConstRef &type)
Given an array or a vector return the element type.
tree_nodeRef refd
refd field references to the node for the type referenced to.
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.
tree_nodeRef mngl
mngl field contains the name of the object as the assembler will see it.
exceptions managed by PandA
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.
A simple interface to token object of the raw files.
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.
std::map< unsigned int, blocRef > list_of_bloc
list_of_bloc field is the list of basic block. If this field is null then the list_of_stmt field is n...
static const unsigned int EXIT_BLOCK_ID
constant identifying the exit basic block
tree_nodeRef base
BASE register.
#define GET_INDEX_NODE(t)
Macro used to hide implementation details when accessing a tree_node from another tree_node...
static std::string print_function_name(const tree_managerConstRef &TM, const function_decl *fd)
Return the name of the function in a string.
struct definition of the function_type tree node.
struct definition of the parm_decl tree node.
Data structure describing a basic block at tree level.
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)
CustomOrderedSet< TreeVocabularyTokenTypes_TokenEnum > list_attr
list of TOKEN, represented as int, associated to the tree_node
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.
const tree_nodeConstRef CGetTreeNode(const unsigned int i) const
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.
bool builtin_flag
flag true when the function is a builtin
static std::string GetMangledFunctionName(const function_decl *fd)
Return the mangled function name.
virtual enum kind get_kind() const =0
Virtual function returning the type of the actual class.
#define STR(s)
Macro which performs a lexical_cast to a string.
Auxiliary methods for manipulating string.
static bool IsVariableType(const tree_nodeConstRef &node)
Return true if the treenode is a valid variable.
struct definition of the label_decl tree node.
static std::string GetTemplateTypeName(const tree_nodeConstRef &type)
Return the name of template without parameters.
bw_t minBitwidth(bool sign) const
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.
const std::string TI_getTokenName(const TreeVocabularyTokenTypes_TokenEnum i)
Return the name associated with the token.
static bool IsUnsignedIntegerType(const tree_nodeConstRef &type)
Return true if the treenode is of unsigned integer type.
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.
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.
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached
virtual std::string get_kind_text() const =0
Virtual function returning the name of the actual class.
bool is_top_function(const function_decl *fd) const
is_top_function checks if a function is one of the application top functions.
size_t get_baseinfo_size() const
return the size of baseinfo vector
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 void getBuiltinFieldTypes(const tree_nodeConstRef &_type, std::list< tree_nodeConstRef > &listOfTypes, CustomUnorderedSet< unsigned int > &already_visited)
static unsigned long long Size(const tree_nodeConstRef &tn)
Return the size of a tree object.
static bool same_size_fields(const tree_nodeConstRef &t)
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.
tree_nodeRef type
type field is the actual data type node being inherited in this basetype.(BINFO_TYPE) ...
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.
#define CASE_QUATERNARY_EXPRESSION
This macro collects all case labels for quaternary_expr objects.
#define CASE_UNARY_EXPRESSION
This macro collects all case labels for unary_expr objects.
static bool is_virtual(const tree_managerConstRef &TM, const unsigned int index)
return true in case the ssa_name is virtual
static std::string sign_reduce_bitstring(std::string bitstring, bool bitstring_is_signed)
function slightly different than BitLatticeManipulator::sign_reduce_bitstring
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.
const unsigned int index
Represent the index read from the raw file and the index-1 of the vector of tree_node associated to t...
static bool IsFunctionType(const tree_nodeConstRef &type)
Return true if the treenode is of type function type.
Low-level memory addressing.
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.
tree_nodeRef body
body field is the saved representation of the body of the entire function.
static std::string return_qualifier_prefix(const TreeVocabularyTokenTypes_TokenEnum quals)
return the prefix given a qualifier
static bool IsVectorType(const tree_nodeConstRef &type)
Return true if the treenode is a vector.
tree_nodeRef base
BASE register.
static std::string GetRecordTypeName(const tree_nodeConstRef &type)
Return the name of the class.
unsigned int get_implementation_node(unsigned int decl_node) const
Return the index of function_decl node that implements the declaration node.
#define GET_CONST_NODE(t)
serialization get_serialization(const std::string &name) const
Return which type of serialization the given function must have.
refcount< const tree_node > tree_nodeConstRef
Classes specification of the tree_node data structures.
static std::string NormalizeTypename(const std::string &id)
Return normalized name of types and variables.
struct definition of the field attr on function_decl, field_decl, var_decl tree node.
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.
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
static bool has_omp_simd(const statement_list *sl)
Check if omp simd pragmas are present in given statement list.
struct definition of the pointer_type tree node.
static size_t AllocatedMemorySize(const tree_nodeConstRef ¶meter)
Compute the memory (in bytes) to be allocated to store a parameter or a variable. ...
This struct specifies the block node.
#define CASE_TYPE_NODES
This macro collects all case labels for type objects.
This file collects some utility functions.
static unsigned int GetRealType(const tree_managerConstRef &TM, unsigned int index)
Return the real type.
static tree_nodeConstRef check_for_simple_pointer_arithmetic(const tree_nodeConstRef &node)
() label_decl()() modop_expr() new_expr() placeholder_expr() type_node
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
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.
struct definition of the reference_type tree node.
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.
#define CASE_CST_NODES
This macro collects all case labels for cast nodes.
struct definition of the type node structures.
FunctionExpander()
Constructor.
Class specification of the tree_reindex support class.
static const unsigned int ENTRY_BLOCK_ID
constant identifying the entry basic block
#define CASE_FAKE_NODES
This macro collects all case labels for fake or empty nodes.
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
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.
#define THROW_ERROR_CODE(code, str_expr)
helper function used to throw an error with a code error
static bool is_extern(const tree_managerConstRef &TM, const unsigned int index)
FIXME: to be remove after substitution with IsExternDeclaration.
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.
tree_nodeRef type
type field holds the data type of the object, when relevant.
static tree_nodeConstRef CGetPointedType(const tree_nodeConstRef &pointer)
Return the pointed type of a pointer object.
#define DEBUG_LEVEL_PARANOIC
paranoid level debugging print is performed.
Classes specification of the tree_node data structures not present in the gcc.
#define CASE_CPP_NODES
This macro collects all case labels for cpp nodes.
Low-level memory addressing.
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.
refcount< tree_node > tree_nodeRef
RefCount type definition of the tree_node class structure.
void rect(int left, int top, int right, int bottom, unsigned int color)
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.
unsigned counter[N_THREADS]
#define CASE_GIMPLE_NODES
This macro collects all cases labels for gimple nodes.
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.
virtual bool operator()(const tree_nodeRef &t) const
check membership to c library function
static bool IsAligned(const tree_managerConstRef &TM, unsigned int type)
Return true if type has not default alignment.
#define GET_INDEX_CONST_NODE(t)
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.
tree_nodeRef type
type field is the type of the node
static bool is_constant(const tree_managerConstRef &TM, const unsigned int index)
Return if a tree node is a constant object.
bool is_transparent(const std::string &name) const
Return if function has to be considered transparent even if we haven't body.
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;.
tree_nodeRef symbol
static or global variable
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 IsPositiveIntegerValue(const tree_nodeConstRef &type)
Return true if the treenode is a ssa_name greater or equal to zero.
#define CASE_TERNARY_EXPRESSION
This macro collects all case labels for ternary_expr objects.
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.
Class specification of the manager of the tree structures extracted from the raw file.
static unsigned long long GetArrayTotalSize(const tree_nodeConstRef &node)
Return the total number of elements of the the base type in the array.
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.
#define CASE_PRAGMA_NODES
This macro collects all case labels for pragma objects.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...