X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Firedges_t.h;h=db8eedeb08004722a85e2126d2b340c848e33665;hb=4483fd1671b94b61ed147d0247b313ee9b19f754;hp=daa6571d1c41e74b894eab6d46d4d8e945e256c0;hpb=05ea88e192e74d381d74c6336e36fd972d7d728e;p=libfirm diff --git a/ir/ir/iredges_t.h b/ir/ir/iredges_t.h index daa6571d1..db8eedeb0 100644 --- a/ir/ir/iredges_t.h +++ b/ir/ir/iredges_t.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. + * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved. * * This file is part of libFirm. * @@ -43,17 +43,13 @@ /** * An edge. */ -struct _ir_edge_t { - ir_node *src; /**< The source node of the edge. */ - int pos; /**< The position of the edge at @p src. */ - unsigned invalid : 1; /**< edges that are removed are marked invalid. */ - unsigned present : 1; /**< Used by the verifier. Don't rely on its content. */ - unsigned kind : 4; /**< The kind of the edge. */ - struct list_head list; /**< The list head to queue all out edges at a node. */ -#ifdef DEBUG_libfirm - long src_nr; /**< The node number of the source node. */ - long edge_nr; /**< A unique number identifying the edge. */ -#endif +struct ir_edge_t { + ir_node *src; /**< The source node of the edge. */ + int pos; /**< The position of the edge at @p src. */ + unsigned invalid : 1; /**< edges that are removed are marked invalid. */ + unsigned present : 1; /**< Used by the verifier. Don't rely on its content. */ + unsigned kind : 4; /**< The kind of the edge. */ + struct list_head list; /**< The list head to queue all out edges at a node. */ }; @@ -76,9 +72,11 @@ struct _ir_edge_t { * @param irn The node. * @return The first out edge that points to this node. */ -static INLINE const ir_edge_t *_get_irn_out_edge_first_kind(const ir_node *irn, ir_edge_kind_t kind) +static inline const ir_edge_t *_get_irn_out_edge_first_kind(const ir_node *irn, ir_edge_kind_t kind) { - const struct list_head *head = _get_irn_outs_head(irn, kind); + const struct list_head *head; + assert(edges_activated_kind(get_irn_irg(irn), kind)); + head = _get_irn_outs_head(irn, kind); return list_empty(head) ? NULL : list_entry(head->next, ir_edge_t, list); } @@ -88,7 +86,7 @@ static INLINE const ir_edge_t *_get_irn_out_edge_first_kind(const ir_node *irn, * @param last The last out edge you have seen. * @return The next out edge in @p irn 's out list after @p last. */ -static INLINE const ir_edge_t *_get_irn_out_edge_next(const ir_node *irn, const ir_edge_t *last) +static inline const ir_edge_t *_get_irn_out_edge_next(const ir_node *irn, const ir_edge_t *last) { struct list_head *next = last->list.next; return next == _get_irn_outs_head(irn, last->kind) ? NULL : list_entry(next, ir_edge_t, list); @@ -99,21 +97,12 @@ static INLINE const ir_edge_t *_get_irn_out_edge_next(const ir_node *irn, const * @param irn The node. * @return The number of edges pointing to this node. */ -static INLINE int _get_irn_n_edges_kind(const ir_node *irn, int kind) +static inline int _get_irn_n_edges_kind(const ir_node *irn, int kind) { - /* Perhaps out_count was buggy. This code does it more safely. */ -#if 0 - int res = 0; - const struct list_head *pos, *head = _get_irn_outs_head(irn, kind); - list_for_each(pos, head) - res++; - return res; -#else return _get_irn_edge_info(irn, kind)->out_count; -#endif } -static INLINE int _edges_activated_kind(const ir_graph *irg, ir_edge_kind_t kind) +static inline int _edges_activated_kind(const ir_graph *irg, ir_edge_kind_t kind) { return _get_irg_edge_info(irg, kind)->activated; } @@ -122,7 +111,7 @@ static INLINE int _edges_activated_kind(const ir_graph *irg, ir_edge_kind_t kind * Assure, that the edges information is present for a certain graph. * @param irg The graph. */ -static INLINE void _edges_assure_kind(ir_graph *irg, int kind) +static inline void _edges_assure_kind(ir_graph *irg, ir_edge_kind_t kind) { if(!_edges_activated_kind(irg, kind)) edges_activate_kind(irg, kind); @@ -131,17 +120,11 @@ static INLINE void _edges_assure_kind(ir_graph *irg, int kind) void edges_init_graph_kind(ir_graph *irg, ir_edge_kind_t kind); /** -* Notify of a edge change. -* The edge from (src, pos) -> old_tgt is redirected to tgt -*/ -void edges_notify_edge_kind(ir_node *src, int pos, ir_node *tgt, ir_node *old_tgt, ir_edge_kind_t kind, ir_graph *irg); - -/** -* A node is deleted. -*/ -void edges_node_deleted(ir_node *old, ir_graph *irg); + * A node might be revivaled by CSE. + */ +void edges_node_revival(ir_node *node); -void edges_invalidate_kind(ir_node *irn, ir_edge_kind_t kind, ir_graph *irg); +void edges_invalidate_kind(ir_node *irn, ir_edge_kind_t kind); /** * Register additional memory in an edge. @@ -151,7 +134,7 @@ void edges_invalidate_kind(ir_node *irn, ir_edge_kind_t kind, ir_graph *irg); * edges_get_private_data() * to get a pointer to your data. */ -int edges_register_private_data(size_t n); +size_t edges_register_private_data(size_t n); /** * Get a pointer to the private data you registered. @@ -160,17 +143,17 @@ int edges_register_private_data(size_t n); * edges_register_private_data(). * @return A pointer to the private data. */ -static INLINE void *_get_edge_private_data(const ir_edge_t *edge, int ofs) +static inline void *_get_edge_private_data(const ir_edge_t *edge, int ofs) { return (void *) ((char *) edge + sizeof(edge[0]) + ofs); } -static INLINE ir_node *_get_edge_src_irn(const ir_edge_t *edge) +static inline ir_node *_get_edge_src_irn(const ir_edge_t *edge) { return edge->src; } -static INLINE int _get_edge_src_pos(const ir_edge_t *edge) +static inline int _get_edge_src_pos(const ir_edge_t *edge) { return edge->pos; } @@ -181,12 +164,19 @@ static INLINE int _get_edge_src_pos(const ir_edge_t *edge) */ extern void init_edges(void); +void edges_invalidate_all(ir_node *irn); + /** - * Set dbg information for edges. + * Helper function to dump the edge set of a graph, + * unused in normal code. */ -void edges_init_dbg(int do_dbg); +void edges_dump_kind(ir_graph *irg, ir_edge_kind_t kind); -void edges_invalidate_all(ir_node *irn, ir_graph *irg); +/** + * Notify normal and block edges. + */ +void edges_notify_edge(ir_node *src, int pos, ir_node *tgt, + ir_node *old_tgt, ir_graph *irg); #define get_irn_n_edges_kind(irn, kind) _get_irn_n_edges_kind(irn, kind) #define get_edge_src_irn(edge) _get_edge_src_irn(edge)