* This are out-edges (also called def-use edges) that are dynamically
* updated as the graph changes.
*/
-#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif
#include "irnode_t.h"
#include "iropt_t.h"
#include "debug.h"
#include "set.h"
#include "bitset.h"
+#include "error.h"
#include "iredgeset.h"
#include "hashptr.h"
static long last_edge_num = -1;
#endif
-static INLINE long edge_get_id(const ir_edge_t *e) {
+static inline long edge_get_id(const ir_edge_t *e) {
#ifdef DEBUG_libfirm
return e->edge_nr;
#else /* DEBUG_libfirm */
return res;
}
-/**
+/*
* Reset the user's private data at offset 'offset'
* The user has to remember his offset and the size of his data!
* Caution: Using wrong values here can destroy other users private data!
*/
-void edges_reset_private_data(ir_graph *irg, int offset, size_t size) {
+void edges_reset_private_data(ir_graph *irg, int offset, unsigned size) {
irg_edge_info_t *info = _get_irg_edge_info(irg, EDGE_KIND_NORMAL);
ir_edge_t *edge;
ir_edgeset_iterator_t iter;
obstack_free(&info->edges_obst, NULL);
}
obstack_init(&info->edges_obst);
+ INIT_LIST_HEAD(&info->free_edges);
ir_edgeset_init_size(&info->edges, amount);
info->allocated = 1;
}
* @param tgt the edge target
* @param kind the kind of the edge
*/
-static INLINE void edge_change_cnt(ir_node *tgt, ir_edge_kind_t kind, int ofs) {
+static inline void edge_change_cnt(ir_node *tgt, ir_edge_kind_t kind, int ofs) {
irn_edge_info_t *info = _get_irn_edge_info(tgt, kind);
info->out_count += ofs;
* Verify the edge list of a node, ie. ensure it's a loop:
* head -> e_1 -> ... -> e_n -> head
*/
-static INLINE void vrfy_list_head(ir_node *irn, ir_edge_kind_t kind) {
+static inline void vrfy_list_head(ir_node *irn, ir_edge_kind_t kind) {
int err = 0;
int num = 0;
pset *lh_set = pset_new_ptr(16);
if (edge) {
msg = "deleting";
list_del(&edge->list);
+ ir_edgeset_remove(edges, edge);
+ list_add(&edge->list, &info->free_edges);
edge->invalid = 1;
edge->pos = -2;
edge->src = NULL;
edge->edge_nr = -1;
#endif /* DEBUG_libfirm */
edge_change_cnt(old_tgt, kind, -1);
- }
-
- /* If the edge was not found issue a warning on the debug stream */
- else {
+ } else {
+ /* If the edge was not found issue a warning on the debug stream */
msg = "edge to delete not found!\n";
}
- } /* if */
-
- /*
- * The target is not NULL and the old target differs
- * from the new target, the edge shall be moved (if the
- * old target was != NULL) or added (if the old target was
- * NULL).
- */
- else {
+ } else {
+ /*
+ * The target is not NULL and the old target differs
+ * from the new target, the edge shall be moved (if the
+ * old target was != NULL) or added (if the old target was
+ * NULL).
+ */
struct list_head *head = _get_irn_outs_head(tgt, kind);
assert(head->next && head->prev &&
list_move(&edge->list, head);
edge_change_cnt(old_tgt, kind, -1);
- }
-
- /* The old target was null, thus, the edge is newly created. */
- else {
+ } else {
+ /* The old target was NULL, thus, the edge is newly created. */
ir_edge_t *new_edge;
- ir_edge_t *edge
- = obstack_alloc(&info->edges_obst, EDGE_SIZE);
- memset(edge, 0, EDGE_SIZE);
- edge->src = src;
- edge->pos = pos;
- edge->kind = kind;
+ ir_edge_t *edge;
+
+ if (list_empty(&info->free_edges)) {
+ edge = obstack_alloc(&info->edges_obst, EDGE_SIZE);
+ } else {
+ edge = list_entry(info->free_edges.next, ir_edge_t, list);
+ list_del(&edge->list);
+ }
+
+ edge->src = src;
+ edge->pos = pos;
+ edge->invalid = 0;
+ edge->present = 0;
+ edge->kind = kind;
+ edge->list.next = NULL;
+ edge->list.prev = NULL;
+ memset(((char*)edge) + sizeof(ir_edge_t), 0, edges_private_size);
DEBUG_ONLY(edge->src_nr = get_irn_node_nr(src));
new_edge = ir_edgeset_insert(edges, edge);
- if(new_edge != edge) {
- obstack_free(&info->edges_obst, edge);
+ if (new_edge != edge) {
+ panic("new edge exists already");
}
- assert(! edge->invalid && "Freshly inserted edge is invalid?!?");
- assert(edge->list.next == NULL && edge->list.prev == NULL &&
- "New edge must not have list head initialized");
-
msg = "adding";
list_add(&edge->list, head);
-#ifdef DEBUG_libfirm
- edge->edge_nr = ++last_edge_num;
-#endif /* DEBUG_libfirm */
+ DEBUG_ONLY(edge->edge_nr = ++last_edge_num);
}
edge_change_cnt(tgt, kind, +1);
visit.data = &w;
+ assert(!info->activated);
+
info->activated = 1;
edges_init_graph_kind(irg, kind);
if (kind == EDGE_KIND_DEP) {
edges_deactivate_kind(irg, EDGE_KIND_NORMAL);
}
-int edges_assure(ir_graph *irg) {
- int activated = edges_activated(irg);
+int edges_assure(ir_graph *irg)
+{
+ int activated = 0;
- if (!activated)
- edges_activate(irg);
+ if (edges_activated_kind(irg, EDGE_KIND_BLOCK)) {
+ activated = 1;
+ } else {
+ edges_activate_kind(irg, EDGE_KIND_BLOCK);
+ }
+ if (edges_activated_kind(irg, EDGE_KIND_NORMAL)) {
+ activated = 1;
+ } else {
+ edges_activate_kind(irg, EDGE_KIND_NORMAL);
+ }
return activated;
}