65 #if HAVE_FROM_PRAGMA_BUILT 69 #include "config_HAVE_ASSERTS.hpp" 70 #include "config_HAVE_FROM_PRAGMA_BUILT.hpp" 71 #include "config_RELEASE.hpp" 73 #include <boost/algorithm/string/replace.hpp> 86 #define MAX_ROW_LENGTH 128 91 TM(_AppM->get_tree_manager()),
93 debug_level(Param->get_class_debug_level(
"BehavioralHelper",
DEBUG_LEVEL_NONE)),
94 function_index(_index),
95 function_name(
tree_helper::GetFunctionName(TM, TM->CGetTreeReindex(function_index))),
104 bool& is_system)
const 120 case gimple_assign_K:
129 case aggr_init_expr_K:
130 case case_label_expr_K:
136 case gimple_multi_way_if_K:
139 case gimple_pragma_K:
140 case gimple_predict_K:
142 case gimple_return_K:
143 case gimple_switch_K:
145 case identifier_node_K:
147 case statement_list_K:
149 case target_mem_ref_K:
150 case target_mem_ref461_K:
171 boost::replace_all(res,
"\\\"",
""");
173 for(
const auto& re : res)
202 switch(node->get_kind())
206 const auto constr = GetPointerS<const constructor>(node);
207 bool designated_initializers_needed =
false;
209 auto i = constr->list_of_idx_valu.begin();
210 const auto vend = constr->list_of_idx_valu.end();
212 const auto firstnode = i != vend ? constr->list_of_idx_valu.front().first :
tree_nodeRef();
213 if(firstnode &&
GET_CONST_NODE(firstnode)->get_kind() == field_decl_K)
215 const auto fd = GetPointerS<const field_decl>(
GET_CONST_NODE(firstnode));
217 std::vector<tree_nodeRef> field_list;
218 if(scpe->get_kind() == record_type_K)
220 field_list = GetPointerS<const record_type>(scpe)->list_of_flds;
222 else if(scpe->get_kind() == union_type_K)
224 field_list = GetPointerS<const union_type>(scpe)->list_of_flds;
228 THROW_ERROR(
"expected a record_type or a union_type");
230 auto fli = field_list.begin();
231 const auto flend = field_list.end();
232 for(; fli != flend && i != vend; ++i, ++fli)
239 if(fli != flend && i != vend)
241 designated_initializers_needed =
true;
246 designated_initializers_needed =
true;
249 auto current_length = res.size();
250 for(i = constr->list_of_idx_valu.begin(); i != vend;)
253 if(designated_initializers_needed && i->first && GET_CONST_NODE(i->first)->get_kind() == field_decl_K)
261 if(val->get_kind() == addr_expr_K)
263 const auto ae = GetPointerS<const addr_expr>(val);
265 if(op->get_kind() == function_decl_K)
271 if(val->get_kind() == function_decl_K)
275 else if(val->get_kind() == constructor_K)
279 else if(val->get_kind() == var_decl_K)
283 else if(val->get_kind() == ssa_name_K)
298 current_length = current.size();
299 res +=
"\n" + current;
303 current_length += current.size();
322 case pointer_plus_expr_K:
326 res +=
PrintNode(node, dummy_vertex, vppf);
331 const auto vd = GetPointerS<const var_decl>(node);
332 THROW_ASSERT(vd->init,
"expected a initialization value: " +
STR(node));
339 case aggr_init_expr_K:
340 case case_label_expr_K:
342 case statement_list_K:
343 case target_mem_ref_K:
344 case target_mem_ref461_K:
350 case cleanup_point_expr_K:
354 case fix_ceil_expr_K:
355 case fix_floor_expr_K:
356 case fix_round_expr_K:
357 case fix_trunc_expr_K:
359 case imagpart_expr_K:
361 case misaligned_indirect_ref_K:
365 case non_lvalue_expr_K:
367 case realpart_expr_K:
368 case reinterpret_cast_expr_K:
370 case static_cast_expr_K:
372 case truth_not_expr_K:
375 case view_convert_expr_K:
376 case reduc_max_expr_K:
377 case reduc_min_expr_K:
378 case reduc_plus_expr_K:
379 case vec_unpack_hi_expr_K:
380 case vec_unpack_lo_expr_K:
381 case vec_unpack_float_hi_expr_K:
382 case vec_unpack_float_lo_expr_K:
388 case ceil_div_expr_K:
389 case ceil_mod_expr_K:
391 case compound_expr_K:
392 case eh_filter_expr_K:
394 case exact_div_expr_K:
396 case floor_div_expr_K:
397 case floor_mod_expr_K:
400 case goto_subroutine_K:
413 case mult_highpart_expr_K:
416 case postdecrement_expr_K:
417 case postincrement_expr_K:
418 case predecrement_expr_K:
419 case preincrement_expr_K:
422 case round_div_expr_K:
423 case round_mod_expr_K:
427 case trunc_div_expr_K:
428 case trunc_mod_expr_K:
429 case truth_and_expr_K:
430 case truth_andif_expr_K:
431 case truth_or_expr_K:
432 case truth_orif_expr_K:
433 case truth_xor_expr_K:
434 case try_catch_expr_K:
442 case unordered_expr_K:
443 case widen_sum_expr_K:
444 case widen_mult_expr_K:
445 case with_size_expr_K:
446 case vec_lshift_expr_K:
447 case vec_rshift_expr_K:
448 case widen_mult_hi_expr_K:
449 case widen_mult_lo_expr_K:
450 case vec_pack_trunc_expr_K:
451 case vec_pack_sat_expr_K:
452 case vec_pack_fix_trunc_expr_K:
453 case vec_extracteven_expr_K:
454 case vec_extractodd_expr_K:
455 case vec_interleavehigh_expr_K:
456 case vec_interleavelow_expr_K:
459 case function_decl_K:
461 case namespace_decl_K:
464 case translation_unit_decl_K:
465 case template_decl_K:
469 case identifier_node_K:
472 case reference_expr_K:
482 case extract_bit_expr_K:
483 case sat_plus_expr_K:
484 case sat_minus_expr_K:
485 case extractvalue_expr_K:
486 case extractelement_expr_K:
499 res +=
"__attribute__ (";
506 if(tl->valu &&
GET_CONST_NODE(tl->valu)->get_kind() == tree_list_K)
510 else if(tl->valu && (
GET_CONST_NODE(tl->valu)->get_kind() == string_cst_K ||
549 if(var_node->get_kind() == indirect_ref_K)
551 const auto ir = GetPointerS<const indirect_ref>(var_node);
557 if(var_node->get_kind() == misaligned_indirect_ref_K)
559 const auto mir = GetPointerS<const misaligned_indirect_ref>(var_node);
565 if(var_node->get_kind() == mem_ref_K)
567 const auto mr = GetPointerS<const mem_ref>(var_node);
579 ") + " +
STR(offset) +
"))";
583 if(var_node->get_kind() == identifier_node_K)
585 const auto in = GetPointerS<const identifier_node>(var_node);
587 return vars_symbol_table[var];
589 if(var_node->get_kind() == field_decl_K)
591 const auto fd = GetPointerS<const field_decl>(var_node);
594 const auto id = GetPointerS<const identifier_node>(
GET_NODE(fd->name));
602 if(var_node->get_kind() == function_decl_K)
604 const auto fd = GetPointerS<const function_decl>(var_node);
607 if(var_node->get_kind() == ssa_name_K)
609 const auto sa = GetPointerS<const ssa_name>(var_node);
615 THROW_ASSERT(sa->volatile_flag || sa->CGetDefStmts().size(), sa->ToString() +
" has not define statement");
616 if(sa->virtual_flag || (!sa->volatile_flag &&
GET_CONST_NODE(sa->CGetDefStmt())->get_kind() != gimple_nop_K))
618 name += (
"_" +
STR(sa->vers));
622 THROW_ASSERT(sa->var,
"the name has to be defined for volatile or parameters");
627 if(var_node->get_kind() == var_decl_K || var_node->get_kind() == parm_decl_K)
629 const auto dn = GetPointerS<const decl_node>(var_node);
632 const auto id = GetPointerS<const identifier_node>(
GET_CONST_NODE(dn->name));
634 return vars_symbol_table[var];
658 switch(node->get_kind())
663 const auto ic = GetPointerS<const integer_cst>(node);
665 const auto it = GetPointer<const integer_type>(
type);
666 const auto unsigned_flag = (it && it->unsigned_flag) || type->get_kind() == pointer_type_K ||
667 type->get_kind() == reference_type_K || type->get_kind() == boolean_type_K;
672 std::string predicted_type;
673 if (it->unsigned_flag)
674 predicted_type +=
"unsigned ";
676 predicted_type +=
"char";
677 else if (it->algn == 16)
678 predicted_type +=
"short";
679 else if (it->algn == 32)
680 predicted_type +=
"int";
681 else if (it->algn == 64)
682 predicted_type +=
"auto int";
684 if (predicted_type != actual_type && actual_type !=
"bit_size_type")
685 res =
"(" + actual_type +
")";
692 if((it && it->prec == 64) && (
value == (static_cast<long long int>(-0x08000000000000000LL))))
694 res =
"(long long int)-0x08000000000000000";
696 else if((it && it->prec == 32) && (
value == (static_cast<long int>(-0x080000000L))))
698 res =
"(long int)-0x080000000";
702 if(it && it->unsigned_flag)
711 if(it && it->prec > 32)
713 if(it && it->unsigned_flag)
728 else if(type->get_kind() == pointer_type_K || type->get_kind() == reference_type_K)
738 const auto rc = GetPointerS<const real_cst>(node);
739 if(rc->overflow_flag)
745 if(GetPointerS<const real_type>(
GET_CONST_NODE(rc->type))->prec == 80)
747 if(strcasecmp(rc->valr.data(),
"Inf") == 0)
749 if(rc->valx[0] ==
'-')
753 res +=
"__builtin_infl()";
755 else if(strcasecmp(rc->valr.data(),
"Nan") == 0)
757 if(rc->valx[0] ==
'-')
761 res +=
"__builtin_nanl(\"\")";
769 else if(GetPointerS<const real_type>(
GET_CONST_NODE(rc->type))->prec == 64)
771 if(strcasecmp(rc->valr.data(),
"Inf") == 0)
773 if(rc->valx[0] ==
'-')
777 res +=
"__builtin_inf()";
779 else if(strcasecmp(rc->valr.data(),
"Nan") == 0)
781 if(rc->valx[0] ==
'-')
785 res +=
"__builtin_nan(\"\")";
792 else if(strcasecmp(rc->valr.data(),
"Inf") == 0)
794 if(rc->valx[0] ==
'-')
798 res +=
"__builtin_inff()";
800 else if(strcasecmp(rc->valr.data(),
"Nan") == 0)
802 if(rc->valx[0] ==
'-')
806 res +=
"__builtin_nanf(\"\")";
816 THROW_ERROR(std::string(
"Node not yet supported: ") + node->get_kind_text());
822 const auto cc = GetPointerS<const complex_cst>(node);
832 const auto sc = GetPointerS<const string_cst>(node);
835 const auto at = GetPointer<const array_type>(
GET_CONST_NODE(sc->type));
837 const auto elts = GetPointerS<const integer_type>(
GET_CONST_NODE(at->elts));
847 res +=
"\"" + sc->strg +
"\"";
852 const auto vc = GetPointerS<const vector_cst>(node);
854 "Vector constant of type " +
GET_CONST_NODE(vc->type)->get_kind_text());
855 if(
GET_NODE(GetPointerS<const vector_type>(
GET_CONST_NODE(vc->type))->elts)->get_kind() != pointer_type_K)
860 for(
unsigned int i = 0; i < (vc->list_of_valu).size(); i++)
863 if(i != vc->list_of_valu.size() - 1)
871 case case_label_expr_K:
873 const auto cl = GetPointerS<const case_label_expr>(node);
883 "Case label expression " +
STR(node) +
" does not use integer_cst");
885 "Case label expression " +
STR(node) +
" does not use integer_cst");
890 res +=
STR(low) +
"u : case ";
893 res +=
STR(low) +
"u";
904 const auto ld = GetPointerS<const label_decl>(node);
905 THROW_ASSERT(ld->name,
"name expected in a label_decl");
906 const auto id = GetPointer<const identifier_node>(
GET_CONST_NODE(ld->name));
913 const auto ue = GetPointerS<const unary_expr>(node);
924 const auto ue = GetPointerS<const unary_expr>(node);
949 case aggr_init_expr_K:
951 case identifier_node_K:
953 case statement_list_K:
955 case target_mem_ref_K:
956 case target_mem_ref461_K:
961 case function_decl_K:
962 case namespace_decl_K:
965 case translation_unit_decl_K:
969 case template_decl_K:
976 case cleanup_point_expr_K:
980 case fix_ceil_expr_K:
981 case fix_floor_expr_K:
982 case fix_round_expr_K:
983 case fix_trunc_expr_K:
985 case imagpart_expr_K:
987 case misaligned_indirect_ref_K:
990 case non_lvalue_expr_K:
992 case realpart_expr_K:
993 case reference_expr_K:
994 case reinterpret_cast_expr_K:
996 case static_cast_expr_K:
998 case truth_not_expr_K:
1001 case view_convert_expr_K:
1002 case reduc_max_expr_K:
1003 case reduc_min_expr_K:
1004 case reduc_plus_expr_K:
1005 case vec_unpack_hi_expr_K:
1006 case vec_unpack_lo_expr_K:
1007 case vec_unpack_float_hi_expr_K:
1008 case vec_unpack_float_lo_expr_K:
1021 THROW_ERROR(
"Var object is not a constant " +
STR(node) +
" " + node->get_kind_text());
1052 return return_type->
index;
1064 const auto fd = GetPointerS<const function_decl>(
fun);
1065 const auto& list_of_args = fd->list_of_args;
1066 if(fd->list_of_args.size())
1069 for(
const auto& list_of_arg : list_of_args)
1077 const auto ft = GetPointerS<const function_type>(
GET_CONST_NODE(fd->type));
1080 auto currentp = ft->prms;
1083 const auto tl = GetPointerS<const tree_list>(
GET_CONST_NODE(currentp));
1086 if(
GET_NODE(tl->valu)->get_kind() != void_type_K)
1090 currentp = tl->chan;
1100 const auto fd = GetPointerS<const function_decl>(
fun);
1101 if(fd->list_of_args.size())
1104 return fd->list_of_args;
1108 const auto ft = GetPointerS<const function_type>(
GET_CONST_NODE(fd->type));
1111 auto currentp = ft->prms;
1114 const auto tl = GetPointerS<const tree_list>(
GET_CONST_NODE(currentp));
1119 parameters.push_back(tl->valu);
1121 currentp = tl->chan;
1168 bool init_has_to_be_printed)
const 1170 std::string return_value;
1172 THROW_ASSERT(GetPointer<const decl_node>(curr_tn) || GetPointer<const ssa_name>(curr_tn),
1173 "Call pparameter_type_indexrint_var_declaration on node " +
STR(var) +
" which is of type " +
1174 curr_tn->get_kind_text());
1176 if(GetPointer<const decl_node>(curr_tn))
1178 dn = GetPointerS<const decl_node>(curr_tn);
1187 const unsigned int init =
GetInit(var, list_of_variables);
1192 if(dn && dn->packed_flag)
1194 return_value +=
" __attribute__((packed))";
1197 ((dn->orig && (GetPointer<const var_decl>(curr_tn)) &&
1199 (GetPointer<const var_decl>(curr_tn)->algn != GetPointer<const var_decl>(
GET_CONST_NODE(dn->orig))->algn)) ||
1200 ((GetPointer<const var_decl>(curr_tn)) && (GetPointer<const var_decl>(curr_tn)->algn == 128))))
1202 return_value +=
" __attribute__ ((aligned (" +
STR(GetPointerS<const var_decl>(curr_tn)->algn / 8) +
"))) ";
1204 if(init && init_has_to_be_printed)
1209 return return_value;
1217 return GetPointer<function_type>(tn)->varargs_flag;
1230 std::string res =
"";
1233 switch(node->get_kind())
1236 case sat_plus_expr_K:
1238 const auto be = GetPointerS<const binary_expr>(node);
1240 std::string left, right;
1241 left = (
"(" +
PrintNode(be->op0, v, vppf) +
")");
1242 right = (
"(" +
PrintNode(be->op1, v, vppf) +
")");
1246 res +=
"((((" + left +
" & " +
STR(1ULL << (op_size - 1)) +
"ULL) ^ (" + right +
" & " +
1247 STR(1ULL << (op_size - 1)) +
1250 left +
" & " +
STR(1ULL << (op_size - 1)) +
"ULL) == ((" + left +
" + " + right +
") & " +
1251 STR(1ULL << (op_size - 1)) +
1254 left +
" + " + right +
1257 left +
" & " +
STR(1ULL << (op_size - 1)) +
"ULL) ? " +
1258 STR(static_cast<long long>(-1ULL << (res_size - 1))) +
" : " +
STR((1LL << (res_size - 1)) - 1) +
1263 res +=
"( (" + left +
" + " + right +
") < " + right +
" ? " +
STR((1ULL << res_size) - 1) +
1264 (res_size > 32 ?
"ULL" :
"") +
" : " + left +
" + " + right +
")";
1268 case sat_minus_expr_K:
1270 const auto be = GetPointerS<const binary_expr>(node);
1271 std::string left, right;
1272 left = (
"(" +
PrintNode(be->op0, v, vppf) +
")");
1273 right = (
"(" +
PrintNode(be->op1, v, vppf) +
")");
1278 res +=
"((((" + left +
" & " +
STR(1ULL << (op_size - 1)) +
"ULL) ^ (~" + right +
" & " +
1279 STR(1ULL << (op_size - 1)) +
1282 left +
" & " +
STR(1ULL << (op_size - 1)) +
"ULL) == ((" + left +
" - " + right +
") & " +
1283 STR(1ULL << (op_size - 1)) +
1286 left +
" - " + right +
1289 left +
" & " +
STR(1ULL << (op_size - 1)) +
"ULL) ? " +
1290 STR(static_cast<long long>(-1ULL << (res_size - 1))) +
" : " +
STR((1LL << (res_size - 1)) - 1) +
1295 res +=
"( " + left +
" > " + right +
" ? " + left +
" - " + right +
" : 0)";
1301 const auto be = GetPointerS<const binary_expr>(node);
1302 std::string left, right;
1304 left = (
"(" +
PrintNode(be->op0, v, vppf) +
")");
1305 right = (
"(" +
PrintNode(be->op1, v, vppf) +
")");
1307 const auto rt = GetPointerS<const real_type>(
GET_CONST_NODE(be->type));
1310 res +=
"fmodl(" + left +
"," + right +
")";
1312 else if(rt->prec == 64)
1314 res +=
"fmod(" + left +
"," + right +
")";
1316 else if(rt->prec == 32)
1318 res +=
"fmodf(" + left +
"," + right +
")";
1322 THROW_ERROR(
"fmod on a real number with not supported precision");
1328 const auto be = GetPointerS<const binary_expr>(node);
1341 const auto vector_size = size / element_size;
1344 for(
unsigned int ind = 0; ind < vector_size; ++ind)
1346 res +=
"(" +
PrintNode(be->op0, v, vppf) +
")[" +
STR(ind) +
"] + (" +
PrintNode(be->op1, v, vppf) +
1347 ")[" +
STR(ind) +
"]";
1348 if(ind != vector_size - 1)
1358 unsigned int prec = 0;
1359 unsigned int algn = 0;
1366 if(prec != algn && prec % algn)
1373 GetPointer<const ssa_name>(GET_CONST_NODE(be->op0)))
1379 res += (
"(" +
PrintNode(be->op0, v, vppf) +
")");
1381 res += std::string(
" ") + op +
" ";
1384 GetPointer<const ssa_name>(GET_CONST_NODE(be->op1)))
1390 res += (
"(" +
PrintNode(be->op1, v, vppf) +
")");
1393 if(prec != algn && prec % algn)
1404 res +=
" << " +
STR(prec) +
"))";
1409 case bit_ior_expr_K:
1410 case bit_xor_expr_K:
1411 case bit_and_expr_K:
1413 const auto be = GetPointerS<const binary_expr>(node);
1426 const auto vector_size = size / element_size;
1429 for(
unsigned int ind = 0; ind < vector_size; ++ind)
1431 res +=
"(" +
PrintNode(be->op0, v, vppf) +
")[" +
STR(ind) +
"] " + op +
" (" +
1433 if(ind != vector_size - 1)
1444 unsigned int prec = 0;
1445 unsigned int algn = 0;
1452 if(prec != algn && prec % algn)
1462 GetPointer<const ssa_name>(GET_CONST_NODE(be->op0)))
1468 res += (
"(" +
PrintNode(be->op0, v, vppf) +
")");
1474 res += std::string(
" ") + op +
" ";
1477 res +=
"((unsigned)(";
1481 GetPointer<const ssa_name>(GET_CONST_NODE(be->op1)))
1487 res += (
"(" +
PrintNode(be->op1, v, vppf) +
")");
1493 if(prec != algn && prec % algn)
1504 res +=
" << " +
STR(prec) +
"))";
1509 case vec_rshift_expr_K:
1511 const auto vre = GetPointerS<const vec_rshift_expr>(node);
1515 const auto vector_size = size / element_size;
1516 res +=
"/*" + vre->get_kind_text() +
"*/";
1519 for(
unsigned int ind = 0; ind < vector_size; ++ind)
1521 for(
unsigned int k = ind;
k < vector_size; ++
k)
1523 res +=
"((" +
PrintNode(vre->op1, v, vppf) +
" >= " +
STR(element_size * (
k - ind)) +
"&&" +
1524 PrintNode(vre->op1, v, vppf) +
" < " +
STR(element_size * (
k - ind + 1)) +
") ? ((" +
1526 STR(element_size * (
k - ind)) +
"): 0)";
1527 if(
k != vector_size - 1)
1533 for(
unsigned int k = ind + 1;
k < vector_size; ++
k)
1535 res +=
"| ((" +
PrintNode(vre->op1, v, vppf) +
" > " +
STR(element_size * (
k - 1 - ind)) +
"&&" +
1536 PrintNode(vre->op1, v, vppf) +
" < " +
STR(element_size * (
k - ind)) +
") ? ((" +
1537 PrintNode(vre->op0, v, vppf) +
")[" +
STR(
k) +
"]) << (" +
STR(element_size * (
k - ind)) +
"-" +
1540 if(ind != vector_size - 1)
1548 case vec_lshift_expr_K:
1550 const auto vle = GetPointerS<const vec_lshift_expr>(node);
1554 const auto vector_size = size / element_size;
1555 res +=
"/*" + vle->get_kind_text() +
"*/";
1558 for(
unsigned int ind = 0; ind < vector_size; ++ind)
1560 for(
unsigned int k = 0;
k <= ind; ++
k)
1562 res +=
"((" +
PrintNode(vle->op1, v, vppf) +
" >= " +
STR(element_size * (
k)) +
"&&" +
1563 PrintNode(vle->op1, v, vppf) +
" < " +
STR(element_size * (
k + 1)) +
") ? ((" +
1565 "-" +
STR(element_size *
k) +
"): 0)";
1571 for(
unsigned int k = 0;
k < ind; ++
k)
1573 res +=
"| ((" +
PrintNode(vle->op1, v, vppf) +
" > " +
STR(element_size * (
k)) +
"&&" +
1574 PrintNode(vle->op1, v, vppf) +
" < " +
STR(element_size * (
k + 1)) +
") ? ((" +
1575 PrintNode(vle->op0, v, vppf) +
")[" +
STR(ind -
k - 1) +
"]) >> (" +
STR(element_size * (
k + 1)) +
1576 "-" +
PrintNode(vle->op1, v, vppf) +
"): 0)";
1578 if(ind != vector_size - 1)
1586 case mult_highpart_expr_K:
1593 case trunc_div_expr_K:
1594 case ceil_div_expr_K:
1595 case floor_div_expr_K:
1596 case round_div_expr_K:
1597 case trunc_mod_expr_K:
1598 case ceil_mod_expr_K:
1599 case floor_mod_expr_K:
1600 case round_mod_expr_K:
1602 case exact_div_expr_K:
1605 case truth_andif_expr_K:
1606 case truth_orif_expr_K:
1607 case truth_and_expr_K:
1608 case truth_or_expr_K:
1609 case truth_xor_expr_K:
1612 const auto be = GetPointerS<const binary_expr>(node);
1624 const auto vector_size = size / element_size;
1627 for(
unsigned int ind = 0; ind < vector_size; ++ind)
1629 res +=
"(" +
PrintNode(be->op0, v, vppf) +
")[" +
STR(ind) +
"] " + op +
" (" +
1633 res +=
"[" +
STR(ind) +
"]";
1635 if(ind != vector_size - 1)
1645 unsigned int prec = 0;
1646 unsigned int algn = 0;
1653 if(prec != algn && prec % algn)
1657 if((node->get_kind() == lshift_expr_K || node->get_kind() == rshift_expr_K) &&
1663 GetPointer<const ssa_name>(GET_CONST_NODE(be->op0)))
1669 res += (
"(" +
PrintNode(be->op0, v, vppf) +
")");
1671 if((node->get_kind() == lshift_expr_K || node->get_kind() == rshift_expr_K) &&
1676 res += std::string(
" ") + op +
" ";
1678 GetPointer<const ssa_name>(GET_CONST_NODE(be->op1)))
1684 res += (
"(" +
PrintNode(be->op1, v, vppf) +
")");
1686 if(prec != algn && prec % algn)
1697 res +=
" << " +
STR(prec) +
"))";
1702 case widen_sum_expr_K:
1703 case widen_mult_expr_K:
1706 const auto be = GetPointerS<const binary_expr>(node);
1710 res += std::string(
" ") + op +
" ";
1714 case extract_bit_expr_K:
1716 const auto be = GetPointerS<const binary_expr>(node);
1717 res +=
"(_Bool)(((unsigned long long int)(" +
PrintNode(be->op0, v, vppf);
1718 res += std::string(
") >> ");
1719 res +=
PrintNode(be->op1, v, vppf) +
") & 1)";
1722 case extractvalue_expr_K:
1724 const auto be = GetPointerS<const extractvalue_expr>(node);
1730 case insertvalue_expr_K:
1732 const auto te = GetPointerS<const insertvalue_expr>(node);
1733 unsigned long long op2_size;
1738 "(((" +
PrintNode(te->op0, v, vppf) +
" >> (" +
STR(op2_size) +
" + " +
PrintNode(te->op2, v, vppf) +
"))";
1739 res +=
" << (" +
STR(op2_size) +
" + " +
PrintNode(te->op2, v, vppf) +
")) | (( " +
1741 res +=
PrintNode(te->op2, v, vppf) +
") | ((" +
PrintNode(te->op0, v, vppf) +
" << " +
1743 res +=
") >> " +
PrintNode(te->op2, v, vppf) +
")))";
1746 case extractelement_expr_K:
1748 const auto be = GetPointerS<const extractvalue_expr>(node);
1754 case insertelement_expr_K:
1756 const auto iee = GetPointerS<const insertelement_expr>(node);
1760 const auto vector_size = size / element_size;
1762 res +=
"/*" + iee->get_kind_text() +
"*/";
1765 for(
unsigned int ind = 0; ind < vector_size; ++ind)
1767 res +=
"(" +
PrintNode(iee->op2, v, vppf) +
" == " +
STR(ind) +
" ? " +
PrintNode(iee->op1, v, vppf) +
1768 " : " +
PrintNode(iee->op0, v, vppf) +
"[" +
STR(ind) +
"])";
1769 if(ind != vector_size - 1)
1777 case pointer_plus_expr_K:
1779 const auto ppe = GetPointerS<const pointer_plus_expr>(node);
1791 bool do_reverse_pointer_arithmetic =
false;
1795 right_op_node->get_kind_text());
1796 const auto right_cost = right_op_node->get_kind() == integer_cst_K;
1799 "expected a pointer type: " +
GET_NODE(ppe->type)->get_kind_text() +
" - " +
STR(ppe->type));
1802 unsigned long long deltabit;
1805 "Pointed type (" +
STR(pointed_type) +
") is " +
GET_CONST_NODE(pointed_type)->get_kind_text());
1808 const auto vt = GetPointerS<const void_type>(
GET_CONST_NODE(pointed_type));
1809 deltabit = vt->algn;
1817 std::string right_offset_var;
1822 if(deltabit / 8 == 0)
1824 do_reverse_pointer_arithmetic =
false;
1826 else if(
GET_CONST_NODE(pointed_type)->get_kind() != array_type_K && deltabit && pointer_offset > deltabit &&
1827 ((pointer_offset % (deltabit / 8)) == 0))
1830 const auto ic = GetPointerS<const integer_cst>(right_op_node);
1831 const auto it = GetPointer<const integer_type>(
GET_CONST_NODE(ic->type));
1832 if(it && (it->prec == 32))
1834 pointer_offset =
static_cast<unsigned int>(pointer_offset / (deltabit / 8));
1838 pointer_offset = pointer_offset / (deltabit / 8);
1840 do_reverse_pointer_arithmetic =
true;
1845 "Arithmetic pointer pattern not matched " +
STR(pointer_offset) +
" vs " +
1852 bool exit =
GET_CONST_NODE(pointed_type)->get_kind() == array_type_K;
1853 while(!do_reverse_pointer_arithmetic && !exit)
1855 switch(right_op_node->get_kind())
1859 if(GetPointerS<const ssa_name>(right_op_node)->CGetDefStmts().empty())
1864 const auto rssa = GetPointerS<const ssa_name>(right_op_node);
1866 if(defstmt->get_kind() != gimple_assign_K)
1871 right_op_node =
GET_NODE(GetPointerS<const gimple_assign>(defstmt)->op1);
1873 "New op node is " +
STR(right_op_node->index) +
" - " +
1874 right_op_node->get_kind_text());
1877 case mult_highpart_expr_K:
1884 const auto mult = GetPointerS<const mult_expr>(right_op_node);
1885 if(
GET_NODE(mult->op1)->get_kind() == integer_cst_K)
1888 "-->Right part of multiply is an integer constant " +
1892 "---Size of pointer is " +
STR(size_of_pointer));
1893 if(size_of_pointer == (deltabit / 8))
1896 right_offset_var +=
PrintNode(mult->op0, v, vppf);
1897 do_reverse_pointer_arithmetic =
true;
1902 "-->Constant is not the size of the pointed: " +
STR(size_of_pointer) +
1903 " vs " +
STR(deltabit / 8));
1907 " is not an integer type");
1908 const auto it = GetPointerS<const integer_type>(
GET_CONST_NODE(temp1));
1910 const auto new_size_of_pointer = max_int + 1 - size_of_pointer;
1911 if(new_size_of_pointer == (deltabit / 8))
1914 "---Constant is minus the size of the pointed");
1915 right_offset_var +=
"-(" +
PrintNode(mult->op0, v, vppf) +
")";
1916 do_reverse_pointer_arithmetic =
true;
1918 else if(deltabit && (deltabit / 8) && (size_of_pointer % ((deltabit / 8)) == 0))
1921 "---Constant is a multiple of the size of the pointed");
1922 right_offset_var +=
PrintNode(mult->op0, v, vppf);
1923 right_offset_var +=
" * ";
1924 right_offset_var +=
STR(size_of_pointer / ((deltabit / 8)));
1925 do_reverse_pointer_arithmetic =
true;
1930 "<--Right offset variable is " + right_offset_var);
1932 else if(
GET_NODE(mult->op0)->get_kind() == integer_cst_K)
1935 if(size_of_pointer == (deltabit / 8))
1937 right_offset_var +=
PrintNode(mult->op1, v, vppf);
1938 do_reverse_pointer_arithmetic =
true;
1945 " is not an integer type");
1946 const auto it = GetPointerS<const integer_type>(
GET_CONST_NODE(temp1));
1948 const auto new_size_of_pointer = max_int + 1 - size_of_pointer;
1949 if(new_size_of_pointer == (deltabit / 8))
1951 right_offset_var +=
"-" +
PrintNode(mult->op1, v, vppf);
1952 do_reverse_pointer_arithmetic =
true;
1954 else if((deltabit / 8) && (size_of_pointer % ((deltabit / 8)) == 0))
1956 right_offset_var +=
PrintNode(mult->op1, v, vppf);
1957 right_offset_var +=
" * ";
1958 right_offset_var +=
STR(size_of_pointer / ((deltabit / 8)));
1959 do_reverse_pointer_arithmetic =
true;
1968 const auto ne = GetPointerS<const negate_expr>(right_op_node);
1969 right_offset_var +=
"-";
1973 right_op_node->get_kind_text());
1979 const auto ne = GetPointerS<const nop_expr>(right_op_node);
1983 right_op_node->get_kind_text());
1989 case aggr_init_expr_K:
1990 case case_label_expr_K:
1992 case identifier_node_K:
1993 case statement_list_K:
1995 case target_mem_ref_K:
1996 case target_mem_ref461_K:
2000 case alignof_expr_K:
2002 case bit_not_expr_K:
2005 case cleanup_point_expr_K:
2007 case convert_expr_K:
2009 case fix_ceil_expr_K:
2010 case fix_floor_expr_K:
2011 case fix_round_expr_K:
2012 case fix_trunc_expr_K:
2014 case imagpart_expr_K:
2015 case indirect_ref_K:
2016 case misaligned_indirect_ref_K:
2018 case non_lvalue_expr_K:
2019 case realpart_expr_K:
2020 case reference_expr_K:
2021 case reinterpret_cast_expr_K:
2023 case static_cast_expr_K:
2025 case truth_not_expr_K:
2028 case view_convert_expr_K:
2029 case reduc_max_expr_K:
2030 case reduc_min_expr_K:
2031 case reduc_plus_expr_K:
2032 case vec_unpack_hi_expr_K:
2033 case vec_unpack_lo_expr_K:
2034 case vec_unpack_float_hi_expr_K:
2035 case vec_unpack_float_lo_expr_K:
2038 case bit_and_expr_K:
2039 case bit_ior_expr_K:
2040 case bit_xor_expr_K:
2042 case ceil_div_expr_K:
2043 case ceil_mod_expr_K:
2044 case complex_expr_K:
2045 case compound_expr_K:
2046 case eh_filter_expr_K:
2048 case exact_div_expr_K:
2050 case floor_div_expr_K:
2051 case floor_mod_expr_K:
2054 case goto_subroutine_K:
2058 case lrotate_expr_K:
2068 case ordered_expr_K:
2070 case pointer_plus_expr_K:
2071 case postdecrement_expr_K:
2072 case postincrement_expr_K:
2073 case predecrement_expr_K:
2074 case preincrement_expr_K:
2077 case round_div_expr_K:
2078 case round_mod_expr_K:
2079 case rrotate_expr_K:
2082 case trunc_div_expr_K:
2083 case trunc_mod_expr_K:
2084 case truth_and_expr_K:
2085 case truth_andif_expr_K:
2086 case truth_or_expr_K:
2087 case truth_orif_expr_K:
2088 case truth_xor_expr_K:
2089 case try_catch_expr_K:
2097 case unordered_expr_K:
2098 case widen_sum_expr_K:
2099 case widen_mult_expr_K:
2100 case with_size_expr_K:
2101 case vec_lshift_expr_K:
2102 case vec_rshift_expr_K:
2103 case widen_mult_hi_expr_K:
2104 case widen_mult_lo_expr_K:
2105 case vec_pack_trunc_expr_K:
2106 case vec_pack_sat_expr_K:
2107 case vec_pack_fix_trunc_expr_K:
2108 case vec_extracteven_expr_K:
2109 case vec_extractodd_expr_K:
2110 case vec_interleavehigh_expr_K:
2111 case vec_interleavelow_expr_K:
2113 case extract_bit_expr_K:
2114 case sat_plus_expr_K:
2115 case sat_minus_expr_K:
2116 case extractvalue_expr_K:
2117 case extractelement_expr_K:
2138 do_reverse_pointer_arithmetic =
true;
2139 right_offset_var =
PrintNode(ppe->op1, v, vppf);
2142 bool char_pointer =
false;
2143 if(!do_reverse_pointer_arithmetic &&
2147 "Reversing pointer arithmetic sucessful because of char pointer");
2148 do_reverse_pointer_arithmetic =
true;
2149 char_pointer =
true;
2151 if(binary_op_cast && !do_reverse_pointer_arithmetic)
2157 res +=
"((unsigned char*)";
2165 res += std::string(
" ") + op +
" ";
2176 if(do_reverse_pointer_arithmetic && !char_pointer)
2178 if(right_offset_var !=
"")
2180 res += right_offset_var;
2184 res +=
STR(pointer_offset);
2185 const auto type =
GET_NODE(GetPointerS<const integer_cst>(right_op_node)->
type);
2186 const auto it = GetPointer<const integer_type>(
type);
2187 bool unsigned_flag = (it && it->unsigned_flag) ||
type->get_kind() == pointer_type_K ||
2188 type->get_kind() == boolean_type_K ||
type->get_kind() == enumeral_type_K;
2197 if(right_op_node->get_kind() == integer_cst_K)
2206 if(binary_op_cast && !do_reverse_pointer_arithmetic)
2227 const auto be = GetPointerS<const binary_expr>(node);
2228 const auto& left_op = be->op0;
2229 const auto& right_op = be->op1;
2240 const auto vector_size = size / element_size;
2243 for(
unsigned int ind = 0; ind < vector_size; ++ind)
2245 res +=
"(" +
PrintNode(left_op, v, vppf) +
")[" +
STR(ind) +
"] " + op +
" (" +
2247 if(ind != vector_size - 1)
2261 const auto left_op_bracket =
2262 !(GetPointer<decl_node>(
GET_NODE(be->op0)) || GetPointer<ssa_name>(
GET_NODE(be->op0)));
2263 const auto right_op_bracket =
2264 !(GetPointer<decl_node>(
GET_NODE(be->op1)) || GetPointer<ssa_name>(
GET_NODE(be->op1)));
2272 res +=
"((unsigned long int)";
2297 res += std::string(
" ") + op +
" ";
2298 if(right_op_bracket)
2304 res +=
"((unsigned long int)";
2313 if(right_op_bracket)
2324 case rrotate_expr_K:
2325 case lrotate_expr_K:
2333 const auto be = GetPointerS<const binary_expr>(node);
2334 const auto& left_op = be->op0;
2335 const auto& right_op = be->op1;
2340 res +=
"((unsigned long int)";
2347 if(node->get_kind() == rrotate_expr_K)
2357 res +=
"((unsigned long int)";
2367 res +=
"((unsigned long int)";
2374 if(node->get_kind() == rrotate_expr_K)
2385 res +=
"((unsigned long int)";
2401 const auto le = GetPointerS<const lut_expr>(node);
2402 std::string concat_shift_string;
2413 concat_shift_string = concat_shift_string +
"((" +
PrintNode(le->op6, v, vppf) +
")<<5) | ";
2417 concat_shift_string = concat_shift_string +
"((" +
PrintNode(le->op5, v, vppf) +
")<<4) | ";
2421 concat_shift_string = concat_shift_string +
"((" +
PrintNode(le->op4, v, vppf) +
")<<3) | ";
2425 concat_shift_string = concat_shift_string +
"((" +
PrintNode(le->op3, v, vppf) +
")<<2) | ";
2429 concat_shift_string = concat_shift_string +
"((" +
PrintNode(le->op2, v, vppf) +
")<<1) | ";
2431 concat_shift_string = concat_shift_string +
"(" +
PrintNode(le->op1, v, vppf) +
")";
2432 res = res +
"(" +
PrintNode(le->op0->index, v, vppf) +
">>(" + concat_shift_string +
"))&1";
2436 case bit_not_expr_K:
2437 case reference_expr_K:
2438 case predecrement_expr_K:
2439 case preincrement_expr_K:
2441 const auto ue = GetPointerS<const unary_expr>(node);
2443 res = res +
" " + op +
"(" +
PrintNode(ue->op, v, vppf) +
")";
2446 case truth_not_expr_K:
2448 const auto te = GetPointerS<const truth_not_expr>(node);
2454 const auto vector_size = size / element_size;
2457 for(
unsigned int ind = 0; ind < vector_size; ++ind)
2459 res +=
" !(" +
PrintNode(te->op, v, vppf) +
")[" +
STR(ind) +
"]";
2460 if(ind != vector_size - 1)
2470 res = res +
" " + op +
"(" +
PrintNode(te->op, v, vppf) +
")";
2475 case realpart_expr_K:
2476 case imagpart_expr_K:
2479 const auto ue = GetPointerS<const unary_expr>(node);
2480 res = res +
" " + op +
PrintNode(ue->op, v, vppf);
2481 const auto sa = GetPointer<const ssa_name>(
GET_CONST_NODE(ue->op));
2482 if(sa && (sa->volatile_flag || (
GET_NODE(sa->CGetDefStmt())->get_kind() == gimple_nop_K)) &&
2483 (sa->var && GetPointer<const var_decl>(
GET_CONST_NODE(sa->var))))
2491 const auto ue = GetPointerS<const addr_expr>(node);
2499 const auto ar = GetPointerS<const array_ref>(
GET_CONST_NODE(ue->op));
2501 if(
GET_NODE(ar->op0)->get_kind() == string_cst_K &&
GET_CONST_NODE(ar->op1)->get_kind() == integer_cst_K &&
2509 if(
GET_NODE(ue->op)->get_kind() == var_decl_K &&
2517 res +=
"&&" +
PrintNode(ue->op, v, vppf);
2523 case function_decl_K:
2525 const auto fd = GetPointerS<const function_decl>(node);
2529 case fix_trunc_expr_K:
2530 case fix_ceil_expr_K:
2531 case fix_floor_expr_K:
2532 case fix_round_expr_K:
2534 case convert_expr_K:
2537 const auto ue = GetPointerS<const unary_expr>(node);
2539 unsigned int prec = 0;
2540 unsigned int algn = 0;
2543 prec = GetPointerS<const integer_type>(
GET_CONST_NODE(type))->prec;
2544 algn = GetPointerS<const integer_type>(
GET_CONST_NODE(type))->algn;
2548 unsigned int operand_prec = 0;
2549 unsigned int operand_algn = 0;
2550 if(operand_type &&
GET_CONST_NODE(operand_type)->get_kind() == integer_type_K)
2552 operand_prec = GetPointerS<const integer_type>(
GET_CONST_NODE(operand_type))->prec;
2553 operand_algn = GetPointerS<const integer_type>(
GET_CONST_NODE(operand_type))->algn;
2556 std::string operand_res =
PrintNode(ue->op, v, vppf);
2557 if(operand_prec != operand_algn && operand_prec % operand_algn &&
2562 operand_res +
"}).bitfield";
2564 if(type && (type->get_kind() == boolean_type_K))
2571 else if(prec != algn && prec % algn)
2586 if(GetPointerS<const integer_type>(
GET_CONST_NODE(type))->unsigned_flag)
2590 res +=
" << " +
STR(prec) +
")";
2593 res += std::string(
" << ") +
STR(algn - prec) +
")) >> " +
STR(algn - prec);
2604 case view_convert_expr_K:
2606 const auto vce = GetPointerS<const view_convert_expr>(node);
2609 res = res +
"__panda_union.dest;}";
2625 case component_ref_K:
2627 const auto cr = GetPointerS<const component_ref>(node);
2631 case indirect_ref_K:
2633 const auto ir = GetPointerS<const indirect_ref>(node);
2635 if(GetPointer<const integer_cst>(
GET_NODE(ir->op)))
2643 case misaligned_indirect_ref_K:
2645 const auto mir = GetPointerS<const misaligned_indirect_ref>(node);
2646 res =
"*(" +
PrintNode(mir->op, v, vppf) +
")";
2651 const auto mr = GetPointerS<const mem_ref>(node);
2658 res =
"(*((" + type_string +
")(" +
PrintNode(mr->op0, v, vppf) +
")))";
2662 res =
"(*((" + type_string +
")(((unsigned char*)" +
PrintNode(mr->op0, v, vppf) +
") + " +
STR(offset) +
2667 case target_mem_ref_K:
2669 const auto tmr = GetPointerS<const target_mem_ref>(node);
2670 bool need_plus =
false;
2674 res +=
"((unsigned char*)" +
2692 res +=
"(" +
PrintNode(tmr->base, v, vppf) +
")";
2696 res +=
"((unsigned char*)" +
PrintNode(tmr->base, v, vppf) +
")";
2706 res +=
PrintNode(tmr->step, v, vppf) +
"*";
2732 case target_mem_ref461_K:
2734 const auto tmr = GetPointerS<const target_mem_ref461>(node);
2735 bool need_plus =
false;
2737 res = isFunctionPointer ?
"(" :
"(*((";
2739 res += isFunctionPointer ?
")(" :
"*)(";
2743 res +=
"((unsigned char*)" +
2755 res +=
PrintNode(tmr->step, v, vppf) +
"*";
2790 res += isFunctionPointer ?
")" :
")))";
2795 const auto ar = GetPointerS<const array_ref>(node);
2798 if(base->get_kind() == mem_ref_K)
2800 const auto mr = GetPointerS<const mem_ref>(
base);
2805 size_t found_square_bracket = type_string.find(
'[');
2806 if(found_square_bracket != std::string::npos)
2808 type_string.insert(found_square_bracket,
"(*)");
2812 type_string = type_string +
"*";
2817 type_string = type_string +
"*";
2821 res =
"(*((" + type_string +
")(" +
PrintNode(mr->op0, v, vppf) +
")))";
2825 res =
"(*((" + type_string +
")(((unsigned char*)" +
PrintNode(mr->op0, v, vppf) +
") + " +
STR(offset) +
2831 res =
"(" +
PrintNode(ar->op0, v, vppf) +
")";
2833 res +=
"[" +
PrintNode(ar->op1, v, vppf) +
"]";
2836 case bit_field_ref_K:
2838 const auto bf = GetPointerS<const bit_field_ref>(node);
2841 PrintNode(bf->op0, v, vppf) +
")) + (unsigned long int)" +
STR(bpos / 8) +
"))";
2844 res +=
" >> " +
STR(bpos % 8);
2849 case postdecrement_expr_K:
2850 case postincrement_expr_K:
2853 const auto be = GetPointerS<const binary_expr>(node);
2859 const auto me = GetPointerS<const min_expr>(node);
2865 const auto vector_size = size / element_size;
2866 res +=
"/*" + me->get_kind_text() +
"*/";
2869 for(
unsigned int ind = 0; ind < vector_size; ++ind)
2871 res +=
"(" +
PrintNode(me->op0, v, vppf) +
")[" +
STR(ind) +
"] < (" +
PrintNode(me->op1, v, vppf) +
2872 ")[" +
STR(ind) +
"] ? " +
"(" +
PrintNode(me->op0, v, vppf) +
")[" +
STR(ind) +
"]" +
" : " +
2873 "(" +
PrintNode(me->op1, v, vppf) +
")[" +
STR(ind) +
"]";
2874 if(ind != vector_size - 1)
2884 res += op_0 +
" < " + op_1 +
" ? " + op_0 +
" : " + op_1;
2890 const auto me = GetPointerS<const max_expr>(node);
2896 const auto vector_size = size / element_size;
2897 res +=
"/*" + me->get_kind_text() +
"*/";
2900 for(
unsigned int ind = 0; ind < vector_size; ++ind)
2902 res +=
"(" +
PrintNode(me->op0, v, vppf) +
")[" +
STR(ind) +
"] > (" +
PrintNode(me->op1, v, vppf) +
2903 ")[" +
STR(ind) +
"] ? " +
"(" +
PrintNode(me->op0, v, vppf) +
")[" +
STR(ind) +
"]" +
" : " +
2904 "(" +
PrintNode(me->op1, v, vppf) +
")[" +
STR(ind) +
"]";
2905 if(ind != vector_size - 1)
2915 res += op_0 +
" > " + op_1 +
" ? " + op_0 +
" : " + op_1;
2919 case unordered_expr_K:
2921 const auto be = GetPointerS<const binary_expr>(node);
2923 res +=
"__builtin_isunordered(" + op_0 +
"," + op_1 +
")";
2926 case ordered_expr_K:
2928 const auto be = GetPointerS<const binary_expr>(node);
2930 res +=
"!__builtin_isunordered(" + op_0 +
"," + op_1 +
")";
2935 const auto be = GetPointerS<const binary_expr>(node);
2937 res +=
"!__builtin_isgreaterequal(" + op_0 +
"," + op_1 +
")";
2942 const auto be = GetPointerS<const binary_expr>(node);
2944 res +=
"!__builtin_isgreater(" + op_0 +
"," + op_1 +
")";
2949 const auto be = GetPointerS<const binary_expr>(node);
2951 res +=
"!__builtin_islessequal(" + op_0 +
"," + op_1 +
")";
2956 const auto be = GetPointerS<const binary_expr>(node);
2958 res +=
"!__builtin_isless(" + op_0 +
"," + op_1 +
")";
2963 const auto be = GetPointerS<const binary_expr>(node);
2965 res +=
"!__builtin_islessgreater(" + op_0 +
"," + op_1 +
")";
2970 const auto be = GetPointerS<const binary_expr>(node);
2972 res +=
"__builtin_islessgreater(" + op_0 +
"," + op_1 +
")";
2977 const auto ae = GetPointerS<const abs_expr>(node);
2978 std::string op_0 =
PrintNode(ae->op, v, vppf);
2981 const auto rt = GetPointerS<const real_type>(
GET_CONST_NODE(ae->type));
2984 res +=
"__builtin_fabsl(" + op_0 +
")";
2986 else if(rt->prec == 64)
2988 res +=
"__builtin_fabs(" + op_0 +
")";
2990 else if(rt->prec == 32)
2992 res +=
"__builtin_fabsf(" + op_0 +
")";
2996 THROW_ERROR(
"Abs on a real number with not supported precision");
3001 res +=
"(" + op_0 +
") >= 0 ? (" + op_0 +
") : -(" + op_0 +
")";
3006 case complex_expr_K:
3008 const auto ce = GetPointerS<const complex_expr>(node);
3010 res += op_0 +
"+ 1i*" + op_1;
3015 const auto ce = GetPointerS<const cond_expr>(node);
3019 case ternary_plus_expr_K:
3021 const auto te = GetPointerS<const ternary_expr>(node);
3025 case ternary_pm_expr_K:
3027 const auto te = GetPointerS<const ternary_expr>(node);
3031 case ternary_mp_expr_K:
3033 const auto te = GetPointerS<const ternary_expr>(node);
3037 case ternary_mm_expr_K:
3039 const auto te = GetPointerS<const ternary_expr>(node);
3046 const auto te = GetPointerS<const ternary_expr>(node);
3053 res +=
"((unsigned long int)";
3061 if(node->get_kind() == fshl_expr_K)
3065 res +=
STR(type_size);
3069 res +=
STR(type_size);
3073 res +=
STR(type_size);
3080 res +=
"((unsigned long int)";
3088 if(node->get_kind() == fshr_expr_K)
3092 res +=
STR(type_size);
3096 res +=
STR(type_size);
3100 res +=
STR(type_size);
3106 case bit_ior_concat_expr_K:
3108 const auto te = GetPointerS<const ternary_expr>(node);
3109 res =
PrintNode(te->op0, v, vppf) +
" | (" +
PrintNode(te->op1, v, vppf) +
" & ((1ULL<<" +
3113 case vec_cond_expr_K:
3115 auto vce = GetPointerS<const vec_cond_expr>(node);
3119 const auto vector_size = size / element_size;
3120 res +=
"/*" + vce->get_kind_text() +
"*/";
3123 for(
unsigned int ind = 0; ind < vector_size; ++ind)
3125 res +=
"(" +
PrintNode(vce->op0, v, vppf) +
")" +
3128 ")[" +
STR(ind) +
"]";
3129 if(ind != vector_size - 1)
3137 case vec_perm_expr_K:
3139 const auto vpe = GetPointerS<const vec_perm_expr>(node);
3143 const auto vector_size = size / element_size;
3144 res +=
"/*" + vpe->get_kind_text() +
"*/";
3147 for(
unsigned int ind = 0; ind < vector_size; ++ind)
3149 res +=
"((((" +
PrintNode(vpe->op2, v, vppf) +
")[" +
STR(ind) +
"])%" +
STR(2 * vector_size) +
") < " +
3150 STR(vector_size) +
") ? (" +
PrintNode(vpe->op0, v, vppf) +
")[(((" +
PrintNode(vpe->op2, v, vppf) +
3151 ")[" +
STR(ind) +
"])%" +
STR(2 * vector_size) +
")] : (" +
PrintNode(vpe->op1, v, vppf) +
")[(((" +
3152 PrintNode(vpe->op2, v, vppf) +
")[" +
STR(ind) +
"])%" +
STR(2 * vector_size) +
")-" +
3153 STR(vector_size) +
"]";
3154 if(ind != vector_size - 1)
3164 const auto gc = GetPointerS<const gimple_cond>(node);
3165 for(
const auto& pragma : gc->pragmas)
3167 res +=
PrintNode(pragma, v, vppf) +
"\n";
3169 res =
"if (" +
PrintNode(gc->op0, v, vppf) +
")";
3172 case gimple_multi_way_if_K:
3174 const auto gmwi = GetPointerS<const gimple_multi_way_if>(node);
3177 for(
const auto& cond : gmwi->list_of_cond)
3181 THROW_ASSERT(cond.first,
"First condition of multi way if " +
STR(node->index) +
" is empty");
3187 res +=
" /* else if(" +
PrintNode(cond.first, v, vppf) +
")*/";
3193 case gimple_while_K:
3195 const auto we = GetPointerS<const gimple_while>(node);
3196 res =
"while (" +
PrintNode(we->op0, v, vppf) +
")";
3201 const auto fe = GetPointerS<const gimple_for>(node);
3205 res =
"//#pragma omp " +
PrintNode(fe->omp_for, v, vppf) +
"\n";
3208 res +=
"for (" +
PrintNode(fe->op1, v, vppf) +
"; ";
3209 res +=
PrintNode(fe->op0, v, vppf) +
"; ";
3214 case gimple_switch_K:
3216 const auto se = GetPointerS<const gimple_switch>(node);
3217 res +=
"switch(" +
PrintNode(se->op0, v, vppf) +
")";
3220 case gimple_assign_K:
3222 const auto ms = GetPointerS<const gimple_assign>(node);
3223 if(!ms->init_assignment && !ms->clobber)
3225 for(
const auto& pragma : ms->pragmas)
3227 res +=
PrintNode(pragma, v, vppf) +
"\n";
3233 res +=
"__builtin_memcpy(";
3238 res +=
PrintNode(ms->op0, v, vppf) +
", ";
3241 const auto vce = GetPointerS<const view_convert_expr>(
GET_CONST_NODE(ms->op1));
3242 res +=
"&" +
PrintNode(vce->op, v, vppf) +
", ";
3250 res +=
PrintNode(ms->op1, v, vppf) +
", ";
3252 res +=
STR(size / 8) +
")";
3255 if((!
Param->getOption<
bool>(OPT_without_transformation)) &&
3263 "Implicit struct type definition not supported in gimple assignment " +
STR(node->index) +
" - " +
3267 res +=
PrintNode(ms->op0, v, vppf) +
" = ";
3270 switch(right->get_kind())
3280 const auto vc = GetPointerS<const vector_cst>(right);
3292 case aggr_init_expr_K:
3293 case case_label_expr_K:
3294 case identifier_node_K:
3296 case statement_list_K:
3298 case target_mem_ref_K:
3299 case target_mem_ref461_K:
3325 if((right->get_kind() == rshift_expr_K || right->get_kind() == lshift_expr_K) &&
3328 res +=
"(unsigned int)";
3339 const auto vce = GetPointer<const view_convert_expr>(right);
3346 " source;} __panda_union; __panda_union.source = " +
PrintNode(vce->op, v, vppf) +
"; " + res;
3351 res =
"if(" +
PrintNode(ms->predicate, v, vppf) +
") " + res;
3356 const auto tde = GetPointerS<const binary_expr>(
GET_CONST_NODE(ms->op1));
3357 res =
"if(" +
PrintNode(tde->op1, v, vppf) +
" != 0) " + res;
3363 res +=
"/*gimple_nop*/";
3368 const auto be = GetPointerS<const binary_expr>(node);
3369 res =
PrintNode(be->op0, v, vppf) +
" = ";
3372 switch(right->get_kind())
3374 case fix_trunc_expr_K:
3375 case fix_ceil_expr_K:
3376 case fix_floor_expr_K:
3377 case fix_round_expr_K:
3379 case convert_expr_K:
3380 case view_convert_expr_K:
3384 const auto ue = GetPointerS<const unary_expr>(right);
3392 case aggr_init_expr_K:
3393 case case_label_expr_K:
3395 case identifier_node_K:
3397 case statement_list_K:
3399 case target_mem_ref_K:
3400 case target_mem_ref461_K:
3405 case alignof_expr_K:
3407 case bit_not_expr_K:
3410 case cleanup_point_expr_K:
3413 case imagpart_expr_K:
3414 case indirect_ref_K:
3415 case misaligned_indirect_ref_K:
3418 case non_lvalue_expr_K:
3419 case realpart_expr_K:
3420 case reference_expr_K:
3421 case reinterpret_cast_expr_K:
3423 case static_cast_expr_K:
3425 case truth_not_expr_K:
3428 case reduc_max_expr_K:
3429 case reduc_min_expr_K:
3430 case reduc_plus_expr_K:
3431 case vec_unpack_hi_expr_K:
3432 case vec_unpack_lo_expr_K:
3433 case vec_unpack_float_hi_expr_K:
3434 case vec_unpack_float_lo_expr_K:
3452 case gimple_return_K:
3454 const auto re = GetPointerS<const gimple_return>(node);
3455 for(
const auto& pragma : re->pragmas)
3457 res +=
PrintNode(pragma, v, vppf) +
"\n";
3460 if(re->op !=
nullptr)
3464 switch(return_node->get_kind())
3466 case fix_trunc_expr_K:
3467 case fix_ceil_expr_K:
3468 case fix_floor_expr_K:
3469 case fix_round_expr_K:
3471 case convert_expr_K:
3474 const auto ue = GetPointerS<const unary_expr>(return_node);
3489 case aggr_init_expr_K:
3490 case case_label_expr_K:
3491 case identifier_node_K:
3493 case statement_list_K:
3495 case target_mem_ref_K:
3496 case target_mem_ref461_K:
3501 case alignof_expr_K:
3503 case bit_not_expr_K:
3506 case cleanup_point_expr_K:
3509 case imagpart_expr_K:
3510 case indirect_ref_K:
3511 case misaligned_indirect_ref_K:
3514 case non_lvalue_expr_K:
3515 case realpart_expr_K:
3516 case reference_expr_K:
3517 case reinterpret_cast_expr_K:
3519 case static_cast_expr_K:
3521 case truth_not_expr_K:
3524 case reduc_max_expr_K:
3525 case reduc_min_expr_K:
3526 case reduc_plus_expr_K:
3527 case vec_unpack_hi_expr_K:
3528 case vec_unpack_lo_expr_K:
3529 case vec_unpack_float_hi_expr_K:
3530 case vec_unpack_float_lo_expr_K:
3531 case view_convert_expr_K:
3556 case aggr_init_expr_K:
3558 const auto ce = GetPointerS<const call_expr>(node);
3561 bool is_va_start_end =
false;
3564 bool is_sizeof =
false;
3565 auto op0_kind = op0->get_kind();
3571 const auto ue = GetPointerS<const unary_expr>(op0);
3574 "tree node not currently supported " + fn->get_kind_text());
3575 fd = GetPointerS<const function_decl>(fn);
3578 if(fname ==
"__builtin_va_start" || fname ==
"__builtin_va_end" || fname ==
"__builtin_va_copy")
3580 is_va_start_end =
true;
3582 if(fname ==
"__builtin_constant_p")
3599 res +=
"(*" +
PrintNode(ce->fn, v, vppf) +
")";
3605 case aggr_init_expr_K:
3606 case case_label_expr_K:
3608 case identifier_node_K:
3609 case statement_list_K:
3610 case target_mem_ref_K:
3611 case target_mem_ref461_K:
3616 if(op0_kind == obj_type_ref_K)
3620 "tree node not currently supported " +
GET_CONST_NODE(fn)->get_kind_text());
3621 const auto local_fd = GetPointerS<const function_decl>(
GET_CONST_NODE(fn));
3630 THROW_ERROR(std::string(
"tree node not currently supported ") + op0->get_kind_text());
3650 THROW_ERROR(std::string(
"tree node not currently supported ") + op0->get_kind_text());
3657 THROW_ASSERT(ce->args.size(),
"va_start or va_end have to have arguments");
3660 if(GetPointer<const addr_expr>(par1))
3662 res +=
PrintNode(GetPointerS<const addr_expr>(par1)->op, v, vppf);
3664 else if(GetPointer<const var_decl>(par1) || GetPointer<const ssa_name>(par1))
3666 res +=
"*(" +
PrintNode(par1, v, vppf) +
")";
3670 THROW_ERROR(
"expected an address or a variable " +
STR(par1->index));
3672 for(
size_t arg_index = 1; arg_index < ce->args.size(); arg_index++)
3675 res +=
PrintNode(ce->args[arg_index], v, vppf);
3680 THROW_ASSERT(ce->args.size() == 1,
"Wrong number of arguments: " +
STR(ce->args.size()));
3681 std::string argument =
PrintNode(ce->args[0], v, vppf);
3684 "Argument is not an addr_expr but a " + std::string(arg1->get_kind_text()));
3685 const auto ae = GetPointer<const addr_expr>(arg1);
3690 "Argument is not an array ref but a " +
3691 std::string(GET_CONST_NODE(ae->op)->get_kind_text()));
3693 const auto ar = GetPointerS<const array_ref>(
GET_CONST_NODE(ae->op));
3696 "Argument is not a string cast but a " +
3697 std::string(GET_CONST_NODE(ar->op0)->get_kind_text()));
3698 std::string unquoted_argument = argument.substr(1, argument.size() - 2);
3699 res += unquoted_argument;
3705 "Argument is not a string cast but a " +
3706 std::string(GET_CONST_NODE(ae->op)->get_kind_text()));
3707 std::string unquoted_argument = argument.substr(3, argument.size() - 6);
3708 res += unquoted_argument;
3715 const auto& actual_args = ce->args;
3716 std::vector<tree_nodeRef> formal_args;
3719 formal_args = fd->list_of_args;
3721 std::vector<tree_nodeRef>::const_iterator actual_arg, actual_arg_end = actual_args.end();
3722 std::vector<tree_nodeRef>::const_iterator formal_arg, formal_arg_end = formal_args.end();
3723 for(actual_arg = actual_args.begin(), formal_arg = formal_args.begin(); actual_arg != actual_arg_end;
3726 if(formal_arg != formal_arg_end &&
3735 if(actual_arg != actual_args.begin())
3740 if(formal_arg != formal_arg_end)
3752 const auto ce = GetPointerS<const gimple_call>(node);
3754 for(
const auto& pragma : ce->pragmas)
3756 res +=
PrintNode(pragma, v, vppf) +
"\n";
3759 bool is_va_start_end =
false;
3762 bool is_sizeof =
false;
3763 auto op0_kind = op0->get_kind();
3769 const auto ue = GetPointerS<const unary_expr>(op0);
3772 "tree node not currently supported " + fn->get_kind_text());
3773 fd = GetPointerS<const function_decl>(fn);
3776 if(fname ==
"__builtin_va_start" || fname ==
"__builtin_va_end" || fname ==
"__builtin_va_copy")
3778 is_va_start_end =
true;
3780 if(fname ==
"__builtin_constant_p")
3797 res +=
"(*" +
PrintNode(ce->fn, v, vppf) +
")";
3803 case aggr_init_expr_K:
3804 case case_label_expr_K:
3806 case identifier_node_K:
3807 case statement_list_K:
3808 case target_mem_ref_K:
3809 case target_mem_ref461_K:
3814 if(op0_kind == obj_type_ref_K)
3818 "tree node not currently supported " + fn->get_kind_text());
3819 const auto local_fd = GetPointerS<const function_decl>(
GET_CONST_NODE(fn));
3828 THROW_ERROR(std::string(
"tree node not currently supported ") + op0->get_kind_text());
3848 THROW_ERROR(std::string(
"tree node not currently supported ") + op0->get_kind_text());
3855 THROW_ASSERT(ce->args.size(),
"va_start or va_end have to have arguments");
3858 if(GetPointer<const addr_expr>(par1))
3860 res +=
PrintNode(GetPointerS<const addr_expr>(par1)->op, v, vppf);
3862 else if(GetPointer<const var_decl>(par1) || GetPointer<const ssa_name>(par1))
3864 res +=
"*(" +
PrintNode(par1, v, vppf) +
")";
3870 for(
size_t arg_index = 1; arg_index < ce->args.size(); arg_index++)
3873 res +=
PrintNode(ce->args[arg_index], v, vppf);
3878 THROW_ASSERT(ce->args.size() == 1,
"Wrong number of arguments: " +
STR(ce->args.size()));
3882 "Argument is not an addr_expr but a " + std::string(arg1->get_kind_text()));
3883 const auto ae = GetPointerS<const addr_expr>(arg1);
3887 "Argument is not an array ref but a " +
3888 std::string(GET_CONST_NODE(ae->op)->get_kind_text()));
3889 const auto ar = GetPointer<const array_ref>(
GET_CONST_NODE(ae->op));
3891 "Argument is not a string cast but a " +
3892 std::string(GET_CONST_NODE(ar->op0)->get_kind_text()));
3897 "Argument is not a string cast but a " +
3898 std::string(GET_CONST_NODE(ae->op)->get_kind_text()));
3901 const auto argument =
PrintNode(ce->args[0], v, vppf);
3902 const auto unquoted_argument = argument.substr(1, argument.size() - 2);
3903 res += unquoted_argument;
3909 const auto& actual_args = ce->args;
3910 std::vector<tree_nodeRef> formal_args;
3913 formal_args = fd->list_of_args;
3915 std::vector<tree_nodeRef>::const_iterator actual_arg, actual_arg_end = actual_args.end();
3916 std::vector<tree_nodeRef>::const_iterator formal_arg, formal_arg_end = formal_args.end();
3917 for(actual_arg = actual_args.begin(), formal_arg = formal_args.begin(); actual_arg != actual_arg_end;
3920 if(formal_arg != formal_arg_end &&
3929 if(actual_arg != actual_args.begin())
3934 if(formal_arg != formal_arg_end)
3946 res +=
"__gimple_resx()";
3951 const auto ae = GetPointerS<const gimple_asm>(node);
3952 for(
const auto& pragma : ae->pragmas)
3957 if(ae->volatile_flag)
3959 res +=
" __volatile__ ";
3961 res +=
"(\"" + ae->str +
"\"";
3966 std::string out_string;
3969 auto tl_purp = GetPointerS<const tree_list>(
GET_CONST_NODE(tl->purp));
3976 tl_purp = GetPointer<const tree_list>(
GET_CONST_NODE(tl_purp->chan));
3983 if(out_string ==
"\"=\"")
3985 out_string =
"\"=r\"";
3988 res +=
"(" +
PrintNode(tl->valu, v, vppf) +
")";
4000 else if(ae->in || ae->clob)
4008 std::string in_string;
4011 auto tl_purp = GetPointer<const tree_list>(
GET_CONST_NODE(tl->purp));
4018 tl_purp = GetPointer<const tree_list>(
GET_CONST_NODE(tl_purp->chan));
4025 if(in_string ==
"\"\"")
4027 in_string =
"\"r\"";
4030 res +=
"(" +
PrintNode(tl->valu, v, vppf) +
")";
4049 auto tl = GetPointerS<const tree_list>(
GET_CONST_NODE(ae->clob));
4069 const auto pn = GetPointerS<const gimple_phi>(node);
4070 res +=
"/* " +
PrintNode(pn->res, v, vppf) +
" = gimple_phi(";
4071 for(
const auto& def_edge : pn->CGetDefEdgesList())
4073 if(def_edge != pn->CGetDefEdgesList().front())
4077 res +=
"<" +
PrintNode(def_edge.first, v, vppf) +
", BB" +
STR(def_edge.second) +
">";
4084 res += (*vppf)(node->index);
4104 res = (*vppf)(node->index);
4114 const auto ld = GetPointerS<const label_decl>(node);
4117 const auto id = GetPointerS<const identifier_node>(
GET_CONST_NODE(ld->name));
4122 res =
"_unnamed_label_" +
STR(node->index);
4126 case gimple_label_K:
4128 const auto le = GetPointerS<const gimple_label>(node);
4129 if(!GetPointerS<const label_decl>(
GET_CONST_NODE(le->op))->artificial_flag)
4138 const auto ge = GetPointerS<const gimple_goto>(node);
4139 const auto is_a_label = GetPointer<const label_decl>(
GET_CONST_NODE(ge->op)) !=
nullptr;
4140 res += (is_a_label ?
"goto " :
"goto *") +
PrintNode(ge->op, v, vppf);
4148 case with_size_expr_K:
4150 const auto wse = GetPointerS<const with_size_expr>(node);
4154 case gimple_predict_K:
4159 case gimple_pragma_K:
4161 const auto pn = GetPointerS<const gimple_pragma>(node);
4163 if(pn->directive && (GetPointer<const omp_for_pragma>(GET_CONST_NODE(pn->directive)) || GetPointer<const omp_simd_pragma>(GET_CONST_NODE(pn->directive))))
4168 if(pn->is_block && !pn->is_opening)
4183 res +=
PrintNode(pn->directive, v, vppf);
4197 case omp_atomic_pragma_K:
4202 case omp_for_pragma_K:
4204 const auto fp = GetPointerS<const omp_for_pragma>(node);
4207 for(
const auto& clause : fp->clauses)
4209 res +=
" " + clause.first +
"(" + clause.second +
")";
4213 case omp_parallel_pragma_K:
4215 const auto pn = GetPointerS<const omp_parallel_pragma>(node);
4216 if(!pn->is_shortcut)
4221 for(
const auto& clause : pn->clauses)
4223 res +=
" " + clause.first +
"(" + clause.second +
")";
4227 case omp_sections_pragma_K:
4229 const auto pn = GetPointerS<const omp_sections_pragma>(node);
4230 if(!pn->is_shortcut)
4236 case omp_parallel_sections_pragma_K:
4238 const auto pn = GetPointerS<const omp_parallel_sections_pragma>(node);
4239 res +=
"parallel sections";
4245 case omp_section_pragma_K:
4250 case omp_declare_simd_pragma_K:
4252 const auto fp = GetPointerS<const omp_declare_simd_pragma>(node);
4253 res +=
"declare simd ";
4255 for(
const auto& clause : fp->clauses)
4257 res +=
" " + clause.first +
"(" + clause.second +
")";
4261 case omp_simd_pragma_K:
4263 const auto fp = GetPointerS<const omp_simd_pragma>(node);
4266 for(
const auto& clause : fp->clauses)
4268 res +=
" " + clause.first +
"(" + clause.second +
")";
4272 case omp_critical_pragma_K:
4275 const auto ocp = GetPointerS<const omp_critical_pragma>(node);
4276 for(
const auto& clause : ocp->clauses)
4278 res +=
" " + clause.first +
"(" + clause.second +
")";
4282 case omp_target_pragma_K:
4285 const auto otp = GetPointerS<const omp_target_pragma>(node);
4286 for(
const auto& clause : otp->clauses)
4288 res +=
" " + clause.first +
"(" + clause.second +
")";
4292 case omp_task_pragma_K:
4295 const auto otp = GetPointerS<const omp_task_pragma>(node);
4296 for(
const auto& clause : otp->clauses)
4298 res +=
" " + clause.first +
"(" + clause.second +
")";
4302 #if HAVE_FROM_PRAGMA_BUILT 4308 case call_hw_pragma_K:
4311 const auto ch = GetPointerS<const call_hw_pragma>(node);
4312 res += ch->HW_component;
4313 if(ch->ID_implementation.size())
4315 res +=
" " +
STR(ch->ID_implementation);
4319 case call_point_hw_pragma_K:
4322 const auto ch = GetPointerS<const call_point_hw_pragma>(node);
4323 res += ch->HW_component;
4324 if(ch->ID_implementation.size())
4326 res +=
" " +
STR(ch->ID_implementation);
4336 case call_hw_pragma_K:
4337 case call_point_hw_pragma_K:
4343 case issue_pragma_K:
4348 case profiling_pragma_K:
4353 case blackbox_pragma_K:
4358 case statistical_profiling_K:
4365 const auto ae = GetPointerS<const assert_expr>(node);
4369 case reduc_max_expr_K:
4371 const auto rme = GetPointerS<const reduc_max_expr>(node);
4372 res +=
"/*reduc_max_expr*/" +
PrintNode(rme->op, v, vppf);
4375 case reduc_min_expr_K:
4377 const auto rme = GetPointerS<const reduc_min_expr>(node);
4378 res +=
"/*reduc_min_expr*/" +
PrintNode(rme->op, v, vppf);
4381 case reduc_plus_expr_K:
4383 const auto rpe = GetPointerS<const reduc_plus_expr>(node);
4384 res +=
"/*reduc_plus_expr*/";
4390 const auto vector_size = size / element_size;
4391 res +=
PrintNode(rpe->op, v, vppf) +
"[0]";
4392 for(
unsigned int ind = 1; ind < vector_size; ++ind)
4394 res +=
"+" +
PrintNode(rpe->op, v, vppf) +
"[" +
STR(ind) +
"]";
4396 for(
unsigned int ind = 1; ind < vector_size; ++ind)
4403 case vec_unpack_hi_expr_K:
4405 const auto vuh = GetPointerS<const vec_unpack_hi_expr>(node);
4410 const auto vector_size = size / element_size;
4411 res +=
"/*" + vuh->get_kind_text() +
"*/";
4414 if(op->get_kind() == vector_cst_K)
4416 const auto vc = GetPointerS<const vector_cst>(op);
4417 for(
auto i = static_cast<unsigned int>(vc->list_of_valu.size() / 2); i < vc->list_of_valu.size();
4423 if(i != (vc->list_of_valu).size() - 1)
4431 for(
auto ind = vector_size; ind < 2 * vector_size; ++ind)
4435 if(ind != 2 * vector_size - 1)
4444 case vec_unpack_lo_expr_K:
4446 const auto vul = GetPointerS<const vec_unpack_lo_expr>(node);
4451 const auto vector_size = size / element_size;
4452 res +=
"/*" + vul->get_kind_text() +
"*/";
4455 if(op->get_kind() == vector_cst_K)
4457 const auto vc = GetPointerS<const vector_cst>(op);
4458 for(
unsigned int i = 0; i < vc->list_of_valu.size() / 2; i++)
4463 if(i != (vc->list_of_valu).size() / 2 - 1)
4471 for(
unsigned int ind = 0; ind < vector_size; ++ind)
4475 if(ind != vector_size - 1)
4484 case vec_unpack_float_hi_expr_K:
4485 case vec_unpack_float_lo_expr_K:
4487 const auto vie = GetPointerS<const unary_expr>(node);
4488 res +=
"/*" + vie->get_kind_text() +
"*/" +
PrintNode(vie->op, v, vppf);
4493 const auto vie = GetPointerS<const unary_expr>(node);
4494 res +=
"(" +
PrintNode(vie->op, v, vppf) +
")";
4498 case vec_pack_trunc_expr_K:
4500 const auto vpt = GetPointerS<const vec_pack_trunc_expr>(node);
4506 const auto vector_size = size / element_size;
4507 res +=
"/*" + vpt->get_kind_text() +
"*/";
4510 if(op0->get_kind() == vector_cst_K)
4512 const auto vc = GetPointerS<const vector_cst>(op0);
4513 for(
const auto& i : vc->list_of_valu)
4523 for(
unsigned int ind = 1; ind < vector_size / 2; ++ind)
4530 if(op1->get_kind() == vector_cst_K)
4532 const auto vc = GetPointerS<const vector_cst>(op1);
4533 for(
unsigned int i = 0; i < (vc->list_of_valu).size(); i++)
4538 if(i != (vc->list_of_valu).size() - 1)
4547 for(
unsigned int ind = 1; ind < vector_size / 2; ++ind)
4556 case dot_prod_expr_K:
4558 const auto dpe = GetPointerS<const ternary_expr>(node);
4563 const auto vector_size = size / element_size;
4565 res +=
"/*" + dpe->get_kind_text() +
"*/";
4573 for(
unsigned int ind = 0; ind < vector_size; ++ind)
4575 res +=
"(" +
PrintNode(dpe->op0, v, vppf) +
"[" +
STR(2 * ind) +
"]" +
" * " +
4576 PrintNode(dpe->op1, v, vppf) +
"[" +
STR(2 * ind) +
"]" +
")";
4577 res +=
"+(" +
PrintNode(dpe->op0, v, vppf) +
"[" +
STR(2 * ind + 1) +
"]" +
" * " +
4578 PrintNode(dpe->op1, v, vppf) +
"[" +
STR(2 * ind + 1) +
"]" +
")";
4579 if(ind != (vector_size - 1))
4585 res +=
" + " +
PrintNode(dpe->op2, v, vppf);
4593 case widen_mult_hi_expr_K:
4595 const auto wmhe = GetPointerS<const widen_mult_hi_expr>(node);
4599 const auto vector_size = size / element_size;
4601 res +=
"/*" + wmhe->get_kind_text() +
"*/";
4604 for(
auto ind = vector_size; ind < vector_size * 2; ++ind)
4606 res +=
PrintNode(wmhe->op0, v, vppf) +
"[" +
STR(ind) +
"]";
4608 res +=
PrintNode(wmhe->op1, v, vppf) +
"[" +
STR(ind) +
"]";
4609 if(ind != (vector_size * 2 - 1))
4617 case widen_mult_lo_expr_K:
4619 const auto wmle = GetPointerS<const widen_mult_lo_expr>(node);
4623 const auto vector_size = size / element_size;
4625 res +=
"/*" + wmle->get_kind_text() +
"*/";
4628 for(
unsigned int ind = 0; ind < vector_size; ++ind)
4630 res +=
PrintNode(wmle->op0, v, vppf) +
"[" +
STR(ind) +
"]";
4632 res +=
PrintNode(wmle->op1, v, vppf) +
"[" +
STR(ind) +
"]";
4633 if(ind != (vector_size - 1))
4641 case vec_pack_sat_expr_K:
4642 case vec_pack_fix_trunc_expr_K:
4644 const auto vie = GetPointerS<const binary_expr>(node);
4645 res +=
"/*" + vie->get_kind_text() +
"*/" +
PrintNode(vie->op0, v, vppf) +
" /**/ " +
4649 case vec_extracteven_expr_K:
4651 const auto vee = GetPointerS<const vec_extracteven_expr>(node);
4655 const auto vector_size = size / element_size;
4657 res +=
"/*" + vee->get_kind_text() +
"*/";
4660 for(
unsigned int ind = 0; ind < vector_size; ind += 2)
4662 res +=
PrintNode(vee->op0, v, vppf) +
"[" +
STR(ind) +
"]";
4665 for(
unsigned int ind = 0; ind < vector_size; ind += 2)
4667 res +=
PrintNode(vee->op1, v, vppf) +
"[" +
STR(ind) +
"]";
4668 if(ind != vector_size - 2)
4676 case vec_extractodd_expr_K:
4678 const auto vee = GetPointerS<const vec_extractodd_expr>(node);
4682 const auto vector_size = size / element_size;
4684 res +=
"/*" + vee->get_kind_text() +
"*/";
4687 for(
unsigned int ind = 1; ind < vector_size; ind += 2)
4689 res +=
PrintNode(vee->op0, v, vppf) +
"[" +
STR(ind) +
"]";
4692 for(
unsigned int ind = 1; ind < vector_size; ind += 2)
4694 res +=
PrintNode(vee->op1, v, vppf) +
"[" +
STR(ind) +
"]";
4695 if(ind != vector_size - 1)
4703 case vec_interleavehigh_expr_K:
4705 const auto vie = GetPointerS<const vec_interleavehigh_expr>(node);
4709 const auto vector_size = size / element_size;
4711 res +=
"/*" + vie->get_kind_text() +
"*/";
4714 for(
auto ind = vector_size / 2; ind < vector_size; ++ind)
4716 res +=
PrintNode(vie->op0, v, vppf) +
"[" +
STR(ind) +
"]";
4718 res +=
PrintNode(vie->op1, v, vppf) +
"[" +
STR(ind) +
"]";
4719 if(ind != vector_size - 1)
4727 case vec_interleavelow_expr_K:
4729 const auto vie = GetPointerS<const vec_interleavelow_expr>(node);
4733 const auto vector_size = size / element_size;
4735 res +=
"/*" + vie->get_kind_text() +
"*/";
4738 for(
unsigned int ind = 0; ind < vector_size / 2; ++ind)
4740 res +=
PrintNode(vie->op0, v, vppf) +
"[" +
STR(ind) +
"]";
4742 res +=
PrintNode(vie->op1, v, vppf) +
"[" +
STR(ind) +
"]";
4743 if(ind != (vector_size / 2) - 1)
4751 case case_label_expr_K:
4756 case array_range_ref_K:
4758 case compound_expr_K:
4759 case eh_filter_expr_K:
4761 case goto_subroutine_K:
4766 case try_catch_expr_K:
4769 case namespace_decl_K:
4770 case translation_unit_decl_K:
4771 case template_decl_K:
4777 case identifier_node_K:
4778 case statement_list_K:
4782 case obj_type_ref_K:
4785 case with_cleanup_expr_K:
4786 case alignof_expr_K:
4790 case cleanup_point_expr_K:
4794 case non_lvalue_expr_K:
4795 case reinterpret_cast_expr_K:
4797 case static_cast_expr_K:
4805 THROW_ERROR(std::string(
"tree node not currently supported ") + node->get_kind_text());
4821 switch(node_type->get_kind())
4825 const auto rt = GetPointerS<const record_type>(node_type);
4840 if(!rt->unql || (!GetPointerS<const record_type>(
GET_NODE(rt->unql))->name &&
4841 !
Param->getOption<
bool>(OPT_without_transformation)))
4848 for(
auto& list_of_fld : rt->list_of_flds)
4857 const auto fd = GetPointerS<const field_decl>(
GET_CONST_NODE(fld_node));
4863 res += (*std_vpf)(field);
4871 if(fd && fd->packed_flag)
4873 res +=
" __attribute__((packed))";
4882 res +=
" __attribute__((packed))";
4888 if(rt->name ||
Param->getOption<
bool>(OPT_without_transformation))
4890 const auto rt_unqal = GetPointerS<const record_type>(
GET_NODE(rt->unql));
4895 else if(
Param->getOption<
bool>(OPT_without_transformation))
4901 if(rt->algn != GetPointerS<const record_type>(
GET_NODE(rt->unql))->algn)
4903 res +=
" __attribute__ ((aligned (" +
STR(rt->algn / 8) +
")))";
4910 const auto ut = GetPointerS<const union_type>(node_type);
4912 "Printing declaration of fake type " +
STR(node_type));
4926 if(!ut->unql || (!GetPointerS<const union_type>(
GET_NODE(ut->unql))->name &&
4927 !
Param->getOption<
bool>(OPT_without_transformation)))
4933 for(
const auto& list_of_fld : ut->list_of_flds)
4942 res +=
" __attribute__((packed))";
4948 if(ut->name ||
Param->getOption<
bool>(OPT_without_transformation))
4950 const auto uut = GetPointerS<const union_type>(
GET_NODE(ut->unql));
4955 else if(
Param->getOption<
bool>(OPT_without_transformation))
4965 if(ut->algn != GetPointerS<const union_type>(
GET_NODE(ut->unql))->algn)
4967 res +=
" __attribute__ ((aligned (" +
STR(ut->algn / 8) +
"))) ";
4972 case enumeral_type_K:
4974 const auto et = GetPointerS<const enumeral_type>(node_type);
4985 res +=
" __attribute__((packed)) ";
4993 res +=
"Internal_" +
STR(type) +
" ";
4996 if(!et->unql || !GetPointerS<const enumeral_type>(
GET_NODE(et->unql))->name)
4999 auto tl = GetPointer<tree_list>(
GET_NODE(et->csts));
5010 tl = GetPointer<tree_list>(
GET_NODE(tl->chan));
5019 if(et->unql && et->name)
5021 const auto et_unql = GetPointerS<const enumeral_type>(
GET_NODE(et->unql));
5032 const auto at = GetPointerS<const array_type>(node_type);
5038 const auto array_length =
GET_NODE(at->size);
5039 const auto array_t =
GET_NODE(at->elts);
5040 if(array_length->get_kind() != integer_cst_K)
5044 const auto tn = GetPointerS<const type_node>(array_t);
5049 THROW_ASSERT(at->name,
"Trying to declare array without name " +
STR(type));
5057 case pointer_type_K:
5059 const auto pt = GetPointerS<const pointer_type>(node_type);
5060 if(pt->unql &&
GET_NODE(pt->ptd)->get_kind() == function_type_K)
5062 const auto ft = GetPointerS<const function_type>(
GET_NODE(pt->ptd));
5067 if(GetPointerS<const type_node>(node_type)->name)
5073 res +=
"Internal_" +
STR(type);
5085 [[gnu::fallthrough]];
5088 case boolean_type_K:
5090 case nullptr_type_K:
5091 case type_pack_expansion_K:
5092 case complex_type_K:
5093 case function_type_K:
5094 case integer_type_K:
5098 case qual_union_type_K:
5100 case reference_type_K:
5102 case template_type_parm_K:
5103 case typename_type_K:
5104 case type_argument_pack_K:
5108 const auto nt = GetPointerS<const type_node>(node_type);
5123 res +=
"Internal_" +
STR(type);
5129 "Expected an integer, got a " + node_type->get_kind_text());
5130 THROW_ASSERT(nt->name,
"Expected a typedef declaration with a name " +
STR(type));
5135 res +=
"typedef long long int bit_size_type";
5142 case aggr_init_expr_K:
5143 case case_label_expr_K:
5145 case identifier_node_K:
5147 case statement_list_K:
5149 case target_mem_ref_K:
5150 case target_mem_ref461_K:
5236 if(temp->get_kind() == indirect_ref_K || temp->get_kind() == misaligned_indirect_ref_K)
5249 if(temp->get_kind() == array_ref_K)
5262 if(temp->get_kind() == component_ref_K)
5275 if(temp->get_kind() == addr_expr_K)
5288 if(temp->get_kind() == mem_ref_K)
5311 switch(node->get_kind())
5318 const auto ue = GetPointerS<const unary_expr>(node);
5327 case case_label_expr_K:
5333 case aggr_init_expr_K:
5335 case identifier_node_K:
5337 case statement_list_K:
5338 case target_mem_ref_K:
5339 case target_mem_ref461_K:
5344 case function_decl_K:
5345 case namespace_decl_K:
5348 case translation_unit_decl_K:
5349 case template_decl_K:
5354 case alignof_expr_K:
5356 case bit_not_expr_K:
5359 case cleanup_point_expr_K:
5361 case convert_expr_K:
5363 case fix_ceil_expr_K:
5364 case fix_floor_expr_K:
5365 case fix_round_expr_K:
5366 case fix_trunc_expr_K:
5368 case imagpart_expr_K:
5369 case indirect_ref_K:
5370 case misaligned_indirect_ref_K:
5373 case non_lvalue_expr_K:
5374 case realpart_expr_K:
5375 case reference_expr_K:
5376 case reinterpret_cast_expr_K:
5378 case static_cast_expr_K:
5380 case truth_not_expr_K:
5383 case view_convert_expr_K:
5384 case reduc_max_expr_K:
5385 case reduc_min_expr_K:
5386 case reduc_plus_expr_K:
5387 case vec_unpack_hi_expr_K:
5388 case vec_unpack_lo_expr_K:
5389 case vec_unpack_float_hi_expr_K:
5390 case vec_unpack_float_lo_expr_K:
5410 if(node->
get_kind() == result_decl_K)
5423 if(temp->
get_kind() == realpart_expr_K)
5436 if(temp->
get_kind() == imagpart_expr_K)
5449 const function_decl* fd = GetPointer<function_decl>(curr_tn);
5461 auto ir = GetPointer<indirect_ref>(temp);
5466 auto mir = GetPointer<misaligned_indirect_ref>(temp);
5474 auto ar = GetPointer<array_ref>(temp);
5482 auto ar = GetPointer<array_ref>(temp);
5490 auto cr = GetPointer<component_ref>(temp);
5498 auto cr = GetPointer<component_ref>(temp);
5506 auto mr = GetPointer<mem_ref>(temp);
5514 auto mr = GetPointer<mem_ref>(temp);
5521 "obj assumed to be an addr_expr, a realpart_expr or an imagpart_expr object. obj is " +
STR(obj));
5523 auto ue = GetPointer<unary_expr>(temp);
5530 auto sn = GetPointer<ssa_name>(temp);
5549 auto be = GetPointer<binary_expr>(node);
5552 switch(right->get_kind())
5555 case fix_ceil_expr_K:
5556 case fix_floor_expr_K:
5557 case fix_round_expr_K:
5559 case convert_expr_K:
5560 case view_convert_expr_K:
5562 case realpart_expr_K:
5563 case imagpart_expr_K:
5566 auto ue = GetPointer<unary_expr>(right);
5572 case aggr_init_expr_K:
5573 case case_label_expr_K:
5575 case fix_trunc_expr_K:
5576 case identifier_node_K:
5578 case statement_list_K:
5579 case target_mem_ref_K:
5580 case target_mem_ref461_K:
5585 case alignof_expr_K:
5587 case bit_not_expr_K:
5590 case cleanup_point_expr_K:
5593 case indirect_ref_K:
5594 case misaligned_indirect_ref_K:
5597 case non_lvalue_expr_K:
5598 case reference_expr_K:
5599 case reinterpret_cast_expr_K:
5601 case static_cast_expr_K:
5603 case truth_not_expr_K:
5606 case reduc_max_expr_K:
5607 case reduc_min_expr_K:
5608 case reduc_plus_expr_K:
5609 case vec_unpack_hi_expr_K:
5610 case vec_unpack_lo_expr_K:
5611 case vec_unpack_float_hi_expr_K:
5612 case vec_unpack_float_lo_expr_K:
5633 case aggr_init_expr_K:
5634 case case_label_expr_K:
5636 case identifier_node_K:
5638 case statement_list_K:
5639 case target_mem_ref_K:
5640 case target_mem_ref461_K:
5644 case bit_and_expr_K:
5645 case bit_ior_expr_K:
5646 case bit_xor_expr_K:
5648 case ceil_div_expr_K:
5649 case ceil_mod_expr_K:
5650 case complex_expr_K:
5651 case compound_expr_K:
5652 case eh_filter_expr_K:
5654 case exact_div_expr_K:
5656 case floor_div_expr_K:
5657 case floor_mod_expr_K:
5660 case goto_subroutine_K:
5663 case lrotate_expr_K:
5671 case mult_highpart_expr_K:
5673 case ordered_expr_K:
5675 case pointer_plus_expr_K:
5676 case postdecrement_expr_K:
5677 case postincrement_expr_K:
5678 case predecrement_expr_K:
5679 case preincrement_expr_K:
5682 case round_div_expr_K:
5683 case round_mod_expr_K:
5684 case rrotate_expr_K:
5687 case trunc_div_expr_K:
5688 case trunc_mod_expr_K:
5689 case truth_and_expr_K:
5690 case truth_andif_expr_K:
5691 case truth_or_expr_K:
5692 case truth_orif_expr_K:
5693 case truth_xor_expr_K:
5694 case try_catch_expr_K:
5703 case unordered_expr_K:
5704 case widen_sum_expr_K:
5705 case widen_mult_expr_K:
5706 case with_size_expr_K:
5707 case vec_lshift_expr_K:
5708 case vec_rshift_expr_K:
5709 case widen_mult_hi_expr_K:
5710 case widen_mult_lo_expr_K:
5711 case vec_pack_trunc_expr_K:
5712 case vec_pack_sat_expr_K:
5713 case vec_pack_fix_trunc_expr_K:
5714 case vec_extracteven_expr_K:
5715 case vec_extractodd_expr_K:
5716 case vec_interleavehigh_expr_K:
5717 case vec_interleavelow_expr_K:
5720 case extract_bit_expr_K:
5721 case sat_plus_expr_K:
5722 case sat_minus_expr_K:
5723 case extractvalue_expr_K:
5724 case extractelement_expr_K:
5745 const auto fd = GetPointer<const function_decl>(node);
5750 for(
const auto&
arg : fd->list_of_args)
5753 ret.insert(pd->type);
5755 const auto ft = GetPointerS<const function_type>(
GET_CONST_NODE(fd->type));
5756 if(!ft || !ft->prms)
5763 ret.insert(tl->valu);
5785 const auto pt = GetPointerS<const pointer_type>(
GET_CONST_NODE(Type_node));
5806 if(node->
get_kind() == gimple_call_K)
5808 auto ce = GetPointer<gimple_call>(node);
5810 if(cefn->get_kind() == addr_expr_K)
5812 auto ue = GetPointer<unary_expr>(cefn);
5813 auto fd = GetPointer<function_decl>(
GET_NODE(ue->op));
5842 if(node->
get_kind() == field_decl_K)
5844 auto fd = GetPointer<field_decl>(node);
5872 case function_decl_K:
5876 THROW_ASSERT(GetPointer<decl_node>(node),
"get_attributes is only for decl_node: " +
STR(var));
5877 return GetPointer<decl_node>(node)->attributes ?
GET_INDEX_NODE(GetPointer<decl_node>(node)->attributes) : 0;
5882 case aggr_init_expr_K:
5883 case case_label_expr_K:
5885 case identifier_node_K:
5886 case statement_list_K:
5888 case target_mem_ref_K:
5889 case target_mem_ref461_K:
5895 case namespace_decl_K:
5896 case translation_unit_decl_K:
5899 case template_decl_K:
5923 unsigned int init = var;
5930 list_of_variables.insert(init);
5931 const auto init_of_init =
GetInit(init, list_of_variables);
5933 return init_of_init;
5946 auto sn = GetPointer<ssa_name>(node);
5958 auto vd = GetPointer<var_decl>(node);
5975 auto vend = co->list_of_idx_valu.end();
5976 for(
auto i = co->list_of_idx_valu.begin(); i != vend; ++i)
5986 case aggr_init_expr_K:
5987 case case_label_expr_K:
5988 case identifier_node_K:
5989 case statement_list_K:
5991 case target_mem_ref_K:
5992 case target_mem_ref461_K:
5997 case function_decl_K:
5999 case namespace_decl_K:
6002 case translation_unit_decl_K:
6003 case template_decl_K:
6033 const auto phi = GetPointer<const gimple_phi>(node);
6040 if(block->CGetStmtList().empty())
6044 const auto& first_stmt = block->CGetStmtList().front();
6045 const auto le = GetPointer<const gimple_label>(
GET_CONST_NODE(first_stmt));
6046 if(le && le->op &&
GET_NODE(le->op)->get_kind() == label_decl_K)
6048 const auto ld = GetPointerS<const label_decl>(
GET_CONST_NODE(le->op));
6067 auto le = GetPointer<gimple_label>(tn);
6069 auto ld = GetPointer<label_decl>(
GET_NODE(le->op));
6070 THROW_ASSERT(ld->name &&
GET_NODE(ld->name)->get_kind() == identifier_node_K,
"identifier_node expected");
6071 auto id = GetPointer<identifier_node>(
GET_NODE(ld->name));
6077 if(block->CGetStmtList().empty())
6082 auto gc = GetPointer<gimple_cond>(
GET_NODE(last));
6087 auto se = GetPointer<gimple_switch>(
GET_NODE(last));
6092 auto ge = GetPointer<gimple_goto>(
GET_NODE(last));
6097 auto gmwi = GetPointer<gimple_multi_way_if>(
GET_NODE(last));
6109 switch(node_type->get_kind())
6113 const auto rt = GetPointerS<const record_type>(node_type);
6120 res +=
"struct Internal_" +
STR(type);
6126 const auto rt = GetPointerS<const union_type>(node_type);
6133 res +=
"union Internal_" +
STR(type);
6137 case enumeral_type_K:
6139 const auto rt = GetPointerS<const enumeral_type>(node_type);
6146 res +=
"enum Internal_" +
STR(type);
6153 case boolean_type_K:
6155 case aggr_init_expr_K:
6156 case case_label_expr_K:
6158 case nullptr_type_K:
6159 case type_pack_expansion_K:
6160 case complex_type_K:
6162 case function_type_K:
6163 case identifier_node_K:
6164 case integer_type_K:
6168 case pointer_type_K:
6169 case qual_union_type_K:
6171 case reference_type_K:
6174 case statement_list_K:
6176 case target_mem_ref_K:
6177 case target_mem_ref461_K:
6178 case template_type_parm_K:
6179 case type_argument_pack_K:
6182 case typename_type_K:
6199 THROW_ERROR(
"Not yet supported " + std::string(node_type->get_kind_text()));
6208 const auto re = GetPointer<const gimple_return>(retNode);
6220 const std::string& tail)
const 6239 tn->
visit(&Visitor);
6245 return sn && sn->default_flag;
6248 #if HAVE_FROM_PRAGMA_BUILT 6249 size_t BehavioralHelper::GetOmpForDegree()
const 6252 return fd->omp_for_wrapper;
6255 bool BehavioralHelper::IsOmpFunctionAtomic()
const 6258 return fd->omp_atomic;
6261 bool BehavioralHelper::IsOmpBodyLoop()
const 6264 return fd->omp_body_loop;
6268 #if HAVE_FROM_PRAGMA_BUILT 6269 bool BehavioralHelper::IsOmpAtomic()
const 6272 return fd->omp_atomic;
6301 const auto ga = GetPointer<const gimple_assign>(tn);
6303 if(ga && ga->predicate &&
GET_NODE(ga->predicate)->get_kind() != integer_cst_K)
6317 switch(tn->get_kind())
6325 case(gimple_assign_K):
6328 switch(
GET_NODE(ga->op1)->get_kind())
6331 case aggr_init_expr_K:
6334 "<--No because of " +
GET_NODE(ga->op1)->get_kind_text() +
6335 " in right part of gimple_assign");
6345 case bit_and_expr_K:
6346 case bit_ior_expr_K:
6347 case bit_xor_expr_K:
6349 case complex_expr_K:
6350 case compound_expr_K:
6352 case eh_filter_expr_K:
6357 case goto_subroutine_K:
6361 case lrotate_expr_K:
6371 case mult_highpart_expr_K:
6373 case ordered_expr_K:
6375 case pointer_plus_expr_K:
6376 case postdecrement_expr_K:
6377 case postincrement_expr_K:
6378 case predecrement_expr_K:
6379 case preincrement_expr_K:
6381 case rrotate_expr_K:
6384 case trunc_div_expr_K:
6385 case truth_and_expr_K:
6386 case truth_andif_expr_K:
6387 case truth_or_expr_K:
6388 case truth_orif_expr_K:
6389 case truth_xor_expr_K:
6390 case try_catch_expr_K:
6398 case unordered_expr_K:
6399 case widen_sum_expr_K:
6400 case widen_mult_expr_K:
6401 case with_size_expr_K:
6402 case vec_lshift_expr_K:
6403 case vec_rshift_expr_K:
6404 case widen_mult_hi_expr_K:
6405 case widen_mult_lo_expr_K:
6406 case vec_pack_trunc_expr_K:
6407 case vec_pack_sat_expr_K:
6408 case vec_pack_fix_trunc_expr_K:
6409 case vec_extracteven_expr_K:
6410 case vec_extractodd_expr_K:
6411 case vec_interleavehigh_expr_K:
6412 case vec_interleavelow_expr_K:
6413 case ceil_div_expr_K:
6414 case ceil_mod_expr_K:
6415 case exact_div_expr_K:
6416 case floor_div_expr_K:
6417 case floor_mod_expr_K:
6419 case round_div_expr_K:
6420 case round_mod_expr_K:
6421 case trunc_mod_expr_K:
6423 case extract_bit_expr_K:
6424 case sat_plus_expr_K:
6425 case sat_minus_expr_K:
6426 case extractvalue_expr_K:
6427 case extractelement_expr_K:
6431 "<--Yes because it is a gimple_assign with " +
GET_NODE(ga->op1)->get_kind_text() +
6432 " in right part of assignment");
6438 case case_label_expr_K:
6439 case identifier_node_K:
6440 case statement_list_K:
6441 case target_mem_ref_K:
6442 case target_mem_ref461_K:
6465 case gimple_label_K:
6466 case gimple_multi_way_if_K:
6467 case gimple_pragma_K:
6468 case gimple_return_K:
6469 case gimple_switch_K:
6477 case aggr_init_expr_K:
6478 case case_label_expr_K:
6482 case gimple_predict_K:
6484 case gimple_while_K:
6485 case identifier_node_K:
6487 case statement_list_K:
6489 case target_mem_ref_K:
6490 case target_mem_ref461_K:
6525 const auto gn = GetPointer<const gimple_node>(tn);
6526 THROW_ASSERT(gn,
"unexpected condition: node " +
STR(tn) +
" is not a gimple_node");
6536 const auto gc = GetPointer<const gimple_call>(tn);
6537 if(gc &&
GET_NODE(gc->fn)->get_kind() == addr_expr_K)
6540 const auto addr_node =
GET_NODE(gc->fn);
6541 const auto ae = GetPointerS<const addr_expr>(addr_node);
6543 "node " +
STR(
GET_NODE(ae->op)) +
" is not function_decl but " +
GET_NODE(ae->op)->get_kind_text());
6552 if(fu_name ==
"__builtin_bambu_time_start" || fu_name ==
"__builtin_bambu_time_stop")
6562 const auto& fun_mem_data =
AppM->CGetFunctionBehavior(
function_index)->get_function_mem();
6568 const auto& fun_mem_data =
AppM->CGetFunctionBehavior(
function_index)->get_function_mem();
#define GET_NODE(t)
Macro used to hide implementation details when accessing a tree_node from another tree_node...
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.
virtual unsigned long long get_size(unsigned int var) const
Return the size in bit of a C object.
std::string PrintVarDeclaration(unsigned int var, const var_pp_functorConstRef vppf, bool init_has_to_be_printed) const
This function prints the declaration of a variable without the closing ";".
bool CanBeMoved(const unsigned int node_index) const
Return if an operation can be moved.
bool CanBeSpeculated(const unsigned int node_index) const
Return true if an operation can be speculated.
virtual bool is_a_complex(unsigned int index) const
Return true if index is a variable or a type of type complex.
static bool IsUnionType(const tree_nodeConstRef &type)
Return if treenode is an union.
bool operating_system_flag
operating system flag: it's true when this is a variable of operating system library ...
#define INDENT_DBG_MEX(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed;.
static std::string name_function(const tree_managerConstRef &tm, const unsigned int index)
Return the name of the function.
virtual std::string PrintNode(const tree_nodeConstRef &node, vertex v, const var_pp_functorConstRef vppf) const
Print the operations corresponding to the node.
virtual std::string print_attributes(unsigned int var, const var_pp_functorConstRef vppf, bool first=true) const
Print the attributes associated to a variable.
virtual unsigned int get_intermediate_var(unsigned int obj) const
Return the intermediate variable of an operation.
File containing functions and utilities to support the printing of debug messagges.
virtual bool is_an_array_ref(unsigned int variable) const
Return true if the index is an array ref.
static void clear_renaming_table()
remove all the entries from the renaming table
This class collects some utility functions used to extract information from tree-based data structure...
static bool IsFunctionPointerType(const tree_nodeConstRef &type)
Return true if the treenode is of type function pointer type.
static bool is_int(const tree_managerConstRef &TM, const unsigned int index)
Return true if the treenode is of integer type.
std::string GetMangledFunctionName() const
#define CASE_BINARY_EXPRESSION
This macro collects all case labels for binary_expr objects.
virtual bool is_a_mem_ref(unsigned int variable) const
Return true if the index is a mem_ref.
bool get_opaque() const
Return the opaque flag.
const tree_nodeRef CGetTreeReindex(const unsigned int i) const
Return a tree_reindex wrapping the i-th tree_node.
#define MAX_ROW_LENGTH
Max length of a row (at the moment checked only during constructor printing)
virtual unsigned int get_component_ref_record(unsigned int obj) const
Return the record variable of a component ref.
std::string get_function_name() const
Return the name of the function.
void add_initialization(unsigned int var, unsigned int init)
Add the initialization of a variables.
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
virtual unsigned int end_with_a_cond_or_goto(const blocRef &block) const
Return the nodeID of the last statement of a basic block in case that statement is a cond or a goto e...
static bool is_unsigned(const tree_managerConstRef &TM, const unsigned int index)
Return true if the treenode is of unsigned integer type.
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...
BehavioralHelper(const application_managerRef AppM, unsigned int index, bool body, const ParameterConstRef parameters)
Constructor.
bool is_a_vector(unsigned int variable) const
Return true if index is a variable or a type of type vector.
static bool is_real(const tree_managerConstRef &TM, const unsigned int index)
Return true if the treenode is of real type.
bool IsLoad(const unsigned int statement_index) const
Return if an operation is a load.
#define CASE_NON_ADDR_UNARY_EXPRESSION
This macro collects all case labels for unary_expr objects.
struct definition of the function_decl tree node.
virtual std::string PrintInit(const tree_nodeConstRef &var, const var_pp_functorConstRef vppf) const
Print the initialization part.
static std::string return_C_qualifiers(const TreeVocabularyTokenTypes_TokenEnum quals, bool real_const)
return the qualifiers in C format
std::vector< tree_nodeRef > GetParameters() const
Return the list of index of original parameters of the function.
static bool is_static(const tree_managerConstRef &TM, const unsigned int index)
FIXME: to be remove after substitution with IsStaticDeclaration.
static tree_nodeConstRef CGetElements(const tree_nodeConstRef &type)
Given an array or a vector return the element type.
virtual std::string print_phinode_res(unsigned int phi_node_id, vertex v, const var_pp_functorConstRef vppf) const
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.
virtual bool is_var_args() const
Returns true if this function is of var args type.
static std::map< unsigned int, std::string > vars_renaming_table
Variable renaming table.
#define STR_CST_string_sizeof
The string used to replace sizeof keyword in the original source code (second step) ...
exceptions managed by PandA
std::string function_name
Name of the function.
unsigned int get_function_index() const
Return the index of the function.
virtual bool is_empty_return(unsigned int index) const
return true in case index is a return expr with an empty operand.
virtual unsigned int get_mem_ref_offset(unsigned int obj) const
Return the offset of a mem ref.
void set_opaque()
Set opaque flag to true.
virtual void visit(tree_node_visitor *const v) const
virtual function used to traverse the tree_node data structure.
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.
virtual std::string print_type(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="") const
Print a type and its variable in case var is not zero.
const application_managerRef AppM
The application manager.
virtual unsigned int get_operand_from_unary_expr(unsigned int obj) const
Return the index of the operand if index is addr_expr, a realpart_expr or a imagpart_expr.
tree node visitor collecting the types used in type casting
#define GET_INDEX_NODE(t)
Macro used to hide implementation details when accessing a tree_node from another tree_node...
virtual bool is_a_result_decl(unsigned int obj) const
Return true if index is a result_decl.
static std::string print_function_name(const tree_managerConstRef &TM, const function_decl *fd)
Return the name of the function in a string.
virtual bool is_an_array(unsigned int variable) const
Return true if index is a variable or a type of type array.
Data structure describing a basic block at tree level.
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.
std::map< unsigned int, unsigned int > initializations
Structure which stores initializations.
virtual bool is_unsigned(unsigned int index) const
Return true if index is a variable or a type of type unsigned int.
redefinition of map to manage ordered/unordered structures
static bool is_an_enum(const tree_managerConstRef &TM, const unsigned int index)
Return if treenode index is an enumeral type.
constant strings used in pragma identification
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.
bool IsDefaultSsaName(const unsigned int ssa_name_index) const
Return true if node is the default ssa_name.
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.
bool has_implementation() const
Return true if function has implementation.
virtual bool is_a_realpart_expr(unsigned int obj) const
Return true if index is a realpart_expr.
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.
const tree_managerConstRef TM
The tree manager.
A set of const tree node.
#define STR(s)
Macro which performs a lexical_cast to a string.
virtual std::tuple< std::string, unsigned int, unsigned int > get_definition(unsigned int index, bool &is_system) const
Returns where the type index is defined.
Auxiliary methods for manipulating string.
virtual std::string PrintConstant(const tree_nodeConstRef &var, const var_pp_functorConstRef vppf=var_pp_functorConstRef()) const
Print the constant associated with var.
virtual bool is_a_pointer(unsigned int variable) const
Return true if index is a variable or a type of type pointer.
virtual bool is_operating_system_function(const unsigned int obj) const
Return true if function is an operating system function.
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.
const OpNodeInfoConstRef CGetOpNodeInfo(const vertex node) const
Returns the info associated with a node.
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 body
Flag to check if behavioral_graph_manager contains the function implementation.
Standard functor that returns the name of a variable.
virtual std::string print_forward_declaration(unsigned int type) const
Print the declaration of a non built-in type.
virtual unsigned int get_array_ref_array(unsigned int obj) const
Return the array variable of an array ref.
const std::list< unsigned int > get_parameters() const
Return the list of index of original parameters of the function.
static unsigned long long Size(const tree_nodeConstRef &tn)
Return the size of a tree object.
#define EXIT_ID
constant used to represent tree node index of exit operation
static unsigned int GetUnqualified(const tree_managerConstRef &TM, unsigned int type)
Return the unqualified version of a type.
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 IsSystemType(const tree_nodeConstRef &type)
Return true if variable or type is a system one.
void InvaildateVariableName(const unsigned int index)
Invalidate cached variable name.
const ParameterConstRef Param
The set of input parameters.
virtual bool is_an_enum(unsigned int index) const
Return true if index is a variable or a type of type enum.
#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 const uint32_t k[]
virtual unsigned int GetInit(unsigned int var, CustomUnorderedSet< unsigned int > &list_of_variables) const
return the initialization object associated with the variable.
bool has_bit_field(unsigned int variable) const
Return true if the variable is a field_decl and it has a bitfield.
#define STR_CST_pragma_keyword_call_point_hw
The call_point_hw pragma keyword.
#define STR_CST_pragma_keyword_call_hw
The call_point_hw pragma keyword.
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.
unsigned int GetFunctionReturnType(unsigned int function) const
Return the index associated with the type of the return of the function.
#define default_COND
constant used to represent label "default" of a switch construct
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...
virtual bool is_va_start_call(unsigned int stm) const
return true in case stm is a va_start call_expr
virtual unsigned int is_named_pointer(const unsigned int index) const
return the nodeid of the named pointer (pointer_type with a name different
virtual bool is_extern(unsigned int decl) const
check if a given index is a extern declaration
virtual int unsigned start_with_a_label(const blocRef &block) const
Return the nodeID of the first statement of a basic block in case that statement is a label expressio...
static void rename_a_variable(unsigned int var, const std::string &new_name)
rename a variable
virtual bool is_int(unsigned int index) const
Return true if index is a variable or a type of type int.
virtual unsigned int get_mem_ref_base(unsigned int obj) const
Return the base of a mem ref.
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
static bool IsVectorType(const tree_nodeConstRef &type)
Return true if the treenode is a vector.
unsigned offset[NUM_VERTICES+1]
#define GET_CONST_NODE(t)
virtual bool is_bool(unsigned int index) const
Return true if index is a variable or a type of type bool.
static std::string NormalizeTypename(const std::string &id)
Return normalized name of types and variables.
bool function_has_to_be_printed(unsigned int f_id) const
returns true if the function body has to be printed by the C backend
unsigned int GetUnqualified(const unsigned int index) const
Return the unqualified version of a type.
virtual bool is_static(unsigned int decl) const
check if a given index is a static declaration
virtual bool is_a_constant(unsigned int obj) const
Return true if the index is a constant object.
Class defining some useful functions to create tree nodes and to manipulate the tree manager...
#define DEBUG_LEVEL_NONE
no debugging print is performed.
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
std::string PrintVariable(unsigned int var) const
Print the name of the variable associated to the index.
struct definition of the pointer_type tree node.
virtual bool is_an_addr_expr(unsigned int variable) const
Return true if the index is an addr_expr.
This struct specifies the block node.
void set_not_opaque()
Set opaque flag to false.
#define STR_CST_pragma_keyword_map
The keyword 'map' which identifies mapping pragmas.
#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.
virtual bool is_natural(unsigned int index) const
Return true if index is a variable grater than or equal to zero.
virtual bool is_a_struct(unsigned int variable) const
Return true if index is a variable or a type of type struct.
virtual ~BehavioralHelper()
Destructor.
virtual void GetTypecast(const tree_nodeConstRef &tn, TreeNodeConstSet &types) const
return the types used in type casting by tn
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.
static std::string op_symbol(const tree_nodeConstRef &op)
Function return the symbol related with the operator op passed as parameter.
void init(int bucket[BUCKETSIZE])
Data structures used to represent an edge in operation and basic block graphs.
std::string print_vertex(const OpGraphConstRef g, const vertex v, const var_pp_functorConstRef vppf, const bool dot=false) const
Print the operations corrisponding to the vertex.
#define STR_CST_pragma_keyword_recursive
The keyword 'omp' which identifies openmp recursive.
virtual bool is_real(unsigned int index) const
Return true if index is a variable or a type of type real.
#define CASE_CST_NODES
This macro collects all case labels for cast nodes.
bool IsStore(const unsigned int statement_index) const
Return if an operation is a store.
unsigned int GetElements(const unsigned int type) const
Given an array or a vector return the element type.
struct definition of the type node structures.
Class specification of the tree_reindex support class.
#define ENTRY_ID
constant used to represent tree node index of entry operation
#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.
virtual unsigned int GetVarFromSsa(unsigned int index) const
Return the index of the variable base of a ssa var.
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.
virtual bool is_a_imagpart_expr(unsigned int obj) const
Return true if index is a imagpart_expr.
static bool is_a_complex(const tree_managerConstRef &TM, const unsigned int index)
Return if treenode index is a complex.
Data structures used in operations graph.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
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.
virtual bool is_an_union(unsigned int variable) const
Return true if index is a variable of a type of type union.
#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 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.
this class is used to manage the command-line or XML options.
virtual unsigned int get_indirect_ref_var(unsigned int obj) const
Return the variable of an indirect ref.
virtual unsigned int get_type(const unsigned int var) const
Return the type of the variable.
#define CASE_CPP_NODES
This macro collects all case labels for cpp nodes.
static bool is_bool(const tree_managerConstRef &TM, const unsigned int index)
Return true if the treenode is of bool type.
static bool IsLut(const tree_nodeConstRef &tn)
Return true in case the right operation is a lut_expr.
refcount< tree_node > tree_nodeRef
RefCount type definition of the tree_node class structure.
bool opaque
Flag to check if a call to this function has to be treated as a TYPE_OPAQUE nodeID.
unsigned int function_index
Index of the function.
virtual unsigned int get_component_ref_field(unsigned int obj) const
Return the field index of a component ref.
virtual TreeNodeConstSet GetParameterTypes() const
Returns the types of the parameters.
static bool is_a_vector(const tree_managerConstRef &TM, const unsigned int index)
Return true if the treenode index is a vector.
virtual bool is_a_component_ref(unsigned int variable) const
Return true if the index is a component ref.
virtual bool is_an_indirect_ref(unsigned int variable) const
Return true if the index is an indirect ref.
static std::map< std::string, unsigned int > used_name
Set of variables name already used.
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.
virtual std::string print_type_declaration(unsigned int type) const
Print the declaration of a non built-in type.
int fun(float *A, float *invA, float *b, float *x, float *I)
virtual const std::string get_label_name(unsigned int label_expr_nid) const
return the label name associated with the label expression
#define GET_INDEX_CONST_NODE(t)
static std::map< unsigned int, std::string > vars_symbol_table
The var symbol table.
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.
bool IsLut(const unsigned int statement_index) const
Return if an operation is a lut_expr.
static tree_nodeConstRef GetFunctionReturnType(const tree_nodeConstRef &function, bool void_as_null=true)
Return the return type of a function.
virtual unsigned int get_array_ref_index(unsigned int obj) const
Return the index variable of an array ref.
std::string get_asm_string(const unsigned int node_index) const
return the string associated with the gimple_asm
#define NULL_VERTEX
null vertex definition
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...
This class creates a layer to add nodes and to manipulate the tree_nodes manager. ...
int debug_level
the debug level
struct definition of the declaration node structures.
#define CASE_TERNARY_EXPRESSION
This macro collects all case labels for ternary_expr objects.
Class specification of the manager of the tree structures extracted from the raw file.
virtual unsigned int get_pointed_type(const unsigned int type) const
Return the pointed type of a pointer.
A brief description of the C++ Header File.
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.
refcount< const BehavioralHelper > BehavioralHelperConstRef
virtual unsigned int get_attributes(unsigned int var) const
return the attributes associated with the variable.
#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 ...