FOR_EACH (node,nodes) { // Adding components std::list<std::shared_ptr<PlugNode>> node_and_components; PlugNodeUtils::node_and_components(*node, node_and_components); // Build nodes and components FOR_EACH (node_and_components_iter,node_and_components) { // Scan connections for (PlugIter p_iter(node_and_components_iter->get()); p_iter; ++p_iter) { if (p_iter()->is_no_draw()) continue; // Incoming if (p_iter()->has_incoming_connection()) { if (p_iter()->incoming_connection()->is_no_draw()) continue; cr.append_undo_command(CommandParams("ConnectPlugs \"" + p_iter()->incoming_connection()->full_name() + "\" \"" + p_iter()->full_name() + "\"" )); } // Outgoing const std::vector<PlugBase*> &connections = p_iter()->outgoing_connections(); for (DTuint k = 0; k < connections.size(); ++k) { if (connections[k]->is_no_draw()) continue; cr.append_undo_command(CommandParams("ConnectPlugs \"" + p_iter()->full_name() + "\" \"" + connections[k]->full_name() + "\"" )); } } // Events for (EventIter e_iter(node_and_components_iter->get()); e_iter; ++e_iter) { if (e_iter()->is_no_draw()) continue; // Incoming const std::vector<Event*> &connections_in = e_iter()->incoming_connections(); for (DTuint k = 0; k < connections_in.size(); ++k) { if (connections_in[k]->is_no_draw()) continue; cr.append_undo_command(CommandParams("ConnectEvents \"" + connections_in[k]->full_name() + "\" \"" + e_iter()->full_name() + "\"" )); } // Outgoing const std::vector<Event*> &connections_out = e_iter()->outgoing_connections(); for (DTuint k = 0; k < connections_out.size(); ++k) { if (connections_out[k]->is_no_draw()) continue; cr.append_undo_command(CommandParams("ConnectEvents \"" + e_iter()->full_name() + "\" \"" + connections_out[k]->full_name() + "\"" )); } } } }
/* * SB identified by the entry_bb and the set of BBs (hb_bbs) */ void El_fprize_this_sb(Procedure *f, Basicblock *entry_bb, List_set<Basicblock*>& hb_bbs) { Hash_set<Edge*> top_entry_edges(hash_edge_ptr); Edge *edge; Compound_region *cr; if (dbg(cpr, 2)) { cdbg << "\tFRPizing Hyperblock with entry " << entry_bb->id() << endl; cdbg << "\tBBS: "; for (List_set_iterator<Basicblock*> hs_iter(hb_bbs); hs_iter!=0; hs_iter++) { cdbg << (*hs_iter)->id() << " "; } cdbg << endl; } for(Region_entry_edges e_iter(entry_bb);e_iter!=0;e_iter++) { edge = *e_iter; top_entry_edges += edge; } // Create a temporary cr for if-conversion cr=el_mark_cr_on_cfg(f, hb_bbs, top_entry_edges); // If convert El_if_convert(cr, El_frp_model); // Nuke the temporary cr, its no longer needed El_remove_region(cr, true); }
void El_find_bbs_in_hb(Hyperblock *hb, Basicblock **entry_bb, List_set<Basicblock*>& hb_bbs) { Region *bb, *e_bb; Op *e_op; int count; // Find entry_bb count = 0; for (Region_entry_ops e_iter(hb); e_iter!=0; e_iter++) { e_op = *e_iter; e_bb = ((Region *)e_op)->parent(); if (! e_bb->is_bb()) El_punt("El_find_bbs_in_hb: no BB tiling!!"); *entry_bb = (Basicblock *)e_bb; count++; } if (count!=1) El_punt("El_find_bbs_in_hb: %d entry ops found in Hyperblock %d", count, hb->id()); // Fill in hb_bbs for (Region_subregions r_iter(hb); r_iter!=0; r_iter++) { bb = *r_iter; if (! bb->is_bb()) El_punt("El_find_bbs_in_hb: Basicblock tiling not present"); hb_bbs += ((Basicblock *) bb); } }
tcwbool_ATTLC cycle_sub(char gtype, const Edge* e, List_of_p<Edge>& e_list, const Graph& g, Vis_v_ticket vt) { Vertex* v; Vertex* last_v; Set_of_p<Edge> e_pset; int i = e->src()->visited(vt); //better to place these in block below, int j = e->dst()->visited(vt); //but get cc warning stmt not reached switch (gtype) { case 'd': v = e->dst(); e_pset = v->out_edges_g(g); break; case 'u': if (i && j) /*use of temp ints nec: && not implemented*/ return(FALS); //this edge is going back the way it came else { if (e->src()->visited(vt)) { v = e->dst(); last_v = e->src(); } else { v = e->src(); last_v = e->dst(); } e_pset = v->edges_g(g); } break; } Edge* next_e; tcwbool_ATTLC found_cycle = FALS; v->set_visited(vt); Set_of_piter<Edge> e_iter(e_pset); if ((gtype == 'd')) { while (next_e = e_iter.next()) { if (cycle1_test(next_e)) { e_list.put(next_e); found_cycle = TRU; // cycle was found } } } else if ((gtype == 'u') && e_list.length()) { //3rd next to see, 1st put on at end while (next_e = e_iter.next()) { if (cycle3_test(next_e, last_v, v)) { e_list.put(next_e); found_cycle = TRU; // cycle was found } } } if (!found_cycle) { //this vertex doesn't have an //edge back to e, keep looking Set_of_piter<Edge> eset_iter(e_pset); Vertex* next_v; while (next_e = eset_iter.next()) { if (gtype == 'd') next_v = next_e->dst(); else //gtype == 'u' next_v = (next_e->src() == v) ? next_e->dst() : next_e->src(); if (!next_v->visited(vt)) { e_list.put(next_e); //temporary put perhaps if (cycle_sub(gtype, next_e, e_list, g, vt)) { found_cycle = TRU; break; } else e_list.unput(next_e); //edge panned out } } } return(found_cycle); }
/* in this function, test_type == 1 means to look for a cycle that contains the node "orig_source", test_type == 2 means to look for any old cycle */ tcwbool_ATTLC cycle0_sub(char gtype, const Edge* e, int test_type, Vertex** vp, const Graph& g, Vis_v_ticket vt) { Vertex* v; Vertex* last_v; Set_of_p<Edge> e_pset; int i = e->src()->visited(vt); //better to place these in block below, int j = e->dst()->visited(vt); //but get cc warning stmt not reached switch (gtype) { case 'd': v = e->dst(); e_pset = v->out_edges_g(g); break; case 'u': if (i && j) /*temp ints nec: && not implemented*/ return(FALS); //this edge is going back the way it came else { if (e->src()->visited(vt)) { v = e->dst(); last_v = e->src(); } else { v = e->src(); last_v = e->dst(); } e_pset = v->edges_g(g); } break; } Edge* next_e; tcwbool_ATTLC found_cycle = FALS; v->set_visited(vt); stat_v_pset.insert(v); Set_of_piter<Edge> e_iter(e_pset); if ((test_type == 1) && (gtype == 'd')) { while (next_e = e_iter.next()) { if (cycle1_test(next_e)) found_cycle = TRU; } } else if ((test_type == 1) && (gtype == 'u') && (stat_v_pset.size() >= 3)) { while (next_e = e_iter.next()) { if (cycle3_test(next_e, last_v, v)) found_cycle = TRU; } } else if ((test_type == 2) && (gtype == 'd')) { while (next_e = e_iter.next()) { if (cycle2_test(next_e)) { *vp = next_e->dst(); found_cycle = TRU; } } } else if ((test_type == 2) && (gtype == 'u') && (stat_v_pset.size() >= 3)) { while (next_e = e_iter.next()) { if (cycle4_test(next_e, last_v, v)) { *vp = (next_e->src() == v) ? next_e->dst() : next_e->src(); found_cycle = TRU; } } } if (!found_cycle) { //keep looking Set_of_piter<Edge> eset_iter(e_pset); Vertex* next_v; while (next_e = eset_iter.next()) { if (gtype == 'd') next_v = next_e->dst(); else //gtype == 'u' next_v = (next_e->src() == v) ? next_e->dst() : next_e->src(); if (!next_v->visited(vt)) { if (cycle0_sub(gtype, next_e, test_type, vp, g, vt)) { found_cycle = TRU; break; } } } } if (!found_cycle) { stat_v_pset.remove(v); //undo insert } return(found_cycle); }