64 #include <boost/range/adaptor/reversed.hpp> 71 #define TREE_NOT_YET_IMPLEMENTED(token) THROW_ERROR(std::string("field not yet supported ") + STOK(token)) 78 reuse(_parameters->IsParameter(
"reuse_gimple") ? _parameters->GetParameter<
bool>(
"reuse_gimple") :
true),
80 debug_level(_parameters->get_class_debug_level(
GET_CLASS(*this)))
102 const std::string&
srcp,
kind operation_kind)
const 107 THROW_ASSERT(!srcp.empty(),
"It requires a non empty string");
110 switch(operation_kind)
120 case aggr_init_expr_K:
121 case case_label_expr_K:
123 case identifier_node_K:
125 case statement_list_K:
127 case target_mem_ref_K:
128 case target_mem_ref461_K:
144 THROW_ERROR(
"The operation given is not a unary expression");
154 case type_pack_expansion_K:
156 case enumeral_type_K:
157 case function_type_K:
163 case qual_union_type_K:
166 case reference_type_K:
168 case template_type_parm_K:
169 case type_argument_pack_K:
170 case typename_type_K:
180 case aggr_init_expr_K:
181 case case_label_expr_K:
183 case identifier_node_K:
185 case statement_list_K:
187 case target_mem_ref_K:
188 case target_mem_ref461_K:
208 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
219 GET_NODE(return_tree_reindex)->get_kind_text() +
")");
221 return return_tree_reindex;
228 kind operation_kind)
const 234 THROW_ASSERT(!srcp.empty(),
"It requires a non empty string");
237 switch(operation_kind)
246 case aggr_init_expr_K:
247 case case_label_expr_K:
249 case identifier_node_K:
251 case statement_list_K:
253 case target_mem_ref_K:
254 case target_mem_ref461_K:
270 THROW_ERROR(
"The operation given is not a binary expression");
280 case type_pack_expansion_K:
282 case enumeral_type_K:
283 case function_type_K:
289 case qual_union_type_K:
292 case reference_type_K:
294 case template_type_parm_K:
295 case typename_type_K:
296 case type_argument_pack_K:
306 case aggr_init_expr_K:
307 case case_label_expr_K:
309 case identifier_node_K:
311 case statement_list_K:
313 case target_mem_ref_K:
314 case target_mem_ref461_K:
334 if(operation_kind == eq_expr_K || operation_kind == ne_expr_K || operation_kind == lt_expr_K ||
335 operation_kind == le_expr_K || operation_kind == gt_expr_K || operation_kind == ge_expr_K ||
336 operation_kind == ltgt_expr_K || operation_kind == truth_and_expr_K || operation_kind == truth_andif_expr_K ||
337 operation_kind == truth_or_expr_K || operation_kind == truth_orif_expr_K || operation_kind == truth_xor_expr_K)
344 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
365 const std::string&
srcp,
kind operation_kind)
const 372 THROW_ASSERT(!srcp.empty(),
"It requires a non empty string");
375 switch(operation_kind)
384 case aggr_init_expr_K:
385 case case_label_expr_K:
387 case identifier_node_K:
389 case statement_list_K:
391 case target_mem_ref_K:
392 case target_mem_ref461_K:
408 THROW_ERROR(
"The operation given is not a ternary expression");
418 case type_pack_expansion_K:
420 case enumeral_type_K:
421 case function_type_K:
427 case qual_union_type_K:
430 case reference_type_K:
432 case template_type_parm_K:
433 case typename_type_K:
434 case type_argument_pack_K:
444 case aggr_init_expr_K:
445 case case_label_expr_K:
447 case identifier_node_K:
449 case statement_list_K:
451 case target_mem_ref_K:
452 case target_mem_ref461_K:
472 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
476 if(operation_kind == cond_expr_K)
509 kind operation_kind)
const 517 THROW_ASSERT(!srcp.empty(),
"It requires a non empty string");
520 switch(operation_kind)
529 case aggr_init_expr_K:
530 case case_label_expr_K:
532 case identifier_node_K:
534 case statement_list_K:
536 case target_mem_ref_K:
537 case target_mem_ref461_K:
553 THROW_ERROR(
"The operation given is not a quaternary expression");
562 case type_pack_expansion_K:
564 case enumeral_type_K:
565 case function_type_K:
571 case qual_union_type_K:
574 case reference_type_K:
576 case template_type_parm_K:
577 case typename_type_K:
578 case type_argument_pack_K:
588 case aggr_init_expr_K:
589 case case_label_expr_K:
591 case identifier_node_K:
593 case statement_list_K:
595 case target_mem_ref_K:
596 case target_mem_ref461_K:
616 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
640 const std::string&
srcp)
const 645 THROW_ASSERT(!op2 || op2->
get_kind() == tree_reindex_K,
"Operand 2 node is not a tree reindex");
646 THROW_ASSERT(!op3 || op3->
get_kind() == tree_reindex_K,
"Operand 3 node is not a tree reindex");
647 THROW_ASSERT(!op4 || op4->
get_kind() == tree_reindex_K,
"Operand 4 node is not a tree reindex");
648 THROW_ASSERT(!op5 || op5->
get_kind() == tree_reindex_K,
"Operand 5 node is not a tree reindex");
649 THROW_ASSERT(!op6 || op6->
get_kind() == tree_reindex_K,
"Operand 6 node is not a tree reindex");
650 THROW_ASSERT(!op7 || op7->
get_kind() == tree_reindex_K,
"Operand 7 node is not a tree reindex");
651 THROW_ASSERT(!op8 || op8->
get_kind() == tree_reindex_K,
"Operand 8 node is not a tree reindex");
652 THROW_ASSERT(!srcp.empty(),
"It requires a non empty string");
653 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
699 const std::string&
srcp)
const 704 THROW_ASSERT(!srcp.empty(),
"It requires a non empty string");
705 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
725 const unsigned int integer_cst_nid)
const 729 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
748 THROW_ASSERT(!strg.empty(),
"It requires a non empty string");
751 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
755 unsigned int node_nid = this->
TreeM->
find(identifier_node_K, IR_schema);
782 bool artificial_flag,
int use_tmpl,
bool static_static_flag,
bool extern_flag,
bool static_flag,
bool register_flag,
783 bool readonly_flag,
const std::string& bit_values,
bool addr_taken,
bool addr_not_taken)
const 790 THROW_ASSERT(!srcp.empty(),
"It requires a non empty string");
798 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
851 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
853 unsigned int translation_unit_decl_nid = this->
TreeM->
find(translation_unit_decl_K, IR_schema);
854 if(!translation_unit_decl_nid)
861 GET_NODE(translation_unit_decl_node)->get_kind_text() +
")");
868 GET_NODE(translation_unit_decl_node)->get_kind_text() +
")");
870 return translation_unit_decl_node;
877 const std::string&
srcp,
unsigned int algn,
878 bool artificial_flag)
const 885 THROW_ASSERT(!srcp.empty(),
"It requires a non empty string");
893 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
937 const std::string&
srcp,
int used,
bool register_flag,
938 bool readonly_flag)
const 944 THROW_ASSERT(!srcp.empty(),
"It requires a non empty string");
946 const auto tn = GetPointer<const type_node>(
GET_CONST_NODE(type));
953 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
990 "Created node " +
STR(node_nid) +
" (" +
GET_CONST_NODE(node_ref)->get_kind_text() +
")");
1004 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
1009 unsigned int void_type_nid = this->
TreeM->
find(void_type_K, IR_schema);
1033 GET_NODE(void_node)->get_kind_text() +
" void)");
1040 GET_NODE(void_node)->get_kind_text() +
" void)");
1055 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
1066 unsigned int bit_size_type_nid = this->
TreeM->
find(integer_type_K, IR_schema);
1069 if(!bit_size_type_nid)
1087 GET_NODE(bit_size_node)->get_kind_text() +
" bit_size)");
1103 GET_NODE(bit_size_node)->get_kind_text() +
" bit_size)");
1105 return bit_size_node;
1122 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
1133 unsigned int size_type_nid = this->
TreeM->
find(integer_type_K, IR_schema);
1154 GET_NODE(size_node)->get_kind_text() +
" bit_size)");
1167 GET_NODE(size_node)->get_kind_text() +
" bit_size)");
1186 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
1190 unsigned int type_decl_nid = this->
TreeM->
find(type_decl_K, IR_schema);
1204 "Created node " +
STR(type_decl_nid) +
" (type_decl boolean)");
1215 GET_NODE(boolean_type_node)->get_kind_text() +
" boolean)");
1223 unsigned int boolean_type_nid = this->
TreeM->
find(boolean_type_K, IR_schema);
1225 if(!boolean_type_nid)
1233 GET_NODE(boolean_type_node)->get_kind_text() +
" boolean)");
1235 return boolean_type_node;
1249 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
1260 unsigned int type_decl_nid = this->
TreeM->
find(type_decl_K, IR_schema);
1277 "Created node " +
STR(type_decl_nid) +
" (type_decl unsigned_int)");
1293 GET_NODE(integer_type_node)->get_kind_text() +
" unsigned_int)");
1307 unsigned int integer_type_nid = this->
TreeM->
find(integer_type_K, IR_schema);
1309 if(!integer_type_nid)
1317 GET_NODE(integer_type_node)->get_kind_text() +
" unsigned int)");
1319 return integer_type_node;
1324 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
1332 unsigned int type_decl_nid = this->
TreeM->
find(type_decl_K, IR_schema);
1347 "Created node " +
STR(type_decl_nid) +
" (type_decl unsigned_int)");
1361 GET_NODE(integer_type_node)->get_kind_text() +
" unsigned long long int int)");
1375 unsigned int integer_type_nid = this->
TreeM->
find(integer_type_K, IR_schema);
1380 GET_NODE(integer_type_node)->get_kind_text() +
" unsigned long long int)");
1382 return integer_type_node;
1397 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
1408 unsigned int type_decl_nid = this->
TreeM->
find(type_decl_K, IR_schema);
1442 GET_NODE(integer_type_node)->get_kind_text() +
" int)");
1457 unsigned int integer_type_nid = this->
TreeM->
find(integer_type_K, IR_schema);
1459 if(!integer_type_nid)
1468 GET_NODE(integer_type_node)->get_kind_text() +
" int)");
1470 return integer_type_node;
1479 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
1481 auto m64P =
parameters->getOption<std::string>(OPT_gcc_m32_mx32).find(
"-m64") != std::string::npos;
1490 unsigned int pointer_type_nid = this->
TreeM->
find(pointer_type_K, IR_schema);
1492 if(!pointer_type_nid)
1495 const auto size_node =
1504 "Created node " +
STR(pointer_type_nid) +
" (pointer_type)");
1510 return pointer_type_node;
1515 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
1522 unsigned int integer_type_nid =
TreeM->
find(integer_type_K, IR_schema);
1524 if(!integer_type_nid)
1545 if(
auto it_name = GetPointerS<integer_type>(
GET_NODE(integer_type_node))->name)
1547 if(
GET_NODE(it_name)->get_kind() == identifier_node_K)
1549 auto in = GetPointerS<identifier_node>(
GET_NODE(it_name));
1550 if(in->strg ==
"sizetype")
1552 in->strg =
"unsigned long";
1554 if(in->strg ==
"ssizetype")
1558 else if(in->strg ==
"bitsizetype")
1560 in->strg =
"unsigned long long int";
1562 else if(in->strg ==
"bit_size_type")
1564 in->strg =
"unsigned long long int";
1568 return integer_type_node;
1572 const std::vector<tree_nodeConstRef>& argsT)
const 1574 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
1577 unsigned int tree_list_node_nid = 0, prev_tree_list_node_nid = 0;
1578 for(
const auto& par_type : boost::adaptors::reverse(argsT))
1582 if(prev_tree_list_node_nid)
1588 prev_tree_list_node_nid = tree_list_node_nid;
1595 if(tree_list_node_nid)
1610 bool volatile_flag,
bool virtual_flag)
const 1613 "-->Creating ssa starting from var " + (var ? var->
ToString() :
"") +
" and type " +
1619 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
1650 if(var && GetPointerS<ssa_name>(curr_node)->CGetUseStmts().empty())
1654 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> gimple_nop_IR_schema;
1671 GetPointerS<ssa_name>(curr_node)->SetDefStmt(gimple_nop_node_ref);
1674 const auto sn = GetPointerS<ssa_name>(curr_node);
1675 sn->virtual_flag = virtual_flag;
1685 unsigned int function_decl_nid,
const std::string&
srcp)
const 1689 THROW_ASSERT(!srcp.empty(),
"It requires a non empty string");
1692 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
1713 unsigned int function_decl_nid,
const std::string&
srcp)
const 1723 const std::vector<tree_nodeRef>&
args,
1724 unsigned int function_decl_nid,
const std::string&
srcp)
const 1726 THROW_ASSERT(!srcp.empty(),
"It requires a non empty string");
1727 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> ae_IR_schema, gc_IR_schema;
1731 const auto formal_count = GetPointer<const function_decl>(
GET_CONST_NODE(called_function))->list_of_args.size();
1732 THROW_ASSERT(formal_count == args.size(),
"Formal parameters count different from actual parameters count: " +
1733 STR(formal_count) +
" != " +
STR(args.size()));
1739 std::string args_string;
1740 for(
const auto&
arg : args)
1742 if(!args_string.empty())
1746 args_string +=
STR(
arg->index);
1767 const std::string&
srcp)
const 1771 THROW_ASSERT(!srcp.empty(),
"It requires a non empty string");
1774 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
1797 unsigned int function_decl_nid,
const std::string&
srcp)
const 1799 THROW_ASSERT(!srcp.empty(),
"It requires a non empty string");
1801 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
1823 "Created node " +
STR(node_nid) +
" (" +
GET_NODE(node_ref)->get_kind_text() +
")");
1834 const std::vector<std::pair<tree_nodeRef, unsigned int>>& list_of_def_edge,
1835 unsigned int function_decl_nid,
bool virtual_flag)
const 1837 auto iterator = list_of_def_edge.begin();
1839 auto* sn_ref = GetPointer<ssa_name>(
GET_NODE(ssa_ref));
1840 THROW_ASSERT(ssa_ref->
get_kind() == tree_reindex_K,
"ssa_name res is not a tree_reindex node");
1841 for(++iterator; iterator != list_of_def_edge.end(); ++iterator)
1845 if(!sn_ref && GetPointer<ssa_name>(
GET_NODE(tn)))
1848 sn_ref = GetPointer<ssa_name>(
GET_NODE(ssa_ref));
1853 ssa_res =
create_ssa_name(sn_ref->var, sn_ref->type, sn_ref->min, sn_ref->max,
false, virtual_flag);
1864 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
1871 auto* pn = GetPointer<gimple_phi>(
GET_NODE(phi_stmt));
1872 pn->virtual_flag = virtual_flag;
1874 for(
const auto& def_edge : list_of_def_edge)
1882 pn->AddDefEdge(
TreeM, def_edge);
1896 std::vector<unsigned int> predecessors,
1897 std::vector<unsigned int> successors, std::vector<tree_nodeRef> stmt,
1898 unsigned int number,
unsigned int true_edge,
unsigned int false_edge,
1899 std::vector<tree_nodeRef>
phi)
const 1902 blocRef new_bb = blocRef(
new bloc(number));
1904 list_of_bloc[new_bb->number] = new_bb;
1909 new_bb->true_edge = true_edge;
1911 new_bb->false_edge = false_edge;
1914 " True Edge: " +
STR(new_bb->true_edge) +
" False Edge: " +
STR(new_bb->false_edge));
1917 for(
auto pred : predecessors)
1919 new_bb->list_of_pred.push_back(pred);
1923 for(
auto suc : successors)
1925 new_bb->list_of_succ.push_back(suc);
1929 for(
const auto& tn : stmt)
1931 new_bb->PushBack(tn,
AppM);
1937 for(
const auto& tn : phi)
1951 for(
const auto& tn : stmts)
1961 bb->PushBack(stmt,
AppM);
1970 for(
auto successor : successors)
1979 bb->add_succ(successor);
1985 for(
auto predecessor : predecessors)
1994 bb->add_pred(predecessor);
2000 for(
auto successor : successors)
2009 std::vector<unsigned int>& list_of_succ = bb->list_of_succ;
2010 auto iterator_stmt = std::find(list_of_succ.begin(), list_of_succ.end(), successor);
2011 THROW_ASSERT(iterator_stmt != list_of_succ.end(),
"Successor not found!");
2013 "Successor " +
STR(*iterator_stmt) +
" is going to be removed");
2014 list_of_succ.erase(iterator_stmt);
2020 for(
auto predecessor : predecessors)
2029 std::vector<unsigned int>& list_of_pred = bb->list_of_pred;
2030 auto iterator_stmt = std::find(list_of_pred.begin(), list_of_pred.end(), predecessor);
2031 THROW_ASSERT(iterator_stmt != list_of_pred.end(),
"Successor not found!");
2033 "Successor " +
STR(*iterator_stmt) +
" is going to be removed");
2034 list_of_pred.erase(iterator_stmt);
2040 bb->list_of_pred.erase(bb->list_of_pred.begin(), bb->list_of_pred.end());
2046 bb->list_of_succ.erase(bb->list_of_succ.begin(), bb->list_of_succ.end());
2052 bb->false_edge = false_edge_index;
2058 bb->true_edge = true_edge_index;
2063 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
2066 if(!block->CGetStmtList().empty())
2068 tree_nodeRef first_stmt = block->CGetStmtList().front();
2069 auto* le = GetPointer<gimple_label>(
GET_NODE(first_stmt));
2073 "label expression pattern not yet supported");
2074 auto* ld = GetPointer<label_decl>(
GET_NODE(le->op));
2078 unsigned int label_decl_name_nid_test;
2082 label_decl_name_nid_test =
TreeM->
find(identifier_node_K, IR_schema);
2083 }
while(label_decl_name_nid_test);
2088 ld->name = tr_new_label_name;
2089 ld->artificial_flag =
false;
2096 unsigned int type_decl_name_nid =
TreeM->
find(identifier_node_K, IR_schema);
2097 if(!type_decl_name_nid)
2105 unsigned int label_decl_name_nid_test;
2109 label_decl_name_nid_test =
TreeM->
find(identifier_node_K, IR_schema);
2110 }
while(label_decl_name_nid_test);
2118 unsigned int label_void_type_name_nid =
TreeM->
find(type_decl_K, IR_schema);
2119 unsigned int label_type_nid;
2120 if(!label_void_type_name_nid)
2138 label_type_nid =
TreeM->
find(void_type_K, IR_schema);
2155 "somenthing of wrong happen");
2181 GetPointer<gimple_node>(
GET_NODE(tr_new_stmt))->bb_index = block->number;
2182 block->PushFront(tr_new_stmt,
AppM);
2185 std::string raw_file_name =
STR(nid++) +
"create_label.raw";
2186 std::ofstream raw_file(raw_file_name.c_str());
2193 const unsigned int label_expr_nid)
const 2201 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
2205 unsigned int type_decl_name_nid =
TreeM->
find(identifier_node_K, IR_schema);
2206 if(!type_decl_name_nid)
2216 unsigned int label_void_type_name_nid =
TreeM->
find(type_decl_K, IR_schema);
2217 unsigned int label_type_nid;
2218 if(!label_void_type_name_nid)
2236 label_type_nid =
TreeM->
find(void_type_K, IR_schema);
2253 "somenthing of wrong happen");
2269 GetPointer<gimple_node>(
GET_NODE(tr_new_stmt))->bb_index = block->number;
2270 block->PushBack(tr_new_stmt,
AppM);
2274 const std::vector<tree_nodeConstRef>& argsT,
2276 bool with_body)
const 2285 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
2288 unsigned int function_name_id =
TreeM->
find(identifier_node_K, IR_schema);
2289 if(!function_name_id)
2307 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> statement_list_schema;
2317 auto fd = GetPointerS<function_decl>(
GET_NODE(function_decl_res));
2318 unsigned int Pindex = 0;
2319 for(
const auto& par_type : argsT)
2321 const auto p_name =
"_P" +
STR(Pindex);
2330 fd->undefined_flag =
true;
2333 return function_decl_res;
2338 unsigned int function_decl_nid)
const 2342 for(
const auto& statement : block->CGetStmtList())
2344 const auto ga = GetPointer<const gimple_assign>(
GET_NODE(statement));
2347 const auto toe = GetPointer<const truth_or_expr>(
GET_NODE(ga->op1));
2348 if(toe and ((toe->op0->index == first_condition->
index and toe->op1->index == second_condition->
index) or
2349 (toe->op0->index == second_condition->
index and toe->op1->index == first_condition->
index)))
2352 auto ssa0 = GetPointerS<ssa_name>(
GET_NODE(ga->op0));
2353 ssa0->bit_values =
"U";
2360 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> ssa_schema, truth_or_expr_schema, gimple_assign_schema;
2374 block->PushBack(ga,
AppM);
2376 return GetPointer<gimple_assign>(
GET_NODE(ga))->op0;
2381 unsigned int function_decl_nid)
const 2385 for(
const auto& statement : block->CGetStmtList())
2387 const auto ga = GetPointer<const gimple_assign>(
GET_NODE(statement));
2390 const auto toe = GetPointer<const truth_and_expr>(
GET_NODE(ga->op1));
2391 if(toe and ((toe->op0->index == first_condition->
index and toe->op1->index == second_condition->
index) or
2392 (toe->op0->index == second_condition->
index and toe->op1->index == first_condition->
index)))
2395 auto ssa0 = GetPointerS<ssa_name>(
GET_NODE(ga->op0));
2396 ssa0->bit_values =
"U";
2402 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> ssa_schema, truth_and_expr_schema, gimple_assign_schema;
2416 block->PushBack(ga,
AppM);
2418 return GetPointer<gimple_assign>(
GET_NODE(ga))->op0;
2422 unsigned int function_decl_nid)
const 2426 for(
const auto& statement : block->CGetStmtList())
2428 const auto ga = GetPointer<const gimple_assign>(
GET_NODE(statement));
2431 const auto tne = GetPointer<const truth_not_expr>(
GET_NODE(ga->op1));
2432 if(tne and tne->op->index == condition->
index)
2435 auto ssa0 = GetPointerS<ssa_name>(
GET_NODE(ga->op0));
2436 ssa0->bit_values =
"U";
2442 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> ssa_schema, truth_not_expr_schema, gimple_assign_schema;
2455 block->PushBack(ga,
AppM);
2457 return GetPointer<gimple_assign>(
GET_NODE(ga))->op0;
2461 unsigned int function_decl_nid)
const 2466 const auto gc = GetPointer<const gimple_cond>(
GET_CONST_NODE(condition));
2469 (
GET_NODE(gc->op0)->get_kind() == ssa_name_K || GetPointer<const cst_node>(
GET_CONST_NODE(gc->op0)) !=
nullptr))
2472 "<--Condition already available as " + gc->op0->ToString());
2479 for(
const auto& statement : block->CGetStmtList())
2481 const auto ga = GetPointer<const gimple_assign>(
GET_CONST_NODE(statement));
2485 auto ssa0 = GetPointerS<ssa_name>(
GET_NODE(ga->op0));
2486 ssa0->bit_values =
"U";
2498 block->PushBack(ga,
AppM);
2515 const auto srcp_default = gc->include_name +
":" +
STR(gc->line_number) +
":" +
STR(gc->column_number);
2520 cond_op0, function_decl_nid, srcp_default);
2521 block->PushBack(op0_ga,
AppM);
2522 ret = GetPointerS<const gimple_assign>(
GET_CONST_NODE(op0_ga))->op0;
2531 unsigned int function_decl_nid)
const 2535 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> ne_schema, ga_schema;
2542 const auto ssa_operand = GetPointer<const ssa_name>(
GET_CONST_NODE(operand));
2543 const auto int_cst_operand = GetPointer<const integer_cst>(
GET_CONST_NODE(operand));
2544 if(!ssa_operand && !int_cst_operand)
2556 GetPointerS<ssa_name>(
GET_NODE(GetPointerS<gimple_assign>(
GET_NODE(ga))->op0))->use_set = ssa_operand->use_set;
2563 const auto int_signed_type = GetPointer<const integer_type>(signed_type);
2564 if(not int_signed_type)
2570 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> ut_schema;
2572 ut_schema[
TOK(
TOK_QUAL)] =
STR(static_cast<int>(int_signed_type->qual));
2573 const auto quals = int_signed_type->qual;
2584 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> min_schema;
2586 const auto find =
TreeM->
find(integer_cst_K, min_schema);
2598 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> max_schema;
2600 const auto find =
TreeM->
find(integer_cst_K, max_schema);
2612 const auto find =
TreeM->
find(integer_type_K, ut_schema);
2619 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> in_schema;
2620 if(int_signed_type->name)
2622 const auto type_name = GetPointer<const decl_node>(
GET_CONST_NODE(int_signed_type->name));
2628 if(type_name->include_name !=
"<built-in>")
2633 const auto in = GetPointer<identifier_node>(
GET_CONST_NODE(type_name->name));
2639 std::string unsigned_str =
"unsigned " + in->strg;
2641 auto find_in =
TreeM->
find(identifier_node_K, in_schema);
2657 unsigned int function_decl_nid)
const 2661 for(
const auto& statement : block->CGetStmtList())
2663 const auto ga = GetPointer<const gimple_assign>(
GET_NODE(statement));
2666 const auto ee = GetPointer<const eq_expr>(
GET_NODE(ga->op1));
2667 if(ee and ((ee->op0->index == first_operand->
index and ee->op1->index == second_operand->
index) or
2668 (ee->op0->index == second_operand->
index and ee->op1->index == first_operand->
index)))
2671 auto ssa0 = GetPointerS<ssa_name>(
GET_NODE(ga->op0));
2672 ssa0->bit_values =
"U";
2679 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> ssa_schema, eq_expr_schema, gimple_assign_schema;
2693 block->PushBack(ga,
AppM);
2695 return GetPointer<gimple_assign>(
GET_NODE(ga))->op0;
2699 const std::vector<tree_nodeRef>&
args,
const std::string&
srcp)
const 2701 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> ae_IR_schema, ce_IR_schema;
2709 std::string args_string;
2710 for(
const auto&
arg : args)
2712 if(!args_string.empty())
2716 args_string +=
STR(
arg->index);
2729 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> ae_IR_schema;
2735 auto vd = GetPointer<const var_decl>(tn);
2747 const std::string&
srcp)
const 2750 const auto ptr_type = GetPointer<addr_expr>(
GET_NODE(addr_tn))->
type;
2752 auto ga = GetPointer<gimple_assign>(
GET_NODE(assign_node));
2753 auto ssa = GetPointer<ssa_name>(
GET_NODE(ga->op0));
2764 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> IR_schema;
2768 auto vector_type_id =
TreeM->
find(vector_type_K, IR_schema);
2771 if(vector_type_id == 0)
2785 const auto fd = GetPointerS<const function_decl>(
GET_CONST_NODE(tn));
2813 std::vector<tree_nodeRef>
const*
args;
2814 if(
const auto gc = GetPointer<const gimple_call>(call_stmt))
2819 else if(
const auto ga = GetPointer<const gimple_assign>(call_stmt))
2821 const auto ce = GetPointer<const call_expr>(
GET_CONST_NODE(ga->op1));
2822 THROW_ASSERT(ce,
"Assign statement does not contain a function call: " +
STR(call_node));
2829 THROW_UNREACHABLE(
"Unsupported call statement: " + call_stmt->get_kind_text() +
" " +
STR(call_node));
2836 "Call statement should address a function declaration");
2838 const auto fd = GetPointer<function_decl>(
GET_NODE(caller_node));
2839 auto sl = GetPointerS<statement_list>(
GET_NODE(fd->body));
2840 const auto&
block = sl->list_of_bloc.at(GetPointer<const gimple_node>(call_stmt)->bb_index);
2841 const auto splitBBI = sl->list_of_bloc.rbegin()->first + 1;
2843 const auto splitBB = sl->list_of_bloc[splitBBI] = blocRef(
new bloc(splitBBI));
2844 splitBB->loop_id = block->loop_id;
2845 splitBB->SetSSAUsesComputed();
2846 THROW_ASSERT(!block->schedule,
"Inlining should not be allowed after scheduling");
2848 std::replace(block->list_of_pred.begin(), block->list_of_pred.end(), block->number, splitBB->number);
2849 splitBB->list_of_succ.assign(block->list_of_succ.cbegin(), block->list_of_succ.cend());
2850 block->list_of_succ.clear();
2851 splitBB->false_edge = block->false_edge;
2852 splitBB->true_edge = block->true_edge;
2853 block->false_edge = 0;
2854 block->true_edge = 0;
2856 for(
const auto& bbi : splitBB->list_of_succ)
2859 const auto& bb = sl->list_of_bloc.at(bbi);
2860 for(
const auto&
phi : bb->CGetPhiList())
2863 const auto defFrom = std::find_if(gp->CGetDefEdgesList().begin(), gp->CGetDefEdgesList().end(),
2865 if(defFrom != gp->CGetDefEdgesList().end())
2867 gp->ReplaceDefEdge(
TreeM, *defFrom, {defFrom->first, splitBBI});
2872 auto it = std::find_if(block->CGetStmtList().begin(), block->CGetStmtList().end(), [&](
const tree_nodeRef& tn) {
2877 while(it != block->CGetStmtList().end())
2879 const auto mv_stmt = *it;
2881 block->RemoveStmt(mv_stmt,
AppM);
2882 splitBB->PushBack(mv_stmt,
AppM);
2884 block->RemoveStmt(call_node,
AppM);
2887 const auto max_loop_id = [&]() {
2888 unsigned int mlid = 0;
2889 for(
const auto& ibb : sl->list_of_bloc)
2891 mlid =
std::max(mlid, ibb.second->loop_id);
2892 std::replace(ibb.second->list_of_pred.begin(), ibb.second->list_of_pred.end(), block->number, splitBB->number);
2896 const auto inline_fd = GetPointerS<const function_decl>(
GET_CONST_NODE(fn));
2897 auto output_level =
parameters->getOption<
int>(OPT_output_level);
2902 remapping.insert(std::make_pair(inline_fd->index, fd->index));
2903 std::for_each(inline_fd->list_of_args.cbegin(), inline_fd->list_of_args.cend(), [&](
const tree_nodeRef& tn) {
2908 const auto dup_sl = GetPointer<const statement_list>(
TreeM->
CGetTreeNode(dup_sl_id));
2911 const auto replace_arg_with_param = [&](
const tree_nodeRef& stmt) {
2913 for(
const auto& use : uses)
2915 const auto SSA = GetPointer<const ssa_name>(
GET_CONST_NODE(use.first));
2918 if(SSA->var !=
nullptr &&
GET_CONST_NODE(SSA->var)->get_kind() == parm_decl_K &&
2921 auto argIt = std::find_if(
2922 inline_fd->list_of_args.cbegin(), inline_fd->list_of_args.cend(),
2925 "parm_decl associated with ssa_name not found in function parameters");
2926 size_t arg_pos =
static_cast<size_t>(argIt - inline_fd->list_of_args.cbegin());
2934 std::vector<std::pair<tree_nodeRef, unsigned int>> list_of_def_edge;
2935 for(
const auto& ibb : dup_sl->list_of_bloc)
2941 auto& bb = ibb.second;
2943 for(
auto it = bb->list_of_pred.begin(); it != bb->list_of_pred.end(); ++it)
2947 *it = block->number;
2948 block->list_of_succ.push_back(bb->number);
2951 for(
auto it = bb->list_of_succ.begin(); it != bb->list_of_succ.end(); ++it)
2953 const auto has_abort_call = [&]() ->
bool {
2954 if(!bb->CGetStmtList().empty())
2956 const auto& last_stmt = bb->CGetStmtList().back();
2959 const auto gc = GetPointerS<const gimple_call>(
GET_CONST_NODE(last_stmt));
2960 auto call_fd = gc->fn;
2968 if(fu_name ==
"abort" || fu_name ==
"exit")
2978 *it = splitBB->number;
2979 splitBB->list_of_pred.push_back(bb->number);
2982 for(
const auto&
phi : bb->CGetPhiList())
2984 replace_arg_with_param(
phi);
2986 for(
auto it = bb->CGetStmtList().begin(); it != bb->CGetStmtList().end();)
2988 const auto stmt = *it;
2990 replace_arg_with_param(stmt);
2996 const auto gr = GetPointerS<const gimple_return>(
GET_CONST_NODE(stmt));
2998 list_of_def_edge.push_back(std::make_pair(gr->op, bb->number));
3000 bb->RemoveStmt(stmt,
AppM);
3004 THROW_ASSERT(block->list_of_succ.size() == 1,
"There should be only one entry point.");
3009 const auto ret_phi =
create_phi_node(phi_res, list_of_def_edge, fd->index);
3010 auto gp = GetPointer<gimple_phi>(
GET_NODE(ret_phi));
3011 gp->artificial =
true;
3012 gp->SetSSAUsesComputed();
3013 splitBB->AddPhi(ret_phi);
3016 if(splitBB->list_of_pred.empty())
3018 THROW_ASSERT(splitBB->CGetStmtList().empty() && splitBB->CGetPhiList().empty(),
3019 "Unreachable BB after inlined call statement must be empty.");
3020 for(
const auto& succ_bbi : splitBB->list_of_succ)
3022 const auto& succ_bb = sl->list_of_bloc[succ_bbi];
3023 const auto new_end = std::remove(succ_bb->list_of_pred.begin(), succ_bb->list_of_pred.end(), splitBB->number);
3024 succ_bb->list_of_pred.erase(new_end, succ_bb->list_of_pred.end());
3026 sl->list_of_bloc.erase(splitBB->number);
3028 return splitBB->number;
3032 const std::string& version_suffix)
3037 std::vector<tree_nodeRef>
const*
args =
nullptr;
3038 if(
const auto gc = GetPointer<const gimple_call>(call_stmt))
3043 else if(
const auto ga = GetPointer<const gimple_assign>(call_stmt))
3045 const auto ce = GetPointer<const call_expr>(
GET_CONST_NODE(ga->op1));
3046 THROW_ASSERT(ce,
"Assign statement does not contain a function call: " +
STR(call_node));
3053 THROW_UNREACHABLE(
"Unsupported call statement: " + call_stmt->get_kind_text() +
" " +
STR(call_node));
3057 called_fn = GetPointerS<const unary_expr>(
GET_CONST_NODE(called_fn))->op;
3060 "Call statement should address a function declaration");
3067 const auto version_fn =
CloneFunction(called_fn, version_suffix);
3072 const auto has_args = !GetPointer<const function_decl>(
GET_CONST_NODE(version_fn))->list_of_args.empty();
3074 const auto ga = GetPointerS<const gimple_assign>(call_stmt);
3087 const auto caller_fd = GetPointer<function_decl>(
GET_NODE(caller_node));
3088 const auto call_bbi = GetPointer<gimple_node>(call_stmt)->bb_index;
3089 const auto& call_bb = GetPointer<statement_list>(
GET_NODE(caller_fd->body))->list_of_bloc.at(call_bbi);
3090 call_bb->Replace(call_node, version_call,
true,
AppM);
#define GET_NODE(t)
Macro used to hide implementation details when accessing a tree_node from another tree_node...
tree_nodeRef CreateOrExpr(const tree_nodeConstRef &first_condition, const tree_nodeConstRef &second_condition, const blocRef &block, unsigned int function_decl_nid) const
Create an or expression.
This struct specifies a point-to solution.
tree_nodeRef CreateNotExpr(const tree_nodeConstRef &condition, const blocRef &block, unsigned int function_decl_nid) const
UTILITY.
~tree_manipulation()
This is the destructor of the tree_manipulation.
refcount< PointToSolution > PointToSolutionRef
#define DEBUG_LEVEL_VERY_PEDANTIC
extremely verbose debugging print is performed.
tree_nodeRef GetBitsizeType() const
Function that creates a bit_size type if it is not already present, otherwise it returns the one that...
#define SIZE_VALUE_FUNCTION
tree_nodeRef ExtractCondition(const tree_nodeRef &condition, const blocRef &block, unsigned int function_decl_nid) const
Extract computation of condition from a gimple_cond.
tree_nodeRef create_quaternary_operation(const tree_nodeConstRef &type, const tree_nodeRef &op0, const tree_nodeRef &op1, const tree_nodeRef &op2, const tree_nodeRef &op3, const std::string &srcp, enum kind operation_kind) const
Function used to create a quaternary expression.
This struct specifies the field bloc (basic block).
#define INDENT_DBG_MEX(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed;.
tree_nodeRef CreateEqExpr(const tree_nodeConstRef &first_operand, const tree_nodeConstRef &second_operand, const blocRef &block, unsigned int function_decl_nid) const
Create an eq_expr.
File containing functions and utilities to support the printing of debug messagges.
#define PRINT_DBG_MEX(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed;.
void bb_set_false_edge(blocRef &bb, const unsigned int &false_edge_index) const
Function that sets in basic block bb the index of the then basic block in case the last statement is ...
std::string ToString() const
Print this node as string in gimple format.
tree_nodeRef create_gimple_cond(const tree_nodeRef &expr, unsigned int function_decl_nid, const std::string &srcp) const
GIMPLE_COND.
#define CASE_BINARY_EXPRESSION
This macro collects all case labels for binary_expr objects.
const tree_nodeRef CGetTreeReindex(const unsigned int i) const
Return a tree_reindex wrapping the i-th tree_node.
void bb_add_stmt(blocRef &bb, const tree_nodeRef &stmt) const
Function that adds in basic block bb the statement stmt.
#define GET_CLASS(obj)
Macro returning the actual type of an object.
void ReplaceTreeNode(const tree_nodeRef &stmt, const tree_nodeRef &old_node, const tree_nodeRef &new_node)
Replace the occurrences of tree node old_node with new_node in statement identified by tn...
tree_managerRef TreeM
Tree Manager.
tree_nodeRef create_translation_unit_decl() const
create or find a global scope
static unsigned int goto_label_unique_id
store a unique id used during the creation of the label_decl associated with a gimple_goto.
#define ALGN_UNSIGNED_LONG_LONG_INT
Definition of the class representing a generic C application.
#define CASE_DECL_NODES
NOTE that cast_expr is a unary expression but it could not be included in the CASE_UNARY_EXPRESSION b...
struct definition of the source position.
tree_nodeRef CreateUnsigned(const tree_nodeConstRef &signed_type) const
Create an unsigned integer type starting from signed type.
mathematical utility function not provided by standard libraries
#define INDENT_OUT_MEX(outLevel, curOutLevel, mex)
tree_nodeRef GetSizeType() const
create a sizetype builtin type in case it has not already been created, otherwise it returns the one ...
static unsigned long long int align(unsigned long long int address, unsigned long long int alignment)
STL includes.
#define PREC_UNSIGNED_LONG_LONG_INT
static tree_nodeConstRef CGetElements(const tree_nodeConstRef &type)
Given an array or a vector return the element type.
unsigned int InlineFunctionCall(const tree_nodeRef &call_node, const tree_nodeRef &caller_node)
Execute function call inlining of given call statement (call graph must be recomputed after inlining)...
unsigned int get_next_available_tree_node_id() const
return the next available tree node id.
exceptions managed by PandA
void bb_remove_successor(blocRef &bb, const unsigned int &successor) const
Function that removes a successor in basic block bb.
tree_nodeRef CloneFunction(const tree_nodeRef &tn, const std::string &funNameSuffix)
CloneFunction duplicates a function.
tree_nodeRef create_binary_operation(const tree_nodeConstRef &type, const tree_nodeRef &op0, const tree_nodeRef &op1, const std::string &srcp, enum kind operation_kind) const
Function used to create a binary expression.
tree_nodeRef GetSignedIntegerType() const
Function that creates a integer type if it is not already present, otherwise it returns the one that ...
void bb_add_successor(blocRef &bb, const unsigned int &successor) const
Function that adds a successor in basic block bb.
A simple interface to token object of the raw files.
static const unsigned int EXIT_BLOCK_ID
constant identifying the exit basic block
tree_nodeRef CreateIntegerCst(const tree_nodeConstRef &type, integer_cst_t value, const unsigned int integer_cst_nid) const
CONST_OBJ_TREE_NODES.
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.
unsigned int get_next_vers()
Return the next unused version number for ssa variables.
Data structure describing a basic block at tree level.
#define PREC_UNSIGNED_INT
#define MIN_VALUE_UNSIGNED_LONG_LONG_INT
#define MIN_VALUE_BIT_SIZE
#define OUTPUT_LEVEL_MINIMUM
minimum debugging print is performed.
tree_nodeRef CreateAddrExpr(const tree_nodeConstRef &tn, const std::string &srcp) const
Create an addr_expr.
#define TOK(token)
Macro used to convert a token symbol into a treeVocabularyTokenTypes.
tree_nodeRef create_unary_operation(const tree_nodeConstRef &type, const tree_nodeRef &op, const std::string &srcp, enum kind operation_kind) const
EXPRESSION_TREE_NODES.
const tree_nodeConstRef CGetTreeNode(const unsigned int i) const
void bb_add_predecessor(blocRef &bb, const unsigned int &predecessor) const
Function that adds a predecessor in basic block bb.
tree_nodeRef CreateGimpleAssign(const tree_nodeConstRef &type, const tree_nodeConstRef &min, const tree_nodeConstRef &max, const tree_nodeRef &op, unsigned int function_decl_nid, const std::string &srcp) const
Create gimple assignment.
#define SIZE_VALUE_UNSIGNED_INT
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.
tree_nodeRef create_parm_decl(const tree_nodeRef &name, const tree_nodeConstRef &type, const tree_nodeRef &scpe, const tree_nodeConstRef &argt, const tree_nodeRef &smt_ann, const tree_nodeRef &init, const std::string &srcp, int used, bool register_flag=false, bool readonly_flag=false) const
DECL_NODES.
Auxiliary methods for manipulating string.
blocRef create_basic_block(std::map< unsigned int, blocRef > &list_of_bloc, std::vector< unsigned int > predecessors, std::vector< unsigned int > successors, std::vector< tree_nodeRef > stmt, unsigned int number, unsigned int true_edge=0, unsigned int false_edge=0, std::vector< tree_nodeRef > phi=std::vector< tree_nodeRef >()) const
BASIC BLOCK.
#define SIZE_VALUE_BIT_SIZE
std::string ToString(ActorGraphBackend_Type actor_graph_backend_type)
Header include.
static void addCallPointAndExpand(CustomUnorderedSet< unsigned int > &AV, const application_managerRef AM, unsigned int caller_id, unsigned int called_id, unsigned int call_id, enum FunctionEdgeInfo::CallType call_type, int DL)
#define MAX_VALUE_UNSIGNED_INT
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.
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached
void bb_set_true_edge(blocRef &bb, const unsigned int &true_edge_index) const
Function that sets in basic block bb the index of the if basic block in case the last statement is a ...
tree_nodeRef create_lut_expr(const tree_nodeConstRef &type, const tree_nodeRef &op0, const tree_nodeRef &op1, const tree_nodeRef &op2, const tree_nodeRef &op3, const tree_nodeRef &op4, const tree_nodeRef &op5, const tree_nodeRef &op6, const tree_nodeRef &op7, const tree_nodeRef &op8, const std::string &srcp) const
create_lut_expr: function used to create a generic lut_expr operation
static unsigned long long Size(const tree_nodeConstRef &tn)
Return the size of a tree object.
void bb_remove_successors(blocRef &bb, const std::vector< unsigned int > &successors) const
Function that removes a list of successors in basic block bb.
tree_nodeRef CreateVectorBooleanType(const unsigned long long number_of_elements) const
Create a vector bool type.
#define ALGN_UNSIGNED_INT
tree_nodeRef GetPointerType(const tree_nodeConstRef &ptd, unsigned long long algn=0) const
Function that creates a pointer type if it is not already present, otherwise it returns the one that ...
static bool IsBooleanType(const tree_nodeConstRef &type)
Return true if the treenode is of bool type.
unsigned int find(enum kind tree_node_type, const std::map< TreeVocabularyTokenTypes_TokenEnum, std::string > &tree_node_schema)
if there exist return the node id of a tree node compatible with the tree_node_schema and of type tre...
void create_goto(const blocRef &block, unsigned int function_decl_nid, unsigned int label_expr_nid) const
create a goto expression.
const application_managerRef AppM
Application manager data structure.
#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.
unsigned int new_tree_node_id(const unsigned int ask=0)
Return a new node id in the intermediate representation.
void bb_add_successors(blocRef &bb, const std::vector< unsigned int > &successors) const
Function that adds a list of successors in basic block bb.
unsigned int create_tree_node(const tree_nodeRef &tn, int mode=tree_node_dup_mode::DEFAULT)
tree_node visitors
void add_function(unsigned int index, tree_nodeRef curr)
Add to the function_decl_nodes the current node.
void bb_remove_predecessors(blocRef &bb, const std::vector< unsigned int > &predecessors) const
Function that removes a list of predecessors in basic block bb.
void bb_add_predecessors(blocRef &bb, const std::vector< unsigned int > &predecessors) const
Function that adds a list of predecessors in basic block bb.
void bb_remove_all_predecessors(blocRef &bb) const
Function that removes all the predecessors of basic block bb.
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...
void create_tree_node(const unsigned int node_id, enum kind tree_node_type, std::map< TreeVocabularyTokenTypes_TokenEnum, std::string > &tree_node_schema)
Factory method.
tree_nodeRef CreateUniqueIntegerCst(integer_cst_t value, const tree_nodeConstRef &type)
memoization of integer constants
std::pair< tree_nodeRef, unsigned int > DefEdge
The type of the def edge.
tree_nodeRef GetTreeReindex(const unsigned int i)
Return a tree_reindex wrapping the i-th tree_node.
tree_nodeRef create_result_decl(const tree_nodeRef &name, const tree_nodeRef &type, const tree_nodeRef &scpe, const tree_nodeRef &size, const tree_nodeRef &smt_ann, const tree_nodeRef &init, const std::string &srcp, unsigned int algn, bool artificial_flag=false) const
Function used to create a result_decl.
static bool IsVectorType(const tree_nodeConstRef &type)
Return true if the treenode is a vector.
constexpr T get_aligned_bitsize(T bitsize)
void add_goto()
Increment the number of added gotos.
#define GET_CONST_NODE(t)
#define MAX_VALUE_BIT_SIZE
#define SIZE_VALUE_POINTER_M32
refcount< const tree_node > tree_nodeConstRef
bool ends_with(const std::string &str, const std::string &pattern)
Classes specification of the tree_node data structures.
tree_nodeRef GetFunctionType(const tree_nodeConstRef &returnType, const std::vector< tree_nodeConstRef > &argsT) const
Create a function type.
Class defining some useful functions to create tree nodes and to manipulate the tree manager...
#define DEBUG_LEVEL_NONE
no debugging print is performed.
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
tree_nodeRef create_function_decl(const std::string &function_name, const tree_nodeRef &scpe, const std::vector< tree_nodeConstRef > &argsT, const tree_nodeConstRef &returnType, const std::string &srcp, bool with_body) const
create the declaration of a function without its body
#define MIN_VALUE_UNSIGNED_INT
const ParameterConstRef parameters
The set of input parameters.
tree_nodeRef GetBooleanType() const
Function that creates a boolean type if it is not already present, otherwise it returns the one that ...
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.
tree_nodeRef create_gimple_return(const tree_nodeConstRef &type, const tree_nodeConstRef &expr, unsigned int function_decl_nid, const std::string &srcp) const
GIMPLE_RETURN.
tree_nodeRef GetTreeNode(const unsigned int index) const
Return the index-th tree_node (modifiable version)
tree_nodeRef GetCustomIntegerType(unsigned long long prec, bool unsigned_p) const
create an integer type starting from a given prec
void init(int bucket[BUCKETSIZE])
tree_nodeRef CreateCallExpr(const tree_nodeConstRef &called_function, const std::vector< tree_nodeRef > &args, const std::string &srcp) const
Create a call_expr.
tree_nodeRef create_ternary_operation(const tree_nodeConstRef &type, const tree_nodeRef &op0, const tree_nodeRef &op1, const tree_nodeRef &op2, const std::string &srcp, enum kind operation_kind) const
Function used to create a ternary expression.
#define SIZE_VALUE_UNSIGNED_LONG_LONG_INT
#define CASE_CST_NODES
This macro collects all case labels for cast nodes.
bool VersionFunctionCall(const tree_nodeRef &call_node, const tree_nodeRef &caller_node, const std::string &version_suffix)
Perform function call versioning.
struct definition of the type node structures.
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.
tree_nodeRef GetUnsignedLongLongType() const
Function that creates a long long unsigned int type if it is not already present, otherwise return th...
void bb_remove_all_successors(blocRef &bb) const
Function that removes all the successors of basic block bb.
tree_nodeRef GetVoidType() const
TYPE_OBJ.
tree_nodeRef create_gimple_call(const tree_nodeConstRef &called_function, const std::vector< tree_nodeRef > &args, unsigned int function_decl_nid, const std::string &srcp) const
GIMPLE_CALL.
void bb_add_stmts(blocRef &bb, const std::vector< tree_nodeRef > &stmt) const
Function that adds in basic block bb the statements listed in vector stmt.
tree_nodeRef CreateNopExpr(const tree_nodeConstRef &operand, const tree_nodeConstRef &type, const tree_nodeConstRef &min, const tree_nodeConstRef &max, unsigned int function_decl_nid) const
Create a nop_expr to perform a conversion.
static tree_nodeConstRef CGetType(const tree_nodeConstRef &node)
Return the treenode of the type of node.
tree_nodeRef GetUnsignedIntegerType() const
Function that creates a unsigned integer type if it is not already present, otherwise it returns the ...
Classes specification of the tree_node data structures not present in the gcc.
this class is used to manage the command-line or XML options.
#define MAX_VALUE_UNSIGNED_LONG_LONG_INT
#define CASE_CPP_NODES
This macro collects all case labels for cpp nodes.
tree_nodeRef create_extract_bit_expr(const tree_nodeRef &op0, const tree_nodeRef &op1, const std::string &srcp) const
tree_nodeRef create_ssa_name(const tree_nodeConstRef &var, const tree_nodeConstRef &type, const tree_nodeConstRef &min, const tree_nodeConstRef &max, bool volatile_flag=false, bool virtual_flag=false) const
MISCELLANEOUS_OBJ_TREE_NODES.
refcount< tree_node > tree_nodeRef
RefCount type definition of the tree_node class structure.
tree node duplication class.
static std::string GetFunctionName(const tree_managerConstRef &TM, const tree_nodeConstRef &decl)
Return the name of the function.
#define SIZE_VALUE_POINTER_M64
absl::node_hash_map< T, U, Hash, Eq, Alloc > CustomUnorderedMapStable
static integer_cst_t GetConstValue(const tree_nodeConstRef &tn, bool is_signed=true)
Get value from integer constant.
#define CASE_GIMPLE_NODES
This macro collects all cases labels for gimple nodes.
tree_nodeRef CreateGimpleAssignAddrExpr(const tree_nodeConstRef &tn, unsigned int function_decl_nid, const std::string &srcp) const
Create a gimple_assign with op0 a new ssa_name, and op1 an addr_expr which takes the address of the t...
tree_nodeRef create_phi_node(tree_nodeRef &ssa_res, const std::vector< std::pair< tree_nodeRef, unsigned int >> &list_of_def_edge, unsigned int function_decl_nid, bool virtual_flag=false) const
GIMPLE_PHI.
#define GET_INDEX_CONST_NODE(t)
const int debug_level
debug level.
const bool reuse
True if statements can be reused.
tree_nodeRef create_identifier_node(const std::string &strg) const
IDENTIFIER_TREE_NODE.
tree_manipulation(const tree_managerRef &TreeM, const ParameterConstRef ¶meters, const application_managerRef _AppM)
This is the constructor of the tree_manipulation.
tree_nodeRef create_gimple_modify_stmt(const tree_nodeRef &op0, const tree_nodeRef &op1, unsigned int function_decl_nid, const std::string &srcp) const
GIMPLE_ASSIGN.
static void ComputeSsaUses(const tree_nodeRef &, TreeNodeMap< size_t > &uses)
recursively compute the references to the ssa_name variables used in a statement
tree_nodeRef GetFunction(const std::string &function_name) const
Return the index of a function given its name.
tree_nodeRef CreateAndExpr(const tree_nodeConstRef &first_condition, const tree_nodeConstRef &second_condition, const blocRef &block, unsigned int function_decl_nid) const
Create an or expression.
#define CASE_TERNARY_EXPRESSION
This macro collects all case labels for ternary_expr objects.
void bb_remove_predecessor(blocRef &bb, const unsigned int &predecessor) const
Function that removes a predecessor in basic block bb.
void create_label(const blocRef &block, unsigned int function_decl_nid) const
create a label expression in a header of a loop.
Class specification of the manager of the tree structures extracted from the raw file.
tree_nodeRef create_var_decl(const tree_nodeRef &name, const tree_nodeConstRef &type, const tree_nodeRef &scpe, const tree_nodeRef &size, const tree_nodeRef &smt_ann, const tree_nodeRef &init, const std::string &srcp, unsigned int algn, int used, bool artificial_flag=false, int use_tmpl=-1, bool static_static_flag=false, bool extern_flag=false, bool static_flag=false, bool register_flag=false, bool readonly_flag=false, const std::string &bit_values="", bool addr_taken=false, bool addr_not_taken=false) const
Function used to create a var_decl.
#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 ...