73 #pragma GCC diagnostic ignored "-Woverloaded-virtual" 81 #include <boost/algorithm/string/replace.hpp> 86 switch(transformation)
91 return "Convergent Cond";
93 return "Divergent Cond";
112 const DesignFlowManagerConstRef _design_flow_manager,
const ParameterConstRef _parameters)
114 TM(_AppM->get_tree_manager()),
126 switch(relationship_type)
130 relationships.insert(std::make_pair(BB_CONTROL_DEPENDENCE_COMPUTATION,
SAME_FUNCTION));
131 relationships.insert(std::make_pair(LOOPS_ANALYSIS_BAMBU,
SAME_FUNCTION));
132 relationships.insert(std::make_pair(BB_ORDER_COMPUTATION,
SAME_FUNCTION));
133 relationships.insert(std::make_pair(BB_REACHABILITY_COMPUTATION,
SAME_FUNCTION));
134 relationships.insert(std::make_pair(PREDICATE_STATEMENTS,
SAME_FUNCTION));
139 relationships.insert(std::make_pair(SERIALIZE_MUTUAL_EXCLUSIONS,
SAME_FUNCTION));
147 relationships.insert(std::make_pair(DEAD_CODE_ELIMINATION,
SAME_FUNCTION));
148 relationships.insert(std::make_pair(MULTI_WAY_IF,
SAME_FUNCTION));
149 relationships.insert(std::make_pair(SHORT_CIRCUIT_TAF,
SAME_FUNCTION));
155 relationships.insert(std::make_pair(REMOVE_CLOBBER_GA,
SAME_FUNCTION));
156 relationships.insert(std::make_pair(SIMPLE_CODE_MOTION,
SAME_FUNCTION));
157 relationships.insert(std::make_pair(DEAD_CODE_ELIMINATION,
SAME_FUNCTION));
158 relationships.insert(std::make_pair(DEAD_CODE_ELIMINATION_IPA,
WHOLE_APPLICATION));
166 return relationships;
171 if(
parameters->IsParameter(
"vectorize") and
parameters->GetParameter<std::string>(
"vectorize") ==
"disable")
208 for(boost::tie(bb, bb_end) = boost::vertices(*bb_graph); bb != bb_end; bb++)
213 const blocRef
block = bb_node_info->block;
215 for(
const auto& statement : block->CGetStmtList())
219 for(
const auto&
phi : block->CGetPhiList())
228 for(boost::tie(bb, bb_end) = boost::vertices(*bb_graph); bb != bb_end; bb++)
233 const blocRef
block = bb_node_info->block;
235 "-->Transforming increment statement of BB" +
STR(block->number));
236 for(
const auto& statement : block->CGetStmtList())
242 const std::string file_name =
parameters->getOption<std::string>(OPT_output_temporary_directory) +
243 "before_" +
STR(statement->index) +
"_expansion.gimple";
244 std::ofstream gimple_file(file_name.c_str());
245 TM->PrintGimple(gimple_file,
false);
249 block->PushBefore(
TM->GetTreeReindex(new_statement), statement,
AppM);
254 const std::string file_name =
parameters->getOption<std::string>(OPT_output_temporary_directory) +
255 "after_" +
STR(statement->index) +
"_expansion.gimple";
256 std::ofstream gimple_file(file_name.c_str());
257 TM->PrintGimple(gimple_file,
false);
263 "<--Transformed increment statement of BB" +
STR(block->number));
274 for(boost::tie(bb, bb_end) = boost::vertices(*bb_graph); bb != bb_end; bb++)
279 const blocRef
block = bb_node_info->block;
281 "-->Transforming statement of BB" +
STR(block->number) +
" - Loop " +
282 STR(bb_node_info->loop_id) +
" - Parallel degree " +
284 std::list<tree_nodeRef> new_statement_list;
285 std::vector<tree_nodeRef> new_phi_list;
286 for(
const auto& statement : block->CGetStmtList())
289 new_statement_list, new_phi_list));
291 for(
const auto&
phi : block->CGetPhiList())
297 const auto& old_statement_list = block->CGetStmtList();
298 while(old_statement_list.size())
300 block->RemoveStmt(old_statement_list.front(),
AppM);
303 const auto& old_phi_list = block->CGetPhiList();
304 while(old_phi_list.size())
306 block->RemovePhi(old_phi_list.front());
309 for(
const auto& new_stmt : new_statement_list)
311 block->PushBack(new_stmt,
AppM);
314 for(
const auto& new_phi : new_phi_list)
316 block->AddPhi(new_phi);
334 const auto loop_id = loop->GetId();
339 const auto potential_parallel_degree =
parameters->getOption<
size_t>(OPT_gcc_openmp_simd);
340 const size_t current_parallel_degree = parallel_degree != 0 ? parallel_degree :
341 (loop->loop_type &
DOALL_LOOP) ? potential_parallel_degree :
347 const auto iteration_number =
349 ((loop->upper_bound + (loop->close_interval ? 1 : 0) - loop->lower_bound) / loop->increment) :
352 if(loop->loop_type &
COUNTABLE_LOOP && iteration_number % static_cast<long long>(potential_parallel_degree) == 0)
356 "-->Loop is parallelizable, countable and the iterations number is multiple of parallel degree");
361 THROW_ASSERT(boost::in_degree(loop->GetHeader(), *cdg_bb_graph) == 1,
"");
363 boost::tie(ie, ie_end) = boost::in_edges(loop->GetHeader(), *cdg_bb_graph);
364 auto edge_labels = cdg_bb_graph->CGetBBEdgeInfo(*ie)->get_labels(
CDG_SELECTOR);
365 auto source = boost::source(*ie, *cdg_bb_graph);
366 THROW_ASSERT(edge_labels.size() == 1 or cdg_bb_graph->CGetBBGraphInfo()->entry_vertex == source,
"");
367 const auto header_controller =
368 std::pair<vertex, unsigned int>(source, edge_labels.size() ? *(edge_labels.begin()) : 0);
371 const auto blocks = loop->get_blocks();
372 for(
const auto block : blocks)
374 boost::tie(ie, ie_end) = boost::in_edges(
block, *cdg_bb_graph);
375 edge_labels = cdg_bb_graph->CGetBBEdgeInfo(*ie)->get_labels(
CDG_SELECTOR);
376 source = boost::source(*ie, *cdg_bb_graph);
377 THROW_ASSERT(edge_labels.size() == 1 or cdg_bb_graph->CGetBBGraphInfo()->entry_vertex == source,
"");
378 const auto current_controller =
379 std::pair<vertex, unsigned int>(source, edge_labels.size() ? *(edge_labels.begin()) : 0);
380 const auto bb_index = cdg_bb_graph->CGetBBNodeInfo(
block)->block->number;
381 if(current_controller == header_controller)
398 "Loop is parallelizable but not countable or iterations number is not multiple of parallel degree");
399 const auto blocks = loop->get_blocks();
400 for(
const auto block : blocks)
406 else if(current_parallel_degree != 0)
410 THROW_ASSERT(boost::in_degree(loop->GetHeader(), *cdg_bb_graph) == 1,
"");
412 boost::tie(ie, ie_end) = boost::in_edges(loop->GetHeader(), *cdg_bb_graph);
413 auto edge_labels = cdg_bb_graph->CGetBBEdgeInfo(*ie)->get_labels(
CDG_SELECTOR);
414 auto source = boost::source(*ie, *cdg_bb_graph);
415 THROW_ASSERT(edge_labels.size() == 1 or cdg_bb_graph->CGetBBGraphInfo()->entry_vertex == source,
"");
416 const auto header_controller =
417 std::pair<vertex, unsigned int>(source, edge_labels.size() ? *(edge_labels.begin()) : 0);
424 const auto blocks = loop->get_blocks();
425 for(
const auto block : blocks)
427 boost::tie(ie, ie_end) = boost::in_edges(
block, *cdg_bb_graph);
428 edge_labels = cdg_bb_graph->CGetBBEdgeInfo(*ie)->get_labels(
CDG_SELECTOR);
429 source = boost::source(*ie, *cdg_bb_graph);
430 THROW_ASSERT(edge_labels.size() == 1 or cdg_bb_graph->CGetBBGraphInfo()->entry_vertex == source,
"");
431 const auto current_controller =
432 std::pair<vertex, unsigned int>(source, edge_labels.size() ? *(edge_labels.begin()) : 0);
433 const auto bb_index = cdg_bb_graph->CGetBBNodeInfo(
block)->block->number;
434 if(current_controller == header_controller)
450 "---Header diverges, so all the basic blocks of the loop diverge");
451 const auto blocks = loop->get_blocks();
452 for(
const auto block : blocks)
463 if(current_parallel_degree != parallel_degree)
468 else if(current_parallel_degree != 0)
478 for(
const auto& nested_loop : loop->GetChildren())
497 case gimple_assign_K:
499 const auto* ga = GetPointer<const gimple_assign>(tree_node);
536 const auto* sa = GetPointer<const ssa_name>(tree_node);
538 "Not in ssa form: " +
STR(sa->CGetDefStmts().size()) +
" definitions");
539 const auto bb_index = GetPointer<const gimple_node>(
GET_NODE(sa->CGetDefStmt()))->bb_index;
541 const auto loop_index =
543 if(GetPointer<const gimple_pragma>(
GET_CONST_NODE(sa->CGetDefStmt())))
563 const auto* ue = GetPointer<const unary_expr>(tree_node);
565 if(tree_node->
get_kind() == nop_expr_K or tree_node->
get_kind() == convert_expr_K or
566 tree_node->
get_kind() == abs_expr_K)
579 const auto* be = GetPointer<const binary_expr>(tree_node);
580 if(tree_node->
get_kind() == mem_ref_K or tree_node->
get_kind() == trunc_div_expr_K or
581 tree_node->
get_kind() == trunc_mod_expr_K or tree_node->
get_kind() == widen_mult_expr_K or
582 tree_node->
get_kind() == mult_expr_K or tree_node->
get_kind() == extract_bit_expr_K)
587 else if(tree_node->
get_kind() == rshift_expr_K or tree_node->
get_kind() == lshift_expr_K or
588 tree_node->
get_kind() == le_expr_K )
593 else if(tree_node->
get_kind() == plus_expr_K)
615 const auto* gp = GetPointer<const gimple_phi>(tree_node);
616 for(
const auto& def_edge : gp->CGetDefEdgesList())
620 "Unsupported pattern - Phi is" +
STR(tree_node));
621 if(def_edge.first->get_kind() == var_decl_K)
629 if(loop->init_gimple_id == tree_node->
index and
simd_loop_type[loop->GetId()] == SIMD_OUTER)
635 else if(loop->GetId() == gp->bb_index and
simd_loop_type[loop->GetId()] == SIMD_OUTER)
645 if(boost::in_degree(header, *bb_graph) != 1)
647 THROW_ASSERT(
false,
"Header loop has more than non-feedback incoming edge");
651 boost::tie(ie, ie_end) = boost::in_edges(header, *bb_graph);
652 const vertex previous = boost::source(*ie, *bb_graph);
653 const auto previous_id = bb_graph->
CGetBBNodeInfo(previous)->block->number;
654 for(
const auto& def_edge : gp->CGetDefEdgesList())
656 if(def_edge.second != previous_id)
659 if(loop_ssa->
get_kind() != ssa_name_K)
664 const auto* sn = GetPointer<const ssa_name>(loop_ssa);
665 if(sn->CGetDefStmts().size() != 1)
667 THROW_ASSERT(
false, sn->ToString() +
" has not a single definition");
670 const auto* ga = GetPointer<const gimple_assign>(
GET_NODE(sn->CGetDefStmt()));
673 THROW_ASSERT(
false, sn->ToString() +
" is not defined in a gimple assignment but in " +
674 sn->CGetDefStmt()->ToString());
677 const auto* pe = GetPointer<const plus_expr>(
GET_NODE(ga->op1));
680 THROW_ASSERT(
false,
"Unexpected pattern: " + ga->op1->ToString());
683 if(pe->op0->index != gp->res->index)
685 THROW_ASSERT(
false,
"Unexpected pattern: " + pe->op0->ToString());
688 const auto* ic = GetPointer<const integer_cst>(
GET_NODE(pe->op1));
691 THROW_ASSERT(
false,
"Unexpected pattern: " + pe->op1->ToString());
709 case target_mem_ref461_K:
711 const auto* tmr = GetPointer<const target_mem_ref461>(tree_node);
742 const auto* gc = GetPointer<const gimple_cond>(tree_node);
744 const auto basic_block_index = gc->bb_index;
746 const auto basic_block = fbb->
CGetBBGraphInfo()->bb_index_map.find(basic_block_index)->second;
748 bool divergent =
false;
749 if(std::find(loop->exit_block_iter_begin(), loop->exit_block_iter_end(), basic_block) ==
750 loop->exit_block_iter_end())
759 for(boost::tie(oe, oe_end) = boost::out_edges(basic_block, *fbb); oe != oe_end; oe++)
762 const auto target_basic_block_index = fbb->
CGetBBNodeInfo(target_basic_block)->block->number;
778 const auto* ce = GetPointer<const cond_expr>(tree_node);
787 const auto* ar = GetPointer<const array_ref>(tree_node);
802 case aggr_init_expr_K:
804 const auto* ce = GetPointer<const call_expr>(tree_node);
805 const auto* ae = GetPointer<const addr_expr>(
GET_NODE(ce->fn));
806 const auto* fd = GetPointer<const function_decl>(
GET_NODE(ae->op));
807 const auto* in = GetPointer<const identifier_node>(
GET_NODE(fd->name));
808 const std::string function_name = in->strg;
812 case bit_ior_concat_expr_K:
813 case ternary_plus_expr_K:
814 case ternary_pm_expr_K:
815 case ternary_mp_expr_K:
816 case ternary_mm_expr_K:
819 case insertvalue_expr_K:
821 const auto te = GetPointer<const ternary_expr>(tree_node);
830 auto* le = GetPointer<const lut_expr>(tree_node);
866 case function_decl_K:
868 case namespace_decl_K:
871 case translation_unit_decl_K:
872 case template_decl_K:
876 case target_mem_ref_K:
879 case case_label_expr_K:
881 case identifier_node_K:
882 case statement_list_K:
893 case gimple_multi_way_if_K:
895 case gimple_pragma_K:
896 case gimple_predict_K:
898 case gimple_return_K:
899 case gimple_switch_K:
902 case array_range_ref_K:
904 case component_ref_K:
905 case bit_field_ref_K:
907 case with_cleanup_expr_K:
910 case vec_cond_expr_K:
911 case vec_perm_expr_K:
912 case dot_prod_expr_K:
913 case insertelement_expr_K:
935 auto* ga = GetPointer<gimple_assign>(statement);
941 const auto* sa = GetPointer<const ssa_name>(
GET_NODE(ga->op0));
942 const auto ssa_tree_node =
952 auto* new_ga = GetPointer<gimple_assign>(
TM->get_tree_node_const(new_gimple));
958 for(
const auto&
phi : bb_graph->GetBBNodeInfo(loop->
GetHeader())->
block->CGetPhiList())
961 "---Replacing " + ga->op0->ToString() +
" with " +
GET_CONST_NODE(ssa_tree_node)->ToString() +
962 " in " +
phi->ToString());
963 TM->ReplaceTreeNode(
phi, ga->op0, ssa_tree_node);
967 const auto stmt_list = bb_graph->GetBBNodeInfo(*(loop->
exit_block_iter_begin()))->block->CGetStmtList();
970 "Loop exit is not a cond_expr: " + stmt_list.back()->ToString());
971 const auto gimple_cond_stmt = stmt_list.back();
972 auto* gc = GetPointer<gimple_cond>(
GET_NODE(gimple_cond_stmt));
973 const auto condition_to_be_duplicated = gc->op0;
974 auto* cond_op = GetPointer<ssa_name>(
GET_CONST_NODE(condition_to_be_duplicated));
975 THROW_ASSERT(cond_op,
"Cond expression operand is " +
STR(condition_to_be_duplicated));
976 THROW_ASSERT(cond_op->CGetDefStmts().size() == 1,
"Cond argument is not defined in a single assignment");
977 auto def_statement = cond_op->CGetDefStmt();
978 const auto use_stmts = cond_op->CGetUseStmts();
979 if(use_stmts.size() > 1)
983 cond_op->volatile_flag, cond_op->virtual_flag);
990 "---Created " +
STR(
TM->CGetTreeNode(new_cond_computation)));
991 const auto new_gc_cond = GetPointer<const gimple_assign>(
TM->CGetTreeNode(new_cond_computation));
992 TM->ReplaceTreeNode(gimple_cond_stmt, condition_to_be_duplicated, new_gc_cond->op0);
996 const auto header_guard_tn =
guards.find(loop_id)->second;
999 const auto header_guard_sn = GetPointer<const ssa_name>(
GET_CONST_NODE(header_guard_tn));
1001 const auto header_guard_stmt_tn =
GET_CONST_NODE(header_guard_sn->CGetDefStmt());
1002 const auto header_guard_gp = GetPointer<const gimple_phi>(header_guard_stmt_tn);
1004 const auto feedback_condition = [&]() ->
tree_nodeRef {
1005 for(
const auto& def_edge : header_guard_gp->CGetDefEdgesList())
1007 if(def_edge.second == gc->bb_index)
1009 return def_edge.first;
1015 const auto feedback_condition_sn = GetPointer<const ssa_name>(
GET_CONST_NODE(feedback_condition));
1017 const auto feedback_condition_def_stmt =
GET_CONST_NODE(feedback_condition_sn->CGetDefStmt());
1019 const auto feedback_condition_def_ga = GetPointer<const gimple_assign>(feedback_condition_def_stmt);
1020 THROW_ASSERT(feedback_condition_def_ga,
STR(feedback_condition_def_stmt));
1021 const auto feedback_condition_right_ta =
1022 GetPointer<const truth_and_expr>(
GET_CONST_NODE(feedback_condition_def_ga->op1));
1024 ": " +
STR(feedback_condition_def_ga->op1));
1025 THROW_ASSERT(feedback_condition_right_ta->op0->index == condition_to_be_duplicated->index or
1026 feedback_condition_right_ta->op1->index == condition_to_be_duplicated->index,
1027 STR(feedback_condition_def_ga->op1));
1029 TM->ReplaceTreeNode(feedback_condition_sn->CGetDefStmt(), condition_to_be_duplicated, new_gc_cond->op0);
1031 "---Replaced condition in feedback guard computation " +
STR(feedback_condition_def_stmt));
1033 ->block->PushBefore(
TM->GetTreeReindex(new_cond_computation), feedback_condition_sn->CGetDefStmt(),
AppM);
1038 ->block->PushBack(
TM->GetTreeReindex(new_cond_computation),
AppM);
1046 TM->ReplaceTreeNode(def_statement, ga->op0, ssa_tree_node);
1056 case target_mem_ref461_K:
1061 case aggr_init_expr_K:
1062 case case_label_expr_K:
1064 case identifier_node_K:
1065 case statement_list_K:
1067 case target_mem_ref_K:
1094 #if HAVE_UNORDERED && NO_ABSEIL_HASH 1101 struct hash<std::tuple<unsigned int, vertex, unsigned int>>
1102 :
public unary_function<std::tuple<unsigned int, vertex, unsigned int>, size_t>
1104 size_t operator()(std::tuple<unsigned int, vertex, unsigned int>
value)
const 1107 hash<unsigned int> hasher;
1108 boost::hash_combine(ret, hasher(std::get<0>(value)));
1109 boost::hash_combine(ret, std::get<1>(value));
1110 boost::hash_combine(ret, hasher(std::get<2>(value)));
1123 const auto true_value =
TM->CreateUniqueIntegerCst(1, boolean_type);
1127 std::list<vertex> basic_blocks;
1128 cfg_bb_graph->TopologicalSort(basic_blocks);
1129 for(
const auto basic_block : basic_blocks)
1131 const auto bb_node_info = cfg_bb_graph->CGetBBNodeInfo(basic_block);
1132 const auto basic_block_id = bb_node_info->block->number;
1134 const auto loop_id = bb_node_info->loop_id;
1137 guards[basic_block_id] = true_value;
1141 guards[basic_block_id] = true_value;
1144 else if(boost::in_degree(basic_block, *cfg_bb_graph) > 1 and
1145 boost::in_degree(basic_block, *cfg_bb_graph) == boost::in_degree(basic_block, *fcfg_bb_graph))
1147 THROW_ASSERT(boost::in_degree(basic_block, *cdg_bb_graph) == 1,
"");
1149 boost::tie(ie, ie_end) = boost::in_edges(basic_block, *cdg_bb_graph);
1150 auto edge_labels = cdg_bb_graph->CGetBBEdgeInfo(*ie)->get_labels(
CDG_SELECTOR);
1151 auto source = boost::source(*ie, *cdg_bb_graph);
1152 THROW_ASSERT(edge_labels.size() == 1 or cdg_bb_graph->CGetBBGraphInfo()->entry_vertex == source,
"");
1153 const auto controller = std::tuple<unsigned int, vertex, unsigned int>(
1154 bb_node_info->loop_id, source, edge_labels.size() ? *(edge_labels.begin()) : 0);
1155 THROW_ASSERT(condition_guards.find(controller) != condition_guards.end(),
"");
1156 guards[basic_block_id] = condition_guards.find(controller)->second;
1159 else if(boost::in_degree(basic_block, *fcfg_bb_graph) > 1)
1163 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> ssa_schema;
1164 auto ssa_vers =
TM->get_next_vers();
1165 auto ssa_node_nid =
TM->new_tree_node_id();
1170 TM->create_tree_node(ssa_node_nid, ssa_name_K, ssa_schema);
1174 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> gimple_phi_schema;
1175 const auto gimple_phi_id =
TM->new_tree_node_id();
1180 TM->create_tree_node(gimple_phi_id, gimple_phi_K, gimple_phi_schema);
1181 auto gp = GetPointer<gimple_phi>(
TM->get_tree_node_const(gimple_phi_id));
1182 gp->SetSSAUsesComputed();
1185 for(boost::tie(ie, ie_end) = boost::in_edges(basic_block, *cfg_bb_graph); ie != ie_end; ie++)
1187 const auto source = boost::source(*ie, *cfg_bb_graph);
1188 THROW_ASSERT(cfg_bb_graph->CGetBBNodeInfo(source)->block,
"");
1189 const auto source_id = source != cfg_bb_graph->CGetBBGraphInfo()->entry_vertex ?
1190 cfg_bb_graph->CGetBBNodeInfo(source)->block->number :
1196 bb_node_info->block->AddPhi(
TM->GetTreeReindex(gimple_phi_id));
1197 boost::tie(ie, ie_end) = boost::in_edges(basic_block, *cdg_bb_graph);
1198 auto edge_labels = cdg_bb_graph->CGetBBEdgeInfo(*ie)->get_labels(
CDG_SELECTOR);
1199 auto source = boost::source(*ie, *cdg_bb_graph);
1200 THROW_ASSERT(edge_labels.size() == 1 or cdg_bb_graph->CGetBBGraphInfo()->entry_vertex == source,
"");
1201 const auto controller = std::tuple<unsigned int, vertex, unsigned int>(
1202 bb_node_info->loop_id, source, edge_labels.size() ? *(edge_labels.begin()) : 0);
1203 condition_guards[controller] = gp->res;
1204 guards[basic_block_id] = gp->res;
1209 boost::tie(ie, ie_end) = boost::in_edges(basic_block, *cfg_bb_graph);
1210 THROW_ASSERT(boost::in_degree(basic_block, *cdg_bb_graph) == 1,
"");
1211 boost::tie(ie, ie_end) = boost::in_edges(basic_block, *cdg_bb_graph);
1212 const auto control = boost::source(*ie, *cdg_bb_graph);
1213 auto edge_labels = cdg_bb_graph->CGetBBEdgeInfo(*ie)->get_labels(
CDG_SELECTOR);
1214 THROW_ASSERT(edge_labels.size() == 1 or cdg_bb_graph->CGetBBGraphInfo()->entry_vertex == control,
"");
1215 const auto controller = std::tuple<unsigned int, vertex, unsigned int>(
1216 bb_node_info->loop_id, control, edge_labels.size() ? *(edge_labels.begin()) : 0);
1217 if(condition_guards.find(controller) != condition_guards.end())
1219 const auto combined_condition = condition_guards.find(controller)->second;
1220 guards[basic_block_id] = combined_condition;
1224 const auto control_bb_node_info = cfg_bb_graph->CGetBBNodeInfo(control)->block;
1225 const auto control_id = control_bb_node_info->number;
1226 const auto control_list_of_stmt = control_bb_node_info->CGetStmtList();
1228 const auto gc = GetPointer<gimple_cond>(
GET_NODE(control_list_of_stmt.back()));
1230 const auto control_condition =
guards.find(control_id)->second;
1231 const auto edge_condition = gc->op0;
1235 const auto combined_condition =
1236 control_condition->index != true_value->index ?
1239 if(control_condition->index != true_value->index)
1241 bb_node_info->block->PushFront(GetPointer<const ssa_name>(
GET_NODE(combined_condition))->CGetDefStmt(),
1244 if(edge_condition != gc->op0)
1246 bb_node_info->block->PushFront(GetPointer<const ssa_name>(
GET_NODE(edge_condition))->CGetDefStmt(),
1249 condition_guards[controller] = combined_condition;
1250 guards[basic_block_id] = combined_condition;
1256 if(boost::out_degree(basic_block, *cfg_bb_graph) != boost::out_degree(basic_block, *fcfg_bb_graph))
1258 if(boost::out_degree(basic_block, *fcfg_bb_graph) == 1)
1261 boost::tie(oe, oe_end) = boost::out_edges(basic_block, *fcfg_bb_graph);
1263 const auto target_id = cfg_bb_graph->CGetBBNodeInfo(
target)->block->number;
1267 const auto guard =
guards.find(target_id)->second;
1268 const auto sn = GetPointer<ssa_name>(
GET_NODE(guard));
1270 auto gp = GetPointer<gimple_phi>(
GET_NODE(sn->CGetDefStmt()));
1275 else if(boost::out_degree(basic_block, *fcfg_bb_graph) == 2)
1278 for(boost::tie(oe, oe_end) = boost::out_edges(basic_block, *fcfg_bb_graph); oe != oe_end; oe++)
1283 const auto target_id = cfg_bb_graph->CGetBBNodeInfo(
target)->block->number;
1285 "---Considering feedback edge BB" +
STR(basic_block_id) +
"-->" +
STR(target_id));
1286 THROW_ASSERT(target_id == bb_node_info->block->true_edge,
"");
1290 const auto guard =
guards.find(target_id)->second;
1291 const auto sn = GetPointer<ssa_name>(
GET_NODE(guard));
1293 auto gp = GetPointer<gimple_phi>(
GET_NODE(sn->CGetDefStmt()));
1295 const auto list_of_stmt = bb_node_info->block->CGetStmtList();
1297 const auto gc = GetPointer<gimple_cond>(
GET_NODE(list_of_stmt.back()));
1299 const auto current_condition =
guards.find(basic_block_id)->second;
1300 const auto feedback_condition = gc->op0;
1301 const auto combined_condition =
1302 current_condition->index != true_value->index ?
1322 for(
const auto& guard :
guards)
1325 "---Guard of BB" +
STR(guard.first) +
" is " +
STR(guard.second));
1339 for(boost::tie(basic_block, basic_block_end) = boost::vertices(*fcfg_bb_graph); basic_block != basic_block_end;
1343 const auto basic_block_id = fcfg_bb_graph->CGetBBNodeInfo(*basic_block)->block->number;
1345 if(boost::in_degree(*basic_block, *fcfg_bb_graph) <= 1)
1348 "---Skipped BB" +
STR(basic_block_id) +
" because has not multiple incoming edges");
1351 const auto bb_node_info = fcfg_bb_graph->CGetBBNodeInfo(*basic_block);
1352 if(
simd_loop_type.find(bb_node_info->loop_id)->second == SIMD_NONE)
1355 "---Skipped BB" +
STR(basic_block_id) +
" because is outside parallelized loops");
1358 if(bb_node_info->loop_id == bb_node_info->block->number)
1361 "---Skipped BB" +
STR(basic_block_id) +
" because is an header");
1365 bool diverge =
false;
1367 for(boost::tie(ie, ie_end) = boost::in_edges(*basic_block, *fcfg_bb_graph); ie != ie_end; ie++)
1369 const auto source = boost::source(*ie, *fcfg_bb_graph);
1370 const auto source_id = fcfg_bb_graph->CGetBBNodeInfo(source)->block->number;
1380 "---Skipped BB" +
STR(basic_block_id) +
" because is not a convergence point");
1384 THROW_ASSERT(boost::in_degree(*basic_block, *dom_graph) == 1,
"");
1385 boost::tie(ie, ie_end) = boost::in_edges(*basic_block, *dom_graph);
1386 vertex whole_dominator = boost::source(*ie, *dom_graph);
1387 THROW_ASSERT(fcfg_bb_graph->ExistsEdge(whole_dominator, *basic_block),
"");
1388 const std::map<vertex, unsigned int>& bb_map_levels =
function_behavior->get_bb_map_levels();
1390 std::set<vertex, bb_vertex_order_by_map> phi_inputs(comp_i);
1391 for(boost::tie(ie, ie_end) = boost::in_edges(*basic_block, *fcfg_bb_graph); ie != ie_end; ie++)
1393 const auto source = boost::source(*ie, *fcfg_bb_graph);
1394 if(source != whole_dominator)
1396 phi_inputs.insert(source);
1399 for(
const auto&
phi : bb_node_info->block->CGetPhiList())
1406 for(
const auto source : phi_inputs)
1408 const auto source_id = fcfg_bb_graph->CGetBBNodeInfo(source)->block->number;
1411 THROW_ASSERT(boost::in_degree(source, *cdg_bb_graph) == 1,
"");
1412 boost::tie(ie_local, ie_end_local) = boost::in_edges(source, *cdg_bb_graph);
1413 vertex local_dominator = boost::source(*ie_local, *cdg_bb_graph);
1414 const auto local_dominator_index = dom_graph->CGetBBNodeInfo(local_dominator)->block->number;
1416 if(local_dominator == whole_dominator)
1418 for(
const auto& def_edge : gp->CGetDefEdgesList())
1420 if(def_edge.second == local_dominator_index)
1422 return def_edge.first;
1430 THROW_ASSERT(new_defs.find(local_dominator_index) != new_defs.end(),
"");
1431 return new_defs.find(local_dominator_index)->second;
1435 for(
const auto& def_edge : gp->CGetDefEdgesList())
1437 if(def_edge.second == source_id)
1447 type,
guards.at(source_id), from_source.first, from_dominator,
BUILTIN_SRCP, cond_expr_K);
1453 if(
GET_NODE(from_source.first)->get_kind() == ssa_name_K and
1454 GET_NODE(from_dominator)->get_kind() == ssa_name_K)
1456 const auto sn1 = GetPointer<const ssa_name>(
GET_NODE(from_source.first));
1457 const auto sn2 = GetPointer<const ssa_name>(
GET_NODE(from_dominator));
1458 if(sn1->var and sn2->var and sn1->var->index == sn2->var->index)
1468 const auto gimple_assign_node =
1470 fcfg_bb_graph->CGetBBNodeInfo(source)->block->PushBack(gimple_assign_node,
AppM);
1473 new_defs[source_id] = ssa_node;
1490 for(boost::tie(bb, bb_end) = boost::vertices(*bb_graph); bb != bb_end; bb++)
1493 const auto basic_block_index = bb_node_info->block->number;
1498 "-->Considering statements of BB" +
STR(basic_block_index));
1499 for(
const auto& stmt : bb_node_info->block->CGetStmtList())
1501 auto ga = GetPointer<gimple_assign>(
GET_NODE(stmt));
1502 if(ga && ga->predicate)
1504 ga->predicate =
guards.at(basic_block_index);
1505 const auto sn = GetPointer<ssa_name>(
GET_NODE(ga->predicate));
1508 sn->AddUseStmt(stmt);
1513 "<--Considered statements of BB" +
STR(basic_block_index));
1520 const size_t scalar_index, std::list<tree_nodeRef>& new_stmt_list,
1521 std::vector<tree_nodeRef>& new_phi_list)
1524 "-->Transforming " +
TM->get_tree_node_const(tree_node_index)->get_kind_text() +
" " +
1525 STR(tree_node_index) +
1526 ((
TM->get_tree_node_const(tree_node_index)->get_kind() != function_decl_K) ?
1527 ": " +
TM->get_tree_node_const(tree_node_index)->ToString() :
1530 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> tree_node_schema;
1531 unsigned int return_value = 0;
1538 if(scalar_index != 0)
1548 switch(transformation)
1552 return_value = tree_node_index;
1558 const auto* gc = GetPointer<const gimple_cond>(tn);
1559 std::string include_name = GetPointer<const srcp>(tn)->include_name;
1560 unsigned int line_number = GetPointer<const srcp>(tn)->line_number;
1561 unsigned int column_number = GetPointer<const srcp>(tn)->column_number;
1562 tree_node_schema[
TOK(
TOK_SRCP)] = include_name +
":" +
STR(line_number) +
":" +
STR(column_number);
1565 STR(
Transform(gc->op0->index, parallel_degree, 1, new_stmt_list, new_phi_list));
1566 unsigned int new_tree_node_index =
TM->new_tree_node_id();
1567 TM->create_tree_node(new_tree_node_index, gimple_cond_K, tree_node_schema);
1568 auto* new_gc = GetPointer<gimple_cond>(
TM->get_tree_node_const(new_tree_node_index));
1569 new_gc->memuse = gc->memuse;
1570 new_gc->memdef = gc->memdef;
1571 for(
const auto& vuse : gc->vuses)
1574 TM->GetTreeReindex(
Transform(vuse->index, parallel_degree, 1, new_stmt_list, new_phi_list)));
1579 TM->GetTreeReindex(
Transform(gc->vdef->index, parallel_degree, 1, new_stmt_list, new_phi_list));
1581 new_gc->vovers = gc->vovers;
1582 new_gc->pragmas = gc->pragmas;
1583 new_gc->use_set = gc->use_set;
1584 new_gc->clobbered_set = gc->clobbered_set;
1585 return_value = new_tree_node_index;
1586 new_stmt_list.push_back(
TM->GetTreeReindex(new_tree_node_index));
1591 std::list<tree_nodeRef> conditions;
1592 const auto* gc = GetPointer<const gimple_cond>(tn);
1593 for(
size_t parallel_index = 1; parallel_index <= parallel_degree; parallel_index++)
1595 conditions.push_back(
TM->GetTreeReindex(
1596 Transform(gc->op0->index, parallel_degree, parallel_index, new_stmt_list, new_phi_list)));
1598 while(conditions.size() > 1)
1600 const auto first_condition = conditions.front();
1601 conditions.pop_front();
1602 const auto second_condition = conditions.front();
1603 conditions.pop_front();
1605 new_stmt_list.push_back(GetPointer<const ssa_name>(
GET_NODE(new_cond))->CGetDefStmt());
1606 conditions.push_back(new_cond);
1608 std::string include_name = GetPointer<const srcp>(tn)->include_name;
1609 unsigned int line_number = GetPointer<const srcp>(tn)->line_number;
1610 unsigned int column_number = GetPointer<const srcp>(tn)->column_number;
1611 tree_node_schema[
TOK(
TOK_SRCP)] = include_name +
":" +
STR(line_number) +
":" +
STR(column_number);
1613 tree_node_schema[
TOK(
TOK_OP0)] =
STR(conditions.front()->index);
1614 unsigned int new_tree_node_index =
TM->new_tree_node_id();
1615 TM->create_tree_node(new_tree_node_index, gimple_cond_K, tree_node_schema);
1616 return_value = new_tree_node_index;
1617 new_stmt_list.push_back(
TM->GetTreeReindex(new_tree_node_index));
1623 const auto* gp = GetPointer<const gimple_phi>(tn);
1625 STR(
Transform(gp->scpe->index, parallel_degree, 0, new_stmt_list, new_phi_list));
1627 STR(
Transform(gp->res->index, parallel_degree, 0, new_stmt_list, new_phi_list));
1629 std::string include_name = gp->include_name;
1630 unsigned int line_number = gp->line_number;
1631 unsigned int column_number = gp->column_number;
1632 tree_node_schema[
TOK(
TOK_SRCP)] = include_name +
":" +
STR(line_number) +
":" +
STR(column_number);
1633 unsigned int new_tree_node_id =
TM->new_tree_node_id();
1634 TM->create_tree_node(new_tree_node_id, gimple_phi_K, tree_node_schema);
1635 auto* new_gp = GetPointer<gimple_phi>(
TM->get_tree_node_const(new_tree_node_id));
1639 boost::tie(ie, ie_end) = boost::in_edges(header, *bb_graph);
1640 const vertex previous = boost::source(*ie, *bb_graph);
1641 const unsigned int previous_id = bb_graph->
CGetBBNodeInfo(previous)->block->number;
1642 const auto previous_block = bb_graph->
GetBBNodeInfo(previous)->block;
1643 const auto previous_list_of_stmt = previous_block->CGetStmtList();
1644 for(
const auto& def_edge : gp->CGetDefEdgesList())
1646 if(def_edge.second == previous_id)
1648 if(
GET_NODE(def_edge.first)->get_kind() == integer_cst_K)
1650 const auto* ic = GetPointer<const integer_cst>(
GET_NODE(def_edge.first));
1652 STR(
Transform(ic->type->index, parallel_degree, 0, new_stmt_list, new_phi_list));
1655 unsigned int new_init_tree_node_id =
TM->new_tree_node_id();
1656 TM->create_tree_node(new_init_tree_node_id, vector_cst_K, tree_node_schema);
1657 auto* new_tn = GetPointer<vector_cst>(
TM->GetTreeNode(new_init_tree_node_id));
1659 "Increment variable of " + gp->res->ToString() +
" is unknown");
1660 const auto increment =
iv_increment.at(gp->res->index);
1661 for(
size_t i = 0; i < parallel_degree; i++)
1663 const auto local_init = original_init + increment *
static_cast<long long>(i);
1664 const auto new_ic =
TM->CreateUniqueIntegerCst(local_init, ic->type);
1665 new_tn->list_of_valu.push_back(
TM->GetTreeReindex(new_ic->index));
1669 else if(
GET_NODE(def_edge.first)->get_kind() == ssa_name_K)
1672 for(
size_t i = 1; i <= parallel_degree; i++)
1674 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> gimple_tree_node_schema,
1675 plus_tree_node_schema, ssa_tree_node_schema;
1678 include_name +
":" +
STR(line_number) +
":" +
STR(column_number);
1679 plus_tree_node_schema[
TOK(
TOK_OP0)] =
STR(def_edge.first->index);
1682 "Increment variable of " + gp->res->ToString() +
" is unknown");
1686 unsigned int plus_tree_node_index =
TM->new_tree_node_id();
1687 TM->create_tree_node(plus_tree_node_index, plus_expr_K, plus_tree_node_schema);
1690 const auto* sa = GetPointer<const ssa_name>(
GET_NODE(def_edge.first));
1701 if(sa->volatile_flag)
1705 if(sa->virtual_flag)
1717 unsigned int ssa_tree_node_index =
TM->new_tree_node_id();
1718 TM->create_tree_node(ssa_tree_node_index, ssa_name_K, ssa_tree_node_schema);
1719 version_to_ssa[i] = ssa_tree_node_index;
1722 include_name +
":" +
STR(line_number) +
":" +
STR(column_number);
1724 gimple_tree_node_schema[
TOK(
TOK_OP1)] =
STR(plus_tree_node_index);
1725 gimple_tree_node_schema[
TOK(
TOK_OP0)] =
STR(ssa_tree_node_index);
1726 unsigned int gimple_tree_node_index =
TM->new_tree_node_id();
1727 TM->create_tree_node(gimple_tree_node_index, gimple_assign_K, gimple_tree_node_schema);
1730 GET_NODE((*(previous_list_of_stmt.begin())))->get_kind() != gimple_cond_K,
1732 previous_block->PushBack(
TM->GetTreeReindex(gimple_tree_node_index),
AppM);
1734 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> constructor_tree_node_schema,
1735 gimple_tree_node_schema, ssa_tree_node_schema;
1738 unsigned int constructor_index =
TM->new_tree_node_id();
1739 TM->create_tree_node(constructor_index, constructor_K, constructor_tree_node_schema);
1740 auto* constr = GetPointer<constructor>(
TM->get_tree_node_const(constructor_index));
1741 for(
size_t scalar = 1; scalar <= parallel_degree; scalar++)
1743 const auto new_ic =
TM->CreateUniqueIntegerCst(static_cast<long long int>(scalar - 1),
1745 constr->add_idx_valu(new_ic,
TM->GetTreeReindex(version_to_ssa[scalar]));
1748 const auto* sa = GetPointer<const ssa_name>(
GET_NODE(def_edge.first));
1752 STR(
Transform(sa->type->index, parallel_degree, 0, new_stmt_list, new_phi_list));
1757 STR(
Transform(sa->var->index, parallel_degree, 0, new_stmt_list, new_phi_list));
1760 if(sa->volatile_flag)
1764 if(sa->virtual_flag)
1771 STR(
Transform(sa->max->index, parallel_degree, 0, new_stmt_list, new_phi_list));
1776 STR(
Transform(sa->min->index, parallel_degree, 0, new_stmt_list, new_phi_list));
1778 unsigned int ssa_tree_node_index =
TM->new_tree_node_id();
1779 TM->create_tree_node(ssa_tree_node_index, ssa_name_K, ssa_tree_node_schema);
1782 include_name +
":" +
STR(line_number) +
":" +
STR(column_number);
1784 gimple_tree_node_schema[
TOK(
TOK_OP1)] =
STR(constructor_index);
1785 gimple_tree_node_schema[
TOK(
TOK_OP0)] =
STR(ssa_tree_node_index);
1786 unsigned int gimple_tree_node_index =
TM->new_tree_node_id();
1787 TM->create_tree_node(gimple_tree_node_index, gimple_assign_K, gimple_tree_node_schema);
1788 previous_block->PushBack(
TM->GetTreeReindex(gimple_tree_node_index),
AppM);
1803 new_stmt_list, new_phi_list)),
1807 return_value = new_tree_node_id;
1808 new_phi_list.push_back(
TM->GetTreeReindex(return_value));
1810 for(
size_t scalar = 1; scalar <= parallel_degree; scalar++)
1813 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> bit_field_ref_tree_node_schema,
1814 ssa_tree_node_schema, gimple_assign_tree_node_schema;
1815 unsigned int bit_field_ref_index =
TM->new_tree_node_id();
1818 const auto bit_size =
1820 const auto offset =
TM->CreateUniqueIntegerCst(static_cast<long long int>((scalar - 1) * bit_size),
1825 include_name +
":" +
STR(line_number) +
":" +
STR(column_number);
1827 bit_field_ref_tree_node_schema[
TOK(
TOK_OP0)] =
1828 STR(
Transform(gp->res->index, parallel_degree, 0, new_stmt_list, new_phi_list));
1829 bit_field_ref_tree_node_schema[
TOK(
TOK_OP1)] =
STR(size->index);
1831 TM->create_tree_node(bit_field_ref_index, bit_field_ref_K, bit_field_ref_tree_node_schema);
1833 const auto* sa = GetPointer<const ssa_name>(
GET_NODE(gp->res));
1844 if(sa->volatile_flag)
1848 if(sa->virtual_flag)
1861 unsigned int ssa_tree_node_index =
TM->new_tree_node_id();
1862 TM->create_tree_node(ssa_tree_node_index, ssa_name_K, ssa_tree_node_schema);
1865 include_name +
":" +
STR(line_number) +
":" +
STR(column_number);
1867 gimple_assign_tree_node_schema[
TOK(
TOK_OP1)] =
STR(bit_field_ref_index);
1868 gimple_assign_tree_node_schema[
TOK(
TOK_OP0)] =
1869 STR(
Transform(gp->res->index, parallel_degree, scalar, new_stmt_list, new_phi_list));
1870 unsigned int gimple_new_tree_node_index =
TM->new_tree_node_id();
1871 TM->create_tree_node(gimple_new_tree_node_index, gimple_assign_K, gimple_assign_tree_node_schema);
1873 new_stmt_list.push_front(
TM->GetTreeReindex(gimple_new_tree_node_index));
1881 const auto* ga = GetPointer<const gimple_assign>(tn);
1883 std::string include_name = GetPointer<const srcp>(tn)->include_name;
1884 unsigned int line_number = GetPointer<const srcp>(tn)->line_number;
1885 unsigned int column_number = GetPointer<const srcp>(tn)->column_number;
1886 tree_node_schema[
TOK(
TOK_SRCP)] = include_name +
":" +
STR(line_number) +
":" +
STR(column_number);
1891 STR(
Transform(ga->op0->index, parallel_degree, 0, new_stmt_list, new_phi_list));
1893 STR(
Transform(ga->op1->index, parallel_degree, 0, new_stmt_list, new_phi_list));
1894 unsigned int new_tree_node_index =
TM->new_tree_node_id();
1895 TM->create_tree_node(new_tree_node_index, gimple_assign_K, tree_node_schema);
1896 auto* new_ga = GetPointer<gimple_assign>(
TM->get_tree_node_const(new_tree_node_index));
1898 GET_NODE(new_ga->op1)->get_kind() == minus_expr_K,
1899 "Loop increment operation is not a plus expression nor a minus expression");
1900 auto* be = GetPointer<binary_expr>(
GET_NODE(new_ga->op1));
1903 const auto new_increment = increment *
static_cast<integer_cst_t>(parallel_degree);
1904 const auto new_ic =
TM->CreateUniqueIntegerCst(new_increment, type);
1905 be->op1 =
TM->GetTreeReindex(
Transform(new_ic->index, parallel_degree, 0, new_stmt_list, new_phi_list));
1906 new_ga->memuse = ga->memuse;
1907 new_ga->memdef = ga->memdef;
1908 for(
const auto& vuse : ga->vuses)
1911 TM->GetTreeReindex(
Transform(vuse->index, parallel_degree, 0, new_stmt_list, new_phi_list)));
1916 TM->GetTreeReindex(
Transform(ga->vdef->index, parallel_degree, 0, new_stmt_list, new_phi_list));
1918 new_ga->vovers = ga->vovers;
1919 new_ga->pragmas = ga->pragmas;
1920 new_ga->use_set = ga->use_set;
1921 new_ga->clobbered_set = ga->clobbered_set;
1922 return_value = new_tree_node_index;
1923 new_stmt_list.push_back(
TM->GetTreeReindex(new_tree_node_index));
1927 for(
size_t scalar = 1; scalar <= parallel_degree; scalar++)
1930 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> bit_field_ref_tree_node_schema,
1931 ssa_tree_node_schema, gimple_assign_tree_node_schema;
1932 unsigned int bit_field_ref_index =
TM->new_tree_node_id();
1935 const auto bit_size =
1937 const auto offset =
TM->CreateUniqueIntegerCst(static_cast<long long int>((scalar - 1) * bit_size),
1942 include_name +
":" +
STR(line_number) +
":" +
STR(column_number);
1944 bit_field_ref_tree_node_schema[
TOK(
TOK_OP0)] =
1945 STR(
Transform(ga->op0->index, parallel_degree, 0, new_stmt_list, new_phi_list));
1946 bit_field_ref_tree_node_schema[
TOK(
TOK_OP1)] =
STR(size->index);
1948 TM->create_tree_node(bit_field_ref_index, bit_field_ref_K, bit_field_ref_tree_node_schema);
1950 const auto* sa = GetPointer<const ssa_name>(
GET_NODE(ga->op0));
1961 if(sa->volatile_flag)
1965 if(sa->virtual_flag)
1978 unsigned int ssa_tree_node_index =
TM->new_tree_node_id();
1979 TM->create_tree_node(ssa_tree_node_index, ssa_name_K, ssa_tree_node_schema);
1982 include_name +
":" +
STR(line_number) +
":" +
STR(column_number);
1984 gimple_assign_tree_node_schema[
TOK(
TOK_OP1)] =
STR(bit_field_ref_index);
1985 gimple_assign_tree_node_schema[
TOK(
TOK_OP0)] =
1986 STR(
Transform(ga->op0->index, parallel_degree, scalar, new_stmt_list, new_phi_list));
1987 unsigned int gimple_new_tree_node_index =
TM->new_tree_node_id();
1988 TM->create_tree_node(gimple_new_tree_node_index, gimple_assign_K, gimple_assign_tree_node_schema);
1989 new_stmt_list.push_back(
TM->GetTreeReindex(gimple_new_tree_node_index));
2001 "<--Already transformed " +
STR(tree_node_index) +
2002 ((
TM->get_tree_node_const(tree_node_index)->get_kind() != function_decl_K) ?
2003 ": " +
TM->get_tree_node_const(
2012 case gimple_assign_K:
2014 const auto* ga = GetPointer<const gimple_assign>(tn);
2017 for(
size_t scalar = 1; scalar <= parallel_degree; scalar++)
2019 std::string include_name = GetPointer<const srcp>(tn)->include_name;
2020 unsigned int line_number = GetPointer<const srcp>(tn)->line_number;
2021 unsigned int column_number = GetPointer<const srcp>(tn)->column_number;
2022 tree_node_schema[
TOK(
TOK_SRCP)] = include_name +
":" +
STR(line_number) +
":" +
STR(column_number);
2028 STR(
Transform(ga->op1->index, parallel_degree, scalar, new_stmt_list, new_phi_list));
2030 STR(
Transform(ga->op0->index, parallel_degree, scalar, new_stmt_list, new_phi_list));
2034 STR(
Transform(ga->predicate->index, parallel_degree, scalar, new_stmt_list, new_phi_list));
2037 unsigned int new_tree_node_index =
TM->new_tree_node_id();
2038 TM->create_tree_node(new_tree_node_index, gimple_assign_K, tree_node_schema);
2039 auto* new_ga = GetPointer<gimple_assign>(
TM->get_tree_node_const(new_tree_node_index));
2040 new_ga->memuse = ga->memuse;
2041 new_ga->memdef = ga->memdef;
2042 for(
const auto& vuse : ga->vuses)
2044 new_ga->AddVuse(
TM->GetTreeReindex(
2045 Transform(vuse->index, parallel_degree, scalar, new_stmt_list, new_phi_list)));
2049 new_ga->vdef =
TM->GetTreeReindex(
2050 Transform(ga->vdef->index, parallel_degree, scalar, new_stmt_list, new_phi_list));
2051 const auto old_vdef = GetPointer<const ssa_name>(
GET_NODE(ga->vdef));
2052 for(
const auto& use_stmt : old_vdef->CGetUseStmts())
2054 const auto stmt = use_stmt.first;
2057 const auto gn = GetPointerS<gimple_node>(
GET_NODE(stmt));
2058 const auto vuse_it = gn->vuses.find(ga->vdef);
2059 if(vuse_it != gn->vuses.end())
2061 gn->vuses.erase(vuse_it);
2062 gn->vuses.insert(new_ga->vdef);
2067 new_ga->vovers = ga->vovers;
2068 new_ga->pragmas = ga->pragmas;
2069 new_ga->use_set = ga->use_set;
2070 new_ga->clobbered_set = ga->clobbered_set;
2071 new_stmt_list.push_back(
TM->GetTreeReindex(new_tree_node_index));
2072 scalar_to_ssa[scalar] = new_ga->op0->index;
2073 return_value = new_tree_node_index;
2076 tree_node_schema.clear();
2084 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> constructor_tree_node_schema;
2087 unsigned int constructor_index =
TM->new_tree_node_id();
2088 TM->create_tree_node(constructor_index, constructor_K, constructor_tree_node_schema);
2089 auto* constr = GetPointer<constructor>(
TM->get_tree_node_const(constructor_index));
2090 for(
size_t scalar = 1; scalar <= parallel_degree; scalar++)
2092 const auto new_ic =
TM->CreateUniqueIntegerCst(static_cast<long long int>(scalar - 1),
2094 constr->add_idx_valu(new_ic,
TM->GetTreeReindex(scalar_to_ssa[scalar]));
2097 std::string include_name = GetPointer<const srcp>(tn)->include_name;
2098 unsigned int line_number = GetPointer<const srcp>(tn)->line_number;
2099 unsigned int column_number = GetPointer<const srcp>(tn)->column_number;
2100 tree_node_schema[
TOK(
TOK_SRCP)] = include_name +
":" +
STR(line_number) +
":" +
STR(column_number);
2106 STR(
Transform(ga->op0->index, parallel_degree, 0, new_stmt_list, new_phi_list));
2107 unsigned int new_tree_node_index =
TM->new_tree_node_id();
2108 TM->create_tree_node(new_tree_node_index, gimple_assign_K, tree_node_schema);
2109 new_stmt_list.push_back(
TM->GetTreeReindex(new_tree_node_index));
2116 const auto* ue = GetPointer<const unary_expr>(tn);
2119 STR(
Transform(ue->op->index, parallel_degree, scalar_index, new_stmt_list, new_phi_list));
2120 std::string include_name = ue->include_name;
2121 unsigned int line_number = ue->line_number;
2122 unsigned int column_number = ue->column_number;
2123 tree_node_schema[
TOK(
TOK_SRCP)] = include_name +
":" +
STR(line_number) +
":" +
STR(column_number);
2124 unsigned int new_tree_node_id =
TM->new_tree_node_id();
2125 TM->create_tree_node(new_tree_node_id, tn->
get_kind(), tree_node_schema);
2126 return_value = new_tree_node_id;
2131 const auto* be = GetPointer<const binary_expr>(tn);
2133 STR(
Transform(be->op0->index, parallel_degree, scalar_index, new_stmt_list, new_phi_list));
2134 std::string include_name = be->include_name;
2135 unsigned int line_number = be->line_number;
2136 unsigned int column_number = be->column_number;
2137 tree_node_schema[
TOK(
TOK_SRCP)] = include_name +
":" +
STR(line_number) +
":" +
STR(column_number);
2140 STR(
Transform(be->op1->index, parallel_degree, scalar_index, new_stmt_list, new_phi_list));
2141 unsigned int new_tree_node_id =
TM->new_tree_node_id();
2142 TM->create_tree_node(new_tree_node_id, tn->
get_kind(), tree_node_schema);
2143 return_value = new_tree_node_id;
2148 const auto* te = GetPointer<const ternary_expr>(tn);
2150 STR(
Transform(te->op0->index, parallel_degree, scalar_index, new_stmt_list, new_phi_list));
2151 std::string include_name = te->include_name;
2152 unsigned int line_number = te->line_number;
2153 unsigned int column_number = te->column_number;
2154 tree_node_schema[
TOK(
TOK_SRCP)] = include_name +
":" +
STR(line_number) +
":" +
STR(column_number);
2157 STR(
Transform(te->op1->index, parallel_degree, scalar_index, new_stmt_list, new_phi_list));
2159 STR(
Transform(te->op2->index, parallel_degree, scalar_index, new_stmt_list, new_phi_list));
2160 unsigned int new_tree_node_id =
TM->new_tree_node_id();
2161 TM->create_tree_node(new_tree_node_id, tn->
get_kind(), tree_node_schema);
2162 return_value = new_tree_node_id;
2167 const auto* le = GetPointer<const lut_expr>(tn);
2169 STR(
Transform(le->op0->index, parallel_degree, scalar_index, new_stmt_list, new_phi_list));
2170 std::string include_name = le->include_name;
2171 unsigned int line_number = le->line_number;
2172 unsigned int column_number = le->column_number;
2173 tree_node_schema[
TOK(
TOK_SRCP)] = include_name +
":" +
STR(line_number) +
":" +
STR(column_number);
2176 STR(
Transform(le->op1->index, parallel_degree, scalar_index, new_stmt_list, new_phi_list));
2180 STR(
Transform(le->op2->index, parallel_degree, scalar_index, new_stmt_list, new_phi_list));
2185 STR(
Transform(le->op3->index, parallel_degree, scalar_index, new_stmt_list, new_phi_list));
2190 STR(
Transform(le->op4->index, parallel_degree, scalar_index, new_stmt_list, new_phi_list));
2195 STR(
Transform(le->op5->index, parallel_degree, scalar_index, new_stmt_list, new_phi_list));
2200 STR(
Transform(le->op6->index, parallel_degree, scalar_index, new_stmt_list, new_phi_list));
2205 STR(
Transform(le->op7->index, parallel_degree, scalar_index, new_stmt_list, new_phi_list));
2210 STR(
Transform(le->op8->index, parallel_degree, scalar_index, new_stmt_list, new_phi_list));
2212 unsigned int new_tree_node_id =
TM->new_tree_node_id();
2213 TM->create_tree_node(new_tree_node_id, tn->
get_kind(), tree_node_schema);
2214 return_value = new_tree_node_id;
2219 const auto* qe = GetPointer<const quaternary_expr>(tn);
2221 STR(
Transform(qe->op0->index, parallel_degree, scalar_index, new_stmt_list, new_phi_list));
2222 std::string include_name = qe->include_name;
2223 unsigned int line_number = qe->line_number;
2224 unsigned int column_number = qe->column_number;
2225 tree_node_schema[
TOK(
TOK_SRCP)] = include_name +
":" +
STR(line_number) +
":" +
STR(column_number);
2228 STR(
Transform(qe->op0->index, parallel_degree, scalar_index, new_stmt_list, new_phi_list));
2230 STR(
Transform(qe->op1->index, parallel_degree, scalar_index, new_stmt_list, new_phi_list));
2234 STR(
Transform(qe->op2->index, parallel_degree, scalar_index, new_stmt_list, new_phi_list));
2239 STR(
Transform(qe->op3->index, parallel_degree, scalar_index, new_stmt_list, new_phi_list));
2241 unsigned int new_tree_node_id =
TM->new_tree_node_id();
2242 TM->create_tree_node(new_tree_node_id, tn->
get_kind(), tree_node_schema);
2243 return_value = new_tree_node_id;
2247 case target_mem_ref461_K:
2249 const auto* tmr = GetPointer<const target_mem_ref461>(tn);
2254 STR(
Transform(tmr->base->index, parallel_degree, scalar_index, new_stmt_list, new_phi_list));
2259 STR(
Transform(tmr->offset->index, parallel_degree, scalar_index, new_stmt_list, new_phi_list));
2264 STR(
Transform(tmr->idx->index, parallel_degree, scalar_index, new_stmt_list, new_phi_list));
2269 STR(
Transform(tmr->step->index, parallel_degree, scalar_index, new_stmt_list, new_phi_list));
2274 STR(
Transform(tmr->idx2->index, parallel_degree, scalar_index, new_stmt_list, new_phi_list));
2276 unsigned int new_tree_node_id =
TM->new_tree_node_id();
2277 TM->create_tree_node(new_tree_node_id, target_mem_ref461_K, tree_node_schema);
2278 return_value = new_tree_node_id;
2283 return_value = tree_node_index;
2288 return_value = tree_node_index;
2295 const auto* sa = GetPointer<const ssa_name>(tn);
2306 if(sa->volatile_flag)
2310 if(sa->virtual_flag)
2323 unsigned int ssa_tree_node_index =
TM->new_tree_node_id();
2324 TM->create_tree_node(ssa_tree_node_index, ssa_name_K, tree_node_schema);
2325 return_value = ssa_tree_node_index;
2329 return_value = tree_node_index;
2334 case aggr_init_expr_K:
2336 const auto* ce = GetPointer<const call_expr>(tn);
2337 std::string include_name = ce->include_name;
2338 unsigned int line_number = ce->line_number;
2339 unsigned int column_number = ce->column_number;
2340 tree_node_schema[
TOK(
TOK_SRCP)] = include_name +
":" +
STR(line_number) +
":" +
STR(column_number);
2343 unsigned int call_expr_tree_node_index =
TM->new_tree_node_id();
2344 TM->create_tree_node(call_expr_tree_node_index, call_expr_K, tree_node_schema);
2345 auto* new_ce = GetPointer<call_expr>(
TM->get_tree_node_const(call_expr_tree_node_index));
2346 for(
const auto&
arg : ce->args)
2348 new_ce->AddArg(
TM->GetTreeReindex(
2349 Transform(
arg->index, parallel_degree, scalar_index, new_stmt_list, new_phi_list)));
2351 return_value = call_expr_tree_node_index;
2356 case function_decl_K:
2358 case namespace_decl_K:
2361 case translation_unit_decl_K:
2362 case template_decl_K:
2368 case case_label_expr_K:
2370 case identifier_node_K:
2371 case statement_list_K:
2372 case target_mem_ref_K:
2383 case gimple_label_K:
2384 case gimple_multi_way_if_K:
2387 case gimple_pragma_K:
2388 case gimple_predict_K:
2390 case gimple_return_K:
2391 case gimple_switch_K:
2392 case gimple_while_K:
2394 case array_range_ref_K:
2414 "<--Already transformed " +
STR(tree_node_index) +
2415 ((
TM->get_tree_node_const(tree_node_index)->get_kind() != function_decl_K) ?
2416 ": " +
TM->get_tree_node_const(tree_node_index)->ToString() :
2423 case gimple_assign_K:
2425 const auto* ga = GetPointer<const gimple_assign>(tn);
2426 std::string include_name = GetPointer<const srcp>(tn)->include_name;
2427 unsigned int line_number = GetPointer<const srcp>(tn)->line_number;
2428 unsigned int column_number = GetPointer<const srcp>(tn)->column_number;
2429 tree_node_schema[
TOK(
TOK_SRCP)] = include_name +
":" +
STR(line_number) +
":" +
STR(column_number);
2435 STR(
Transform(ga->op1->index, parallel_degree, 0, new_stmt_list, new_phi_list));
2438 "Composition not yet implemented " +
STR(tn));
2440 STR(
Transform(ga->op0->index, parallel_degree, 0, new_stmt_list, new_phi_list));
2441 unsigned int new_tree_node_index =
TM->new_tree_node_id();
2442 TM->create_tree_node(new_tree_node_index, gimple_assign_K, tree_node_schema);
2443 auto* new_ga = GetPointer<gimple_assign>(
TM->get_tree_node_const(new_tree_node_index));
2444 new_ga->memuse = ga->memuse;
2445 new_ga->memdef = ga->memdef;
2446 for(
const auto& vuse : ga->vuses)
2449 TM->GetTreeReindex(
Transform(vuse->index, parallel_degree, 0, new_stmt_list, new_phi_list)));
2454 TM->GetTreeReindex(
Transform(ga->vdef->index, parallel_degree, 0, new_stmt_list, new_phi_list));
2456 new_ga->vovers = ga->vovers;
2457 new_ga->pragmas = ga->pragmas;
2458 new_ga->use_set = ga->use_set;
2459 new_ga->clobbered_set = ga->clobbered_set;
2460 return_value = new_tree_node_index;
2462 new_stmt_list.push_back(
TM->GetTreeReindex(return_value));
2463 for(
size_t scalar = 1; scalar <= parallel_degree; scalar++)
2466 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> bit_field_ref_tree_node_schema,
2467 gimple_assign_tree_node_schema;
2468 unsigned int bit_field_ref_index =
TM->new_tree_node_id();
2471 const auto bit_size =
2473 const auto offset =
TM->CreateUniqueIntegerCst(static_cast<long long int>((scalar - 1) * bit_size),
2475 const auto size =
TM->CreateUniqueIntegerCst(static_cast<long long int>(bit_size),
2478 include_name +
":" +
STR(line_number) +
":" +
STR(column_number);
2480 bit_field_ref_tree_node_schema[
TOK(
TOK_OP0)] =
2481 STR(
Transform(ga->op0->index, parallel_degree, 0, new_stmt_list, new_phi_list));
2482 bit_field_ref_tree_node_schema[
TOK(
TOK_OP1)] =
STR(size->index);
2484 TM->create_tree_node(bit_field_ref_index, bit_field_ref_K, bit_field_ref_tree_node_schema);
2487 include_name +
":" +
STR(line_number) +
":" +
STR(column_number);
2489 gimple_assign_tree_node_schema[
TOK(
TOK_OP1)] =
STR(bit_field_ref_index);
2490 gimple_assign_tree_node_schema[
TOK(
TOK_OP0)] =
2491 STR(
Transform(ga->op0->index, parallel_degree, scalar, new_stmt_list, new_phi_list));
2492 unsigned int gimple_new_tree_node_index =
TM->new_tree_node_id();
2493 TM->create_tree_node(gimple_new_tree_node_index, gimple_assign_K, gimple_assign_tree_node_schema);
2495 "---Adding " +
TM->get_tree_node_const(gimple_new_tree_node_index)->ToString());
2496 new_stmt_list.push_back(
TM->GetTreeReindex(gimple_new_tree_node_index));
2503 const auto* sa = GetPointer<const ssa_name>(tn);
2507 STR(
Transform(sa->type->index, parallel_degree, 0, new_stmt_list, new_phi_list));
2512 STR(
Transform(sa->var->index, parallel_degree, 0, new_stmt_list, new_phi_list));
2516 if(sa->volatile_flag)
2520 if(sa->virtual_flag)
2527 STR(
Transform(sa->max->index, parallel_degree, 0, new_stmt_list, new_phi_list));
2532 STR(
Transform(sa->min->index, parallel_degree, 0, new_stmt_list, new_phi_list));
2535 unsigned int new_tree_node_index =
TM->new_tree_node_id();
2536 TM->create_tree_node(new_tree_node_index, ssa_name_K, tree_node_schema);
2537 return_value = new_tree_node_index;
2542 const auto*
type = GetPointer<const type_node>(tn);
2547 STR(
Transform(
type->unql->index, parallel_degree, 0, new_stmt_list, new_phi_list));
2552 STR(
Transform(
type->scpe->index, parallel_degree, 0, new_stmt_list, new_phi_list));
2554 if(
type->packed_flag)
2563 switch(
type->get_kind())
2565 case pointer_type_K:
2568 const pointer_type * pt = GetPointer<const pointer_type>(tn);
2574 unsigned int new_tree_node_id =
TM->new_tree_node_id();
2575 TM->create_tree_node(new_tree_node_id, pointer_type_K, tree_node_schema);
2576 return_value = new_tree_node_id;
2580 case boolean_type_K:
2581 case integer_type_K:
2584 tree_node_schema[
TOK(
TOK_ELTS)] =
type->get_kind() != boolean_type_K ?
2589 const auto element_size =
type->get_kind() != boolean_type_K ?
2592 const auto bit_size = element_size *
static_cast<unsigned int>(parallel_degree);
2593 const auto size =
TM->CreateUniqueIntegerCst(static_cast<long long int>(bit_size),
2598 auto new_tree_node_id =
TM->new_tree_node_id();
2599 TM->create_tree_node(new_tree_node_id, vector_type_K, tree_node_schema);
2600 return_value = new_tree_node_id;
2602 auto* new_type_node = GetPointer<type_node>(
TM->get_tree_node_const(new_tree_node_id));
2603 if(new_type_node->name and
GET_NODE(new_type_node->name)->get_kind() == type_decl_K)
2605 auto* td = GetPointer<type_decl>(
GET_NODE(new_type_node->name));
2606 td->type =
TM->GetTreeReindex(new_tree_node_id);
2612 case nullptr_type_K:
2613 case type_pack_expansion_K:
2614 case complex_type_K:
2615 case enumeral_type_K:
2616 case function_type_K:
2620 case qual_union_type_K:
2623 case reference_type_K:
2625 case template_type_parm_K:
2626 case typename_type_K:
2627 case type_argument_pack_K:
2633 case aggr_init_expr_K:
2634 case case_label_expr_K:
2636 case identifier_node_K:
2638 case statement_list_K:
2640 case target_mem_ref_K:
2641 case target_mem_ref461_K:
2670 const auto* dn = GetPointer<const decl_node>(tn);
2674 STR(
Transform(dn->name->index, parallel_degree, 0, new_stmt_list, new_phi_list));
2679 STR(
Transform(dn->mngl->index, parallel_degree, 0, new_stmt_list, new_phi_list));
2687 if(dn->get_kind() != type_decl_K)
2690 STR(
Transform(dn->type->index, parallel_degree, 0, new_stmt_list, new_phi_list));
2696 STR(
Transform(dn->scpe->index, parallel_degree, 0, new_stmt_list, new_phi_list));
2705 STR(
Transform(dn->chan->index, parallel_degree, 0, new_stmt_list, new_phi_list));
2707 if(dn->artificial_flag)
2715 if(dn->operating_system_flag)
2719 if(dn->library_system_flag)
2723 if(dn->libbambu_flag)
2731 std::string include_name =
2732 dn->get_kind() == type_decl_K and dn->include_name ==
"<built-in>" ?
"<new>" : dn->include_name;
2733 auto line_number = dn->line_number;
2734 auto column_number = dn->column_number;
2735 tree_node_schema[
TOK(
TOK_SRCP)] = include_name +
":" +
STR(line_number) +
":" +
STR(column_number);
2740 const auto* td = GetPointer<const type_decl>(tn);
2744 STR(
Transform(td->tmpl_parms->index, parallel_degree, 0, new_stmt_list, new_phi_list));
2749 STR(
Transform(td->tmpl_args->index, parallel_degree, 0, new_stmt_list, new_phi_list));
2751 auto new_tree_node_id =
TM->new_tree_node_id();
2752 TM->create_tree_node(new_tree_node_id, type_decl_K, tree_node_schema);
2753 return_value = new_tree_node_id;
2758 const auto* vd = GetPointer<const var_decl>(tn);
2763 if(vd->static_static_flag)
2778 STR(
Transform(vd->init->index, parallel_degree, 0, new_stmt_list, new_phi_list));
2783 const auto*
type = GetPointer<const type_node>(
TM->get_tree_node_const(
2784 Transform(dn->type->index, parallel_degree, 0, new_stmt_list, new_phi_list)));
2795 if(vd->register_flag)
2802 STR(
Transform(vd->smt_ann->index, parallel_degree, 0, new_stmt_list, new_phi_list));
2804 auto new_tree_node_id =
TM->new_tree_node_id();
2805 TM->create_tree_node(new_tree_node_id, var_decl_K, tree_node_schema);
2806 return_value = new_tree_node_id;
2811 case function_decl_K:
2813 case namespace_decl_K:
2816 case translation_unit_decl_K:
2819 case template_decl_K:
2823 case aggr_init_expr_K:
2824 case case_label_expr_K:
2826 case identifier_node_K:
2828 case statement_list_K:
2830 case target_mem_ref_K:
2831 case target_mem_ref461_K:
2857 case translation_unit_decl_K:
2859 return_value = tree_node_index;
2862 case identifier_node_K:
2864 const auto* in = GetPointer<const identifier_node>(tn);
2865 if(in->operator_flag)
2871 tree_node_schema[
TOK(
TOK_STRG)] =
"vector_" + boost::replace_all_copy(in->strg,
" ",
"_");
2873 auto new_tree_node_id =
TM->new_tree_node_id();
2874 TM->create_tree_node(new_tree_node_id, identifier_node_K, tree_node_schema);
2875 return_value = new_tree_node_id;
2878 case function_decl_K:
2881 return_value = tree_node_index;
2886 const auto* ue = GetPointer<const unary_expr>(tn);
2888 STR(
Transform(ue->type->index, parallel_degree, 0, new_stmt_list, new_phi_list));
2890 STR(
Transform(ue->op->index, parallel_degree, 0, new_stmt_list, new_phi_list));
2894 std::string include_name = ue->include_name;
2895 auto line_number = ue->line_number;
2896 auto column_number = ue->column_number;
2897 tree_node_schema[
TOK(
TOK_SRCP)] = include_name +
":" +
STR(line_number) +
":" +
STR(column_number);
2898 auto new_tree_node_id =
TM->new_tree_node_id();
2899 TM->create_tree_node(new_tree_node_id, tn->
get_kind(), tree_node_schema);
2900 return_value = new_tree_node_id;
2905 const auto* be = GetPointer<const binary_expr>(tn);
2907 STR(
Transform(be->type->index, parallel_degree, 0, new_stmt_list, new_phi_list));
2909 STR(
Transform(be->op0->index, parallel_degree, 0, new_stmt_list, new_phi_list));
2918 STR(
Transform(be->op1->index, parallel_degree, 0, new_stmt_list, new_phi_list));
2925 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> constructor_tree_node_schema,
2926 temp_tree_node_schema, ssa_tree_node_schema;
2928 STR(
Transform(be->type->index, parallel_degree, 0, new_stmt_list, new_phi_list));
2929 auto constructor_index =
TM->new_tree_node_id();
2930 TM->create_tree_node(constructor_index, constructor_K, constructor_tree_node_schema);
2931 auto* constr = GetPointer<constructor>(
TM->get_tree_node_const(constructor_index));
2932 for(
size_t scalar = 1; scalar <= parallel_degree; scalar++)
2934 const auto new_ic =
TM->CreateUniqueIntegerCst(static_cast<long long int>(scalar - 1),
2936 constr->add_idx_valu(new_ic,
TM->GetTreeReindex(be->op1->index));
2939 std::string include_name = GetPointer<const srcp>(tn)->include_name;
2940 auto line_number = GetPointer<const srcp>(tn)->line_number;
2941 auto column_number = GetPointer<const srcp>(tn)->column_number;
2943 "Unexpected operand " +
GET_NODE(be->op1)->get_kind_text());
2944 const auto* sa = GetPointer<const ssa_name>(
GET_NODE(be->op1));
2948 STR(
Transform(sa->type->index, parallel_degree, 0, new_stmt_list, new_phi_list));
2953 STR(
Transform(sa->var->index, parallel_degree, 0, new_stmt_list, new_phi_list));
2957 if(sa->volatile_flag)
2961 if(sa->virtual_flag)
2968 STR(
Transform(sa->max->index, parallel_degree, 0, new_stmt_list, new_phi_list));
2973 STR(
Transform(sa->min->index, parallel_degree, 0, new_stmt_list, new_phi_list));
2976 auto ssa_tree_node_index =
TM->new_tree_node_id();
2977 TM->create_tree_node(ssa_tree_node_index, ssa_name_K, ssa_tree_node_schema);
2979 include_name +
":" +
STR(line_number) +
":" +
STR(column_number);
2982 temp_tree_node_schema[
TOK(
TOK_OP0)] =
STR(ssa_tree_node_index);
2985 auto temp_tree_node_index =
TM->new_tree_node_id();
2986 TM->create_tree_node(temp_tree_node_index, gimple_assign_K, temp_tree_node_schema);
2987 auto* new_ga = GetPointer<gimple_assign>(
TM->get_tree_node_const(temp_tree_node_index));
2988 new_stmt_list.push_back(
TM->GetTreeReindex(temp_tree_node_index));
2995 std::string include_name = be->include_name;
2996 auto line_number = be->line_number;
2997 auto column_number = be->column_number;
2998 tree_node_schema[
TOK(
TOK_SRCP)] = include_name +
":" +
STR(line_number) +
":" +
STR(column_number);
2999 auto new_tree_node_id =
TM->new_tree_node_id();
3000 if(tn->
get_kind() == truth_or_expr_K)
3002 TM->create_tree_node(new_tree_node_id, bit_ior_expr_K, tree_node_schema);
3004 else if(tn->
get_kind() == truth_and_expr_K)
3006 TM->create_tree_node(new_tree_node_id, bit_and_expr_K, tree_node_schema);
3008 else if(tn->
get_kind() == lshift_expr_K)
3010 TM->create_tree_node(new_tree_node_id, vec_lshift_expr_K, tree_node_schema);
3012 else if(tn->
get_kind() == rshift_expr_K)
3014 TM->create_tree_node(new_tree_node_id, vec_rshift_expr_K, tree_node_schema);
3018 TM->create_tree_node(new_tree_node_id, tn->
get_kind(), tree_node_schema);
3020 return_value = new_tree_node_id;
3025 const auto* cn = GetPointer<const cst_node>(tn);
3027 STR(
Transform(cn->type->index, parallel_degree, 0, new_stmt_list, new_phi_list));
3028 auto new_tree_node_id =
TM->new_tree_node_id();
3029 TM->create_tree_node(new_tree_node_id, vector_cst_K, tree_node_schema);
3030 auto* new_tn = GetPointer<vector_cst>(
TM->get_tree_node_const(new_tree_node_id));
3031 for(
size_t i = 0; i < parallel_degree; i++)
3033 new_tn->list_of_valu.push_back(
TM->GetTreeReindex(tn->
index));
3035 return_value = new_tree_node_id;
3040 const auto* gp = GetPointer<const gimple_phi>(tn);
3042 STR(
Transform(gp->scpe->index, parallel_degree, 0, new_stmt_list, new_phi_list));
3044 STR(
Transform(gp->res->index, parallel_degree, 0, new_stmt_list, new_phi_list));
3046 std::string include_name = gp->include_name;
3047 auto line_number = gp->line_number;
3048 auto column_number = gp->column_number;
3049 tree_node_schema[
TOK(
TOK_SRCP)] = include_name +
":" +
STR(line_number) +
":" +
STR(column_number);
3051 auto new_tree_node_id =
TM->new_tree_node_id();
3052 TM->create_tree_node(new_tree_node_id, gimple_phi_K, tree_node_schema);
3053 auto* new_gp = GetPointer<gimple_phi>(
TM->get_tree_node_const(new_tree_node_id));
3054 new_gp->SetSSAUsesComputed();
3055 for(
const auto& def_edge : gp->CGetDefEdgesList())
3066 new_stmt_list, new_phi_list)),
3075 return_value = new_tree_node_id;
3076 new_phi_list.push_back(
TM->GetTreeReindex(return_value));
3077 if(!gp->virtual_flag)
3082 for(
size_t scalar = 1; scalar <= parallel_degree; scalar++)
3085 const auto new_srcp = include_name +
":" +
STR(line_number) +
":" +
STR(column_number);
3088 const auto bit_size =
GET_CONST_NODE(element_type)->get_kind() != boolean_type_K ?
3091 const auto offset =
TM->CreateUniqueIntegerCst(static_cast<long long int>((scalar - 1) * bit_size),
3093 const auto size =
TM->CreateUniqueIntegerCst(static_cast<long long int>(bit_size),
3097 TM->GetTreeReindex(
Transform(gp->res->index, parallel_degree, 0, new_stmt_list, new_phi_list)),
3098 size,
offset, new_srcp, bit_field_ref_K);
3102 Transform(gp->res->index, parallel_degree, scalar, new_stmt_list, new_phi_list)),
3105 new_stmt_list.push_front(gimple_new_tree_node);
3113 const auto* te = GetPointer<const ternary_expr>(tn);
3115 STR(
Transform(te->type->index, parallel_degree, 0, new_stmt_list, new_phi_list));
3117 STR(
Transform(te->op2->index, parallel_degree, 0, new_stmt_list, new_phi_list));
3119 STR(
Transform(te->op1->index, parallel_degree, 0, new_stmt_list, new_phi_list));
3121 STR(
Transform(te->op0->index, parallel_degree, 0, new_stmt_list, new_phi_list));
3131 std::string include_name = te->include_name;
3132 auto line_number = te->line_number;
3133 auto column_number = te->column_number;
3134 tree_node_schema[
TOK(
TOK_SRCP)] = include_name +
":" +
STR(line_number) +
":" +
STR(column_number);
3135 auto new_tree_node_id =
TM->new_tree_node_id();
3136 TM->create_tree_node(new_tree_node_id, vec_cond_expr_K, tree_node_schema);
3137 return_value = new_tree_node_id;
3143 case namespace_decl_K:
3146 case template_decl_K:
3150 case aggr_init_expr_K:
3151 case case_label_expr_K:
3153 case statement_list_K:
3155 case target_mem_ref_K:
3156 case target_mem_ref461_K:
3167 case gimple_label_K:
3168 case gimple_multi_way_if_K:
3170 case gimple_pragma_K:
3171 case gimple_predict_K:
3173 case gimple_return_K:
3174 case gimple_switch_K:
3175 case gimple_while_K:
3178 case component_ref_K:
3179 case bit_field_ref_K:
3181 case with_cleanup_expr_K:
3182 case obj_type_ref_K:
3184 case vec_cond_expr_K:
3185 case vec_perm_expr_K:
3186 case dot_prod_expr_K:
3187 case ternary_plus_expr_K:
3188 case ternary_pm_expr_K:
3189 case ternary_mp_expr_K:
3190 case ternary_mm_expr_K:
3194 case bit_ior_concat_expr_K:
3196 case insertvalue_expr_K:
3197 case insertelement_expr_K:
3220 "<--Transformed " +
TM->get_tree_node_const(tree_node_index)->get_kind_text() +
" " +
3221 STR(tree_node_index) +
3222 ((
TM->get_tree_node_const(return_value)->get_kind() != function_decl_K) ?
3223 ": " +
TM->get_tree_node_const(return_value)->ToString() :
3225 return return_value;
#define GET_NODE(t)
Macro used to hide implementation details when accessing a tree_node from another tree_node...
tree_nodeRef CreateOrExpr(const tree_nodeConstRef &first_condition, const tree_nodeConstRef &second_condition, const blocRef &block, unsigned int function_decl_nid) const
Create an or expression.
tree_nodeRef ptd
ptd field points to the node for the type pointed to.
bool HasToBeExecuted() const override
Check if this step has actually to be executed.
void ClassifyTreeNode(const unsigned int loop_id, const tree_nodeConstRef tree_node)
Classify a statement.
This class contains the methods for vectorize loop or whole function.
#define DEBUG_LEVEL_VERY_PEDANTIC
extremely verbose debugging print is performed.
#define INDENT_DBG_MEX(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed;.
CustomUnorderedMap< unsigned int, CustomUnorderedMapStable< size_t, unsigned int > > scalar_to_scalar
Map between scalar tree node and versioned scalar tree node.
boost::graph_traits< graph >::out_edge_iterator OutEdgeIterator
out_edge_iterator definition.
Basic block control flow graph.
File containing functions and utilities to support the printing of debug messagges.
void SetPredication()
Set predicate of predicated instructions.
std::string ToString() const
Print this node as string in gimple format.
#define DEBUG_LEVEL_PEDANTIC
very verbose debugging print is performed.
Step successfully executed.
#define CASE_BINARY_EXPRESSION
This macro collects all case labels for binary_expr objects.
CustomMap< unsigned int, SimdLoop > simd_loop_type
Loop classification.
#define GET_CLASS(obj)
Macro returning the actual type of an object.
bool LookForScalar(const tree_nodeConstRef tree_node)
Check recursively if at least an ssa operand is defined an operation outside simd outer loop...
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...
std::string GetName() const override
Return the name of this design step.
RelationshipType
The relationship type.
Source must be executed to satisfy target.
const BBGraphInfoConstRef CGetBBGraphInfo() const
Returns the property associated with the graph.
DesignFlowStep_Status InternalExec() override
Restructures the unstructured code.
#define COUNTABLE_LOOP
countable loop
CustomMap< unsigned int, bool > basic_block_divergence
Basic block classification: if value is true, the basic block can be executed or not in parallel inst...
CustomOrderedMap< T, U > CustomMap
boost::graph_traits< graph >::in_edge_iterator InEdgeIterator
in_edge_iterator definition.
Vectorize(const application_managerRef AppM, unsigned int function_id, const DesignFlowManagerConstRef design_flow_manager, const ParameterConstRef parameters)
Constructor.
enum Transformation { NONE, COND_CON, COND_DIV, INC, INIT, SCALAR, SIMD, } Transformation
Enum used to classify the statement according to the required transformation.
A simple interface to token object of the raw files.
void PrintTreeManager(const bool before) const
Dump the tree manager.
Definition of hash function for EdgeDescriptor.
Data structure describing a basic block at tree level.
unsigned int bb_version
The version of the basic block intermediate representation on which this step has been applied...
std::list< vertex >::const_iterator exit_block_iter_begin() const
#define TOK(token)
Macro used to convert a token symbol into a treeVocabularyTokenTypes.
Abstract pure class for the tree structure.
virtual enum kind get_kind() const =0
Virtual function returning the type of the actual class.
#define STR(s)
Macro which performs a lexical_cast to a string.
Auxiliary methods for manipulating string.
#define FB_CFG_SELECTOR
Feedback control flow edge selector.
CustomMap< unsigned int, integer_cst_t > iv_increment
The increment of induction variables; id is the index of the ssa name defined in the init gimple...
#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.
static unsigned long long Size(const tree_nodeConstRef &tn)
Return the size of a tree object.
unsigned int DuplicateIncrement(const unsigned int loop_id, const tree_nodeRef statement)
Duplicate increment statement and update uses of defined variable when necessary. ...
absl::flat_hash_map< T, U, Hash, Eq, Alloc > CustomUnorderedMap
#define CDG_SELECTOR
Control dependence edge selector.
#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.
CustomUnorderedMapUnstable< unsigned int, unsigned int > scalar_to_vector
Map between scalar tree node and vector tree node.
unsigned int create_tree_node(const tree_nodeRef &tn, int mode=tree_node_dup_mode::DEFAULT)
tree_node visitors
void WriteBBGraphDot(const std::string &filename) const
Write the current version of statement list in dot format.
Basic block dominator tree.
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...
Classes to describe design flow graph.
Basic block control flow graph with feedback.
Target must be reexecuted.
std::pair< tree_nodeRef, unsigned int > DefEdge
The type of the def edge.
static std::string ToString(Transformation transformation)
Header include.
void ClassifyLoop(const LoopConstRef loop, const size_t parallel_degree)
Classify a loop.
#define BB_ENTRY
constant identifying the basic block node of type entry
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
CustomMap< unsigned int, size_t > loop_parallel_degree
Loop parallel degree.
unsigned offset[NUM_VERTICES+1]
~Vectorize() override
Destructor.
unsigned int Transform(const unsigned int tree_node_index, const size_t parallel_degree, const size_t scalar_index, std::list< tree_nodeRef > &new_stmt_list, std::vector< tree_nodeRef > &new_phi_list)
Transform a tree node.
#define GET_CONST_NODE(t)
boost::graph_traits< graph >::vertex_iterator VertexIterator
vertex_iterator definition.
DesignFlowStep_Status GetStatus() const
Return the status of this design step.
const ParameterConstRef parameters
Set of input parameters.
DesignFlowStep_Status
The status of a step.
Basic block control dependence graph.
This file collects some utility functions and macros.
Class defining some useful functions to create tree nodes and to manipulate the tree manager...
The key comparison function for vertices set based on levels.
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
static bool has_omp_simd(const statement_list *sl)
Check if omp simd pragmas are present in given statement list.
struct definition of the pointer_type tree node.
tree_nodeRef GetBooleanType() const
Function that creates a boolean type if it is not already present, otherwise it returns the one that ...
This struct specifies the block node.
const tree_manipulationRef tree_man
The tree_manipulation.
#define CASE_TYPE_NODES
This macro collects all case labels for type objects.
This file collects some utility functions.
void AddGuards()
Add the guards for predicated operations.
BBNodeInfoRef GetBBNodeInfo(const vertex node)
Return the info associated with a basic block.
CustomMap< unsigned int, tree_nodeRef > guards
The guards for each basic block.
tree_nodeRef create_ternary_operation(const tree_nodeConstRef &type, const tree_nodeRef &op0, const tree_nodeRef &op1, const tree_nodeRef &op2, const std::string &srcp, enum kind operation_kind) const
Function used to create a ternary expression.
const unsigned int function_id
The index of the function to be analyzed.
#define CASE_CST_NODES
This macro collects all case labels for cast nodes.
const application_managerRef AppM
The application manager.
vertex GetHeader() const
returns loop header
Class specification of the tree_reindex support class.
#define CASE_FAKE_NODES
This macro collects all case labels for fake or empty nodes.
Class specification of the basic_block structure.
const BBNodeInfoConstRef CGetBBNodeInfo(const vertex node) const
Return the info associated with a basic block.
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.
tree_nodeRef GetUnsignedIntegerType() const
Function that creates a unsigned integer type if it is not already present, otherwise it returns the ...
const CustomUnorderedSet< std::pair< FrontendFlowStepType, FunctionRelationship > > ComputeFrontendRelationships(const DesignFlowStep::RelationshipType relationship_type) const override
Return the set of analyses in relationship with this design step.
interface of loops finding algorithm
Classes specification of the tree_node data structures not present in the gcc.
this class is used to manage the command-line or XML options.
#define CASE_CPP_NODES
This macro collects all case labels for cpp nodes.
tree_nodeRef create_ssa_name(const tree_nodeConstRef &var, const tree_nodeConstRef &type, const tree_nodeConstRef &min, const tree_nodeConstRef &max, bool volatile_flag=false, bool virtual_flag=false) const
MISCELLANEOUS_OBJ_TREE_NODES.
refcount< tree_node > tree_nodeRef
RefCount type definition of the tree_node class structure.
tree node duplication class.
#define DOALL_LOOP
parallelizable for loop
absl::node_hash_map< T, U, Hash, Eq, Alloc > CustomUnorderedMapStable
#define CASE_GIMPLE_NODES
This macro collects all cases labels for gimple nodes.
static integer_cst_t GetConstValue(const tree_nodeConstRef &tn, bool is_signed=true)
Get value from integer constant.
int debug_level
The debug level.
CustomMap< unsigned int, Transformation > transformations
Statement classification.
bool IsReducible() const
tells if the loop is reducible
#define GET_INDEX_CONST_NODE(t)
tree_nodeRef create_gimple_modify_stmt(const tree_nodeRef &op0, const tree_nodeRef &op1, unsigned int function_decl_nid, const std::string &srcp) const
GIMPLE_ASSIGN.
void FixPhis()
Fix the phis to consider implicitly predicated operations.
This class creates a layer to add nodes and to manipulate the tree_nodes manager. ...
tree_nodeRef CreateAndExpr(const tree_nodeConstRef &first_condition, const tree_nodeConstRef &second_condition, const blocRef &block, unsigned int function_decl_nid) const
Create an or expression.
#define CASE_TERNARY_EXPRESSION
This macro collects all case labels for ternary_expr objects.
Class specification of the manager of the tree structures extracted from the raw file.
A brief description of the C++ Header File.
const FunctionBehaviorRef function_behavior
The function behavior of the function to be analyzed.
const tree_managerRef TM
The tree manager.
#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 ...