- VEC(constraint_edge_t,heap) *succvec = graph->succs[node];
- VEC(constraint_edge_t,heap) *predvec = graph->preds[node];
- bitmap_iterator bi;
- unsigned int j;
- constraint_edge_t c = NULL;
- int i;
-
- /* Walk the successors, erase the associated preds. */
-
- EXECUTE_IF_IN_NONNULL_BITMAP (graph->zero_weight_succs[node], 0, j, bi)
- if (j != node)
- bitmap_clear_bit (graph->zero_weight_preds[j], node);
-
- for (i = 0; VEC_iterate (constraint_edge_t, succvec, i, c); i++)
- if (c->dest != node)
- {
- unsigned int place;
- struct constraint_edge lookfor;
- constraint_edge_t result;
-
- lookfor.dest = node;
- place = VEC_lower_bound (constraint_edge_t, graph->preds[c->dest],
- &lookfor, constraint_edge_less);
- result = VEC_ordered_remove (constraint_edge_t,
- graph->preds[c->dest], place);
- pool_free (constraint_edge_pool, result);
- }
-
- /* Walk the preds, erase the associated succs. */
-
- EXECUTE_IF_IN_NONNULL_BITMAP (graph->zero_weight_preds[node], 0, j, bi)
- if (j != node)
- bitmap_clear_bit (graph->zero_weight_succs[j], node);
-
- for (i =0; VEC_iterate (constraint_edge_t, predvec, i, c); i++)
- if (c->dest != node)
- {
- unsigned int place;
- struct constraint_edge lookfor;
- constraint_edge_t result;
-
- lookfor.dest = node;
- place = VEC_lower_bound (constraint_edge_t, graph->succs[c->dest],
- &lookfor, constraint_edge_less);
- result = VEC_ordered_remove (constraint_edge_t,
- graph->succs[c->dest], place);
- pool_free (constraint_edge_pool, result);
-
- }
-
- if (graph->zero_weight_preds[node])
- {
- BITMAP_FREE (graph->zero_weight_preds[node]);
- graph->zero_weight_preds[node] = NULL;
- }
-
- if (graph->zero_weight_succs[node])
- {
- BITMAP_FREE (graph->zero_weight_succs[node]);
- graph->zero_weight_succs[node] = NULL;
- }
-
- VEC_free (constraint_edge_t, heap, graph->preds[node]);
- VEC_free (constraint_edge_t, heap, graph->succs[node]);
- graph->preds[node] = NULL;
- graph->succs[node] = NULL;
-}
-
-static bool edge_added = false;
-
-/* Add edge (src, dest) to the graph. */
-
-static bool
-add_graph_edge (constraint_graph_t graph, unsigned int src, unsigned int dest)
-{
- unsigned int place;
- VEC(constraint_edge_t,heap) *vec;
- struct constraint_edge newe;
- newe.dest = dest;
-
- vec = graph->preds[src];
- place = VEC_lower_bound (constraint_edge_t, vec, &newe,
- constraint_edge_less);
- if (place == VEC_length (constraint_edge_t, vec)
- || VEC_index (constraint_edge_t, vec, place)->dest != dest)
- {
- constraint_edge_t edge = new_constraint_edge (dest);
-
- VEC_safe_insert (constraint_edge_t, heap, graph->preds[src],
- place, edge);
- edge = new_constraint_edge (src);
-
- place = VEC_lower_bound (constraint_edge_t, graph->succs[dest],
- edge, constraint_edge_less);
- VEC_safe_insert (constraint_edge_t, heap, graph->succs[dest],
- place, edge);
- edge_added = true;
- stats.num_edges++;
- return true;
- }
- else
- return false;
-}
-
-
-/* Return the bitmap representing the weights of edge (SRC, DEST). */
-
-static bitmap *
-get_graph_weights (constraint_graph_t graph, unsigned int src,
- unsigned int dest)
-{
- constraint_edge_t edge;
- VEC(constraint_edge_t,heap) *vec;
- struct constraint_edge lookfor;
-
- lookfor.dest = dest;
-
- vec = graph->preds[src];
- edge = constraint_edge_vec_find (vec, lookfor);
- gcc_assert (edge != NULL);
- return &edge->weights;
-}
-
-/* Allocate graph weight bitmap for the edges associated with SRC and
- DEST in GRAPH. Both the pred and the succ edges share a single
- bitmap, so we need to set both edges to that bitmap. */
-
-static bitmap
-allocate_graph_weights (constraint_graph_t graph, unsigned int src,
- unsigned int dest)
-{
- bitmap result;
- constraint_edge_t edge;
- VEC(constraint_edge_t,heap) *vec;
- struct constraint_edge lookfor;
-
- result = BITMAP_ALLOC (&ptabitmap_obstack);
-
- /* Set the pred weight. */
- lookfor.dest = dest;
- vec = graph->preds[src];
- edge = constraint_edge_vec_find (vec, lookfor);
- gcc_assert (edge != NULL);
- edge->weights = result;
-
- /* Set the succ weight. */
- lookfor.dest = src;
- vec = graph->succs[dest];
- edge = constraint_edge_vec_find (vec, lookfor);
- gcc_assert (edge != NULL);
- edge->weights = result;
-
- return result;