Commit 5f623be3 authored by Matthias Braun's avatar Matthias Braun
Browse files

get rid of #define in public headers

parent 1888bb8f
......@@ -47,6 +47,25 @@
FIRM_API const ir_edge_t *get_irn_out_edge_first_kind(const ir_node *irn,
ir_edge_kind_t kind);
/**
* Returns the first edge pointing to some node.
* @note There is no order on out edges. First in this context only
* means, that you get some starting point into the list of edges.
* @param irn The node.
* @param kind The kind of the edge.
* @return The first out edge that points to this node.
*/
FIRM_API const ir_edge_t *get_irn_out_edge_first(const ir_node *irn);
/**
* Returns the first edge pointing to a successor block.
*
* You can navigate the list with the usual get_irn_out_edge_next().
* @param block the Block
* @return first block successor edge
*/
FIRM_API const ir_edge_t *get_block_succ_first(const ir_node *block);
/**
* Returns the next edge in the out list of some node.
* @param irn The node.
......@@ -115,6 +134,13 @@ FIRM_API int get_edge_src_pos(const ir_edge_t *edge);
*/
FIRM_API int get_irn_n_edges_kind(const ir_node *irn, ir_edge_kind_t kind);
/**
* Returns the number of registered out edges with EDGE_KIND_NORMAL
* @param irn The node.
* @param kind The kind.
*/
FIRM_API int get_irn_n_edges(const ir_node *irn);
/**
* Checks if the out edges are activated.
*
......@@ -125,6 +151,13 @@ FIRM_API int get_irn_n_edges_kind(const ir_node *irn, ir_edge_kind_t kind);
*/
FIRM_API int edges_activated_kind(const ir_graph *irg, ir_edge_kind_t kind);
/**
* Checks if out edges with EDG_KIND_NORMAL and EDGE_KIND_BLOCK are activated.
* @param irg The graph.
* @return 1, if the edges are present for the given irg, 0 if not.
*/
FIRM_API int edges_activated(const ir_graph *irg);
/**
* Activates the edges for an irg.
*
......@@ -150,6 +183,14 @@ FIRM_API void edges_deactivate_kind(ir_graph *irg, ir_edge_kind_t kind);
*/
FIRM_API void edges_reroute_kind(ir_node *old, ir_node *nw, ir_edge_kind_t kind);
/**
* Reroutes edges of EDGE_KIND_NORMAL from an old node to a new one.
*
* @param old the old node
* @param nw the new node
*/
FIRM_API void edges_reroute(ir_node *old, ir_node *nw);
/**
* reroutes (normal) edges from an old node to a new node, except for the
* @p exception which keeps its input even if it is old.
......@@ -185,31 +226,6 @@ FIRM_API void edges_init_dbg(int do_dbg);
FIRM_API ir_graph_pass_t *irg_verify_edges_pass(const char *name,
unsigned assert_on_problem);
/** Convenience version of edges_reroute_kind() with #EDGE_KIND_NORMAL */
#define edges_reroute(old, nw) edges_reroute_kind(old, nw, EDGE_KIND_NORMAL)
/** Conventience version of edges_activated_kind() for #EDGE_KIND_NORMAL and #EDGE_KIND_BLOCK */
#define edges_activated(irg) (edges_activated_kind(irg, EDGE_KIND_NORMAL) && edges_activated_kind(irg, EDGE_KIND_BLOCK))
#ifndef get_irn_n_edges
/** Conventience version of get_irn_n_edges_kind() with #EDGE_KIND_NORMAL. */
#define get_irn_n_edges(irn) get_irn_n_edges_kind(irn, EDGE_KIND_NORMAL)
#endif
#ifndef get_irn_out_edge_first
/** Convenience version of get_irn_out_edge_first_kind() with #EDGE_KIND_NORMAL */
#define get_irn_out_edge_first(irn) get_irn_out_edge_first_kind(irn, EDGE_KIND_NORMAL)
#endif
#ifndef get_block_succ_first
/** Convenience version of get_irn_out_edge_first_kind() with #EDGE_KIND_BLOCK */
#define get_block_succ_first(irn) get_irn_out_edge_first_kind(irn, EDGE_KIND_BLOCK)
#endif
#ifndef get_block_succ_next
/** Convenience version of get_irn_out_edge_next() with #EDGE_KIND_BLOCK */
#define get_block_succ_next(irn, last) get_irn_out_edge_next(irn, last)
#endif
/**
* Activates data and block edges for an irg.
* If the irg phase is phase_backend, Dependence edges are
......
......@@ -602,6 +602,11 @@ int (edges_activated_kind)(const ir_graph *irg, ir_edge_kind_t kind)
return edges_activated_kind_(irg, kind);
}
int (edges_activated)(const ir_graph *irg)
{
return edges_activated_(irg);
}
void edges_reroute_kind(ir_node *from, ir_node *to, ir_edge_kind_t kind)
{
ir_graph *irg = get_irn_irg(from);
......@@ -620,6 +625,11 @@ void edges_reroute_kind(ir_node *from, ir_node *to, ir_edge_kind_t kind)
}
}
void edges_reroute(ir_node *from, ir_node *to)
{
edges_reroute_kind(from, to, EDGE_KIND_NORMAL);
}
void edges_reroute_except(ir_node *from, ir_node *to, ir_node *exception)
{
foreach_out_edge_safe(from, edge) {
......@@ -854,7 +864,7 @@ ir_graph_pass_t *irg_verify_edges_pass(const char *name, unsigned assert_on_prob
void init_edges(void)
{
FIRM_DBG_REGISTER(dbg, DBG_EDGES);
FIRM_DBG_REGISTER(dbg, "firm.ir.edges");
}
void edges_init_dbg(int do_dbg)
......@@ -908,6 +918,16 @@ const ir_edge_t *(get_irn_out_edge_first_kind)(const ir_node *irn, ir_edge_kind_
return get_irn_out_edge_first_kind_(irn, kind);
}
const ir_edge_t *(get_irn_out_edge_first)(const ir_node *irn)
{
return get_irn_out_edge_first_kind_(irn, EDGE_KIND_NORMAL);
}
const ir_edge_t *(get_block_succ_first)(const ir_node *block)
{
return get_irn_out_edge_first_kind_(block, EDGE_KIND_BLOCK);
}
const ir_edge_t *(get_irn_out_edge_next)(const ir_node *irn, const ir_edge_t *last)
{
return get_irn_out_edge_next_(irn, last);
......
......@@ -37,7 +37,14 @@
#include "iredgekinds.h"
#include "iredges.h"
#define DBG_EDGES "firm.ir.edges"
#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)
#define get_edge_src_pos(edge) get_edge_src_pos_(edge)
#define get_irn_out_edge_next(irn, last) get_irn_out_edge_next_(irn, last)
#define get_irn_n_edges(irn) get_irn_n_edges_kind_(irn, EDGE_KIND_NORMAL)
#define get_irn_out_edge_first(irn) get_irn_out_edge_first_kind_(irn, EDGE_KIND_NORMAL)
#define get_block_succ_first(irn) get_irn_out_edge_first_kind_(irn, EDGE_KIND_BLOCK)
#define get_block_succ_next(irn, last) get_irn_out_edge_next_(irn, last)
/**
* An edge.
......@@ -122,6 +129,12 @@ static inline int edges_activated_kind_(const ir_graph *irg, ir_edge_kind_t kind
return get_irg_edge_info_const(irg, kind)->activated;
}
static inline int edges_activated_(const ir_graph *irg)
{
return edges_activated_kind(irg, EDGE_KIND_NORMAL)
&& edges_activated_kind(irg, EDGE_KIND_BLOCK);
}
/**
* Assure, that the edges information is present for a certain graph.
* @param irg The graph.
......@@ -184,25 +197,4 @@ void edges_dump_kind(ir_graph *irg, ir_edge_kind_t kind);
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)
#define get_edge_src_pos(edge) get_edge_src_pos_(edge)
#define get_irn_out_edge_next(irn, last) get_irn_out_edge_next_(irn, last)
#ifndef get_irn_n_edges
#define get_irn_n_edges(irn) get_irn_n_edges_kind_(irn, EDGE_KIND_NORMAL)
#endif
#ifndef get_irn_out_edge_first
#define get_irn_out_edge_first(irn) get_irn_out_edge_first_kind_(irn, EDGE_KIND_NORMAL)
#endif
#ifndef get_block_succ_first
#define get_block_succ_first(irn) get_irn_out_edge_first_kind_(irn, EDGE_KIND_BLOCK)
#endif
#ifndef get_block_succ_next
#define get_block_succ_next(irn, last) get_irn_out_edge_next_(irn, last)
#endif
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment