Commit 9f7a1e68 authored by Matthias Braun's avatar Matthias Braun
Browse files

avoid _ prefix in identifiers, correct coding style

They are reserved in ANSI-C so instead of _XXX we use XXX_ now.
parent f35117c9
......@@ -38,7 +38,7 @@
/* Internal use. */
#define _bsfe_get_irn(irg, elm) (elm == (unsigned) -1 ? NULL : get_idx_irn((irg), (unsigned) elm))
#define bsfe_get_irn_(irg, elm) (elm == (unsigned) -1 ? NULL : get_idx_irn((irg), (unsigned) elm))
/**
* Iterate over a bitset containing node indexes.
......@@ -48,7 +48,7 @@
* @param irn An ir_node * which is set to the current node.
*/
#define bitset_foreach_irn(irg, bs, elm, irn) \
for(elm = bitset_next_set(bs, 0), irn = _bsfe_get_irn(irg, elm); elm != (unsigned) -1; elm = bitset_next_set(bs, elm + 1), irn = _bsfe_get_irn(irg, elm))
for(elm = bitset_next_set(bs, 0), irn = bsfe_get_irn_(irg, elm); elm != (unsigned) -1; elm = bitset_next_set(bs, elm + 1), irn = bsfe_get_irn_(irg, elm))
#endif
......@@ -185,7 +185,7 @@ size_t edges_register_private_data(size_t n)
*/
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);
irg_edge_info_t *info = get_irg_edge_info(irg, EDGE_KIND_NORMAL);
ir_edge_t *edge;
ir_edgeset_iterator_t iter;
......@@ -207,7 +207,7 @@ void edges_reset_private_data(ir_graph *irg, int offset, unsigned size)
void edges_init_graph_kind(ir_graph *irg, ir_edge_kind_t kind)
{
if (edges_activated_kind(irg, kind)) {
irg_edge_info_t *info = _get_irg_edge_info(irg, kind);
irg_edge_info_t *info = get_irg_edge_info(irg, kind);
size_t amount = irg->estimated_node_count * 2;
edges_used = 1;
......@@ -236,7 +236,7 @@ const ir_edge_t *get_irn_edge_kind(const ir_node *src, int pos, ir_edge_kind_t k
{
ir_graph *irg = get_irn_irg(src);
if (edges_activated_kind(irg, kind)) {
irg_edge_info_t *info = _get_irg_edge_info(irg, kind);
irg_edge_info_t *info = get_irg_edge_info(irg, kind);
ir_edge_t key;
key.src = (ir_node *)src;
......@@ -256,7 +256,7 @@ const ir_edge_t *get_irn_edge_kind(const ir_node *src, int pos, ir_edge_kind_t k
*/
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);
irn_edge_info_t *info = get_irn_edge_info(tgt, kind);
info->out_count += ofs;
}
......@@ -266,10 +266,10 @@ static inline void edge_change_cnt(ir_node *tgt, ir_edge_kind_t kind, int ofs)
*/
static inline void verify_list_head(ir_node *irn, ir_edge_kind_t kind)
{
int err = 0;
int num = 0;
pset *lh_set = pset_new_ptr(16);
const struct list_head *head = _get_irn_outs_head(irn, kind);
int err = 0;
int num = 0;
pset *lh_set = pset_new_ptr(16);
const struct list_head *head = &get_irn_edge_info(irn, kind)->outs_head;
const struct list_head *pos;
list_for_each(pos, head) {
......@@ -304,7 +304,7 @@ void edges_dump_kind(ir_graph *irg, ir_edge_kind_t kind)
if (!edges_activated_kind(irg, kind))
return;
info = _get_irg_edge_info(irg, kind);
info = get_irg_edge_info(irg, kind);
edges = &info->edges;
foreach_ir_edgeset(edges, e, iter) {
ir_printf("%+F %d %d\n", e->src, e->pos, e->invalid);
......@@ -329,7 +329,7 @@ void edges_notify_edge_kind(ir_node *src, int pos, ir_node *tgt,
if (tgt == old_tgt)
return;
info = _get_irg_edge_info(irg, kind);
info = get_irg_edge_info(irg, kind);
edges = &info->edges;
/* Initialize the edge template to search in the set. */
......@@ -364,7 +364,7 @@ void edges_notify_edge_kind(ir_node *src, int pos, ir_node *tgt,
* old target was != NULL) or added (if the old target was
* NULL).
*/
struct list_head *head = _get_irn_outs_head(tgt, kind);
struct list_head *head = &get_irn_edge_info(tgt, kind)->outs_head;
assert(head->next && head->prev &&
"target list head must have been initialized");
......@@ -497,7 +497,7 @@ static void edges_node_revival_kind(ir_node *irn, ir_edge_kind_t kind)
if (!edges_activated_kind(irg, kind))
return;
info = _get_irn_edge_info(irn, kind);
info = get_irn_edge_info(irn, kind);
if (info->edges_built)
return;
......@@ -530,7 +530,7 @@ static void build_edges_walker(ir_node *irn, void *data)
ir_node *pred = get_n(irn, i, kind);
edges_notify_edge_kind(irn, i, pred, NULL, kind, irg);
}
_get_irn_edge_info(irn, kind)->edges_built = 1;
get_irn_edge_info(irn, kind)->edges_built = 1;
}
/**
......@@ -541,10 +541,10 @@ static void init_lh_walker(ir_node *irn, void *data)
{
build_walker *w = (build_walker*)data;
ir_edge_kind_t kind = w->kind;
list_head *head = _get_irn_outs_head(irn, kind);
list_head *head = &get_irn_edge_info(irn, kind)->outs_head;
INIT_LIST_HEAD(head);
_get_irn_edge_info(irn, kind)->edges_built = 0;
_get_irn_edge_info(irn, kind)->out_count = 0;
get_irn_edge_info(irn, kind)->edges_built = 0;
get_irn_edge_info(irn, kind)->out_count = 0;
}
/**
......@@ -562,21 +562,21 @@ static void init_lh_walker_dep(ir_node *irn, void *data)
{
build_walker *w = (build_walker*)data;
ir_edge_kind_t kind = w->kind;
list_head *head = _get_irn_outs_head(irn, kind);
list_head *head = &get_irn_edge_info(irn, kind)->outs_head;
int i;
INIT_LIST_HEAD(head);
_get_irn_edge_info(irn, kind)->edges_built = 0;
_get_irn_edge_info(irn, kind)->out_count = 0;
get_irn_edge_info(irn, kind)->edges_built = 0;
get_irn_edge_info(irn, kind)->out_count = 0;
for (i = get_irn_deps(irn) - 1; i >= 0; --i) {
ir_node *dep = get_irn_dep(irn, i);
head = _get_irn_outs_head(dep, kind);
head = &get_irn_edge_info(dep, kind)->outs_head;
INIT_LIST_HEAD(head);
_get_irn_edge_info(dep, kind)->edges_built = 0;
_get_irn_edge_info(dep, kind)->out_count = 0;
get_irn_edge_info(dep, kind)->edges_built = 0;
get_irn_edge_info(dep, kind)->out_count = 0;
}
}
......@@ -628,7 +628,7 @@ static void visitor(ir_node *irn, void *data)
void edges_activate_kind(ir_graph *irg, ir_edge_kind_t kind)
{
struct build_walker w;
irg_edge_info_t *info = _get_irg_edge_info(irg, kind);
irg_edge_info_t *info = get_irg_edge_info(irg, kind);
visitor_info_t visit;
w.kind = kind;
......@@ -654,7 +654,7 @@ void edges_activate_kind(ir_graph *irg, ir_edge_kind_t kind)
void edges_deactivate_kind(ir_graph *irg, ir_edge_kind_t kind)
{
irg_edge_info_t *info = _get_irg_edge_info(irg, kind);
irg_edge_info_t *info = get_irg_edge_info(irg, kind);
info->activated = 0;
if (info->allocated) {
......@@ -666,7 +666,7 @@ void edges_deactivate_kind(ir_graph *irg, ir_edge_kind_t kind)
int (edges_activated_kind)(const ir_graph *irg, ir_edge_kind_t kind)
{
return _edges_activated_kind(irg, kind);
return edges_activated_kind_(irg, kind);
}
......@@ -683,7 +683,7 @@ void edges_reroute_kind(ir_node *from, ir_node *to, ir_edge_kind_t kind)
set_edge_func_t *set_edge = edge_kind_info[kind].set_edge;
if (set_edge && edges_activated_kind(irg, kind)) {
struct list_head *head = _get_irn_outs_head(from, kind);
struct list_head *head = &get_irn_edge_info(from, kind)->outs_head;
DBG((dbg, LEVEL_5, "reroute from %+F to %+F\n", from, to));
......@@ -699,7 +699,7 @@ static void verify_set_presence(ir_node *irn, void *data)
{
build_walker *w = (build_walker*)data;
ir_graph *irg = get_irn_irg(irn);
ir_edgeset_t *edges = &_get_irg_edge_info(irg, w->kind)->edges;
ir_edgeset_t *edges = &get_irg_edge_info(irg, w->kind)->edges;
int i, n;
foreach_tgt(irn, i, n, w->kind) {
......@@ -746,7 +746,7 @@ static void verify_list_presence(ir_node *irn, void *data)
int edges_verify_kind(ir_graph *irg, ir_edge_kind_t kind)
{
struct build_walker w;
ir_edgeset_t *edges = &_get_irg_edge_info(irg, kind)->edges;
ir_edgeset_t *edges = &get_irg_edge_info(irg, kind)->edges;
ir_edge_t *e;
ir_edgeset_iterator_t iter;
......@@ -837,8 +837,8 @@ static void verify_edge_counter(ir_node *irn, void *env)
bs = (bitset_t*)get_irn_link(irn);
list_cnt = 0;
ref_cnt = 0;
edge_cnt = _get_irn_edge_info(irn, EDGE_KIND_NORMAL)->out_count;
head = _get_irn_outs_head(irn, EDGE_KIND_NORMAL);
edge_cnt = get_irn_edge_info(irn, EDGE_KIND_NORMAL)->out_count;
head = &get_irn_edge_info(irn, EDGE_KIND_NORMAL)->outs_head;
/* We can iterate safely here, list heads have already been verified. */
list_for_each(pos, head) {
......@@ -998,27 +998,27 @@ void edges_node_revival(ir_node *irn)
const ir_edge_t *(get_irn_out_edge_first_kind)(const ir_node *irn, ir_edge_kind_t kind)
{
return _get_irn_out_edge_first_kind(irn, kind);
return get_irn_out_edge_first_kind_(irn, kind);
}
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);
return get_irn_out_edge_next_(irn, last);
}
ir_node *(get_edge_src_irn)(const ir_edge_t *edge)
{
return _get_edge_src_irn(edge);
return get_edge_src_irn_(edge);
}
int (get_edge_src_pos)(const ir_edge_t *edge)
{
return _get_edge_src_pos(edge);
return get_edge_src_pos_(edge);
}
int (get_irn_n_edges_kind)(const ir_node *irn, ir_edge_kind_t kind)
{
return _get_irn_n_edges_kind(irn, kind);
return get_irn_n_edges_kind_(irn, kind);
}
static void irg_walk_edges2(ir_node *node, irg_walk_func *pre,
......
......@@ -52,68 +52,84 @@ struct ir_edge_t {
struct list_head list; /**< The list head to queue all out edges at a node. */
};
/** Accessor for private irn info. */
#define _get_irn_edge_info(irn, kind) (&(((irn)->edge_info)[kind]))
static inline irn_edge_info_t *get_irn_edge_info(ir_node *node,
ir_edge_kind_t kind)
{
return &node->edge_info[kind];
}
static inline const irn_edge_info_t *get_irn_edge_info_const(
const ir_node *node, ir_edge_kind_t kind)
{
return &node->edge_info[kind];
}
/** Accessor for private irg info. */
#define _get_irg_edge_info(irg, kind) (&(((irg)->edge_info)[kind]))
static inline irg_edge_info_t *get_irg_edge_info(ir_graph *irg,
ir_edge_kind_t kind)
{
return &irg->edge_info[kind];
}
/**
* Convenience macro to get the outs_head from a irn_edge_info_t
* struct.
*/
#define _get_irn_outs_head(irn, kind) (&_get_irn_edge_info(irn, kind)->outs_head)
/** Accessor for private irg info. */
static inline const irg_edge_info_t *get_irg_edge_info_const(
const ir_graph *irg, ir_edge_kind_t kind)
{
return &irg->edge_info[kind];
}
/**
* Get 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.
* @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)
* Get 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.
* @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)
{
const struct list_head *head;
assert(edges_activated_kind(get_irn_irg(irn), kind));
head = _get_irn_outs_head(irn, kind);
head = &get_irn_edge_info_const(irn, kind)->outs_head;
return list_empty(head) ? NULL : list_entry(head->next, ir_edge_t, list);
}
/**
* Get the next edge in the out list of some node.
* @param irn The node.
* @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)
* Get the next edge in the out list of some node.
* @param irn The node.
* @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)
{
struct list_head *next = last->list.next;
return next == _get_irn_outs_head(irn, last->kind) ? NULL : list_entry(next, ir_edge_t, list);
const struct list_head *head
= &get_irn_edge_info_const(irn, last->kind)->outs_head;
return next == head ? NULL : list_entry(next, ir_edge_t, list);
}
/**
* Get the number of edges pointing to a node.
* @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)
* Get the number of edges pointing to a node.
* @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)
{
return _get_irn_edge_info(irn, kind)->out_count;
return get_irn_edge_info_const(irn, kind)->out_count;
}
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;
return get_irg_edge_info_const(irg, kind)->activated;
}
/**
* Assure, that the edges information is present for a certain graph.
* @param irg The graph.
*/
static inline void _edges_assure_kind(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, ir_edge_kind_t kind)
{
if(!_edges_activated_kind(irg, kind))
if(!edges_activated_kind_(irg, kind))
edges_activate_kind(irg, kind);
}
......@@ -127,41 +143,41 @@ void edges_node_revival(ir_node *node);
void edges_invalidate_kind(ir_node *irn, ir_edge_kind_t kind);
/**
* Register additional memory in an edge.
* This must be called before Firm is initialized.
* @param n Number of bytes you need.
* @return A number you have to keep and to pass
* edges_get_private_data()
* to get a pointer to your data.
*/
* Register additional memory in an edge.
* This must be called before Firm is initialized.
* @param n Number of bytes you need.
* @return A number you have to keep and to pass
* edges_get_private_data()
* to get a pointer to your data.
*/
size_t edges_register_private_data(size_t n);
/**
* Get a pointer to the private data you registered.
* @param edge The edge.
* @param ofs The number, you obtained with
* 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)
* Get a pointer to the private data you registered.
* @param edge The edge.
* @param ofs The number, you obtained with
* 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)
{
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;
}
/**
* Initialize the out edges.
* This must be called before firm is initialized.
*/
* Initialize the out edges.
* This must be called before firm is initialized.
*/
extern void init_edges(void);
void edges_invalidate_all(ir_node *irn);
......@@ -178,26 +194,26 @@ 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_edge_private_data(edge, ofs) _get_edge_private_data(edge,ofs)
#define get_irn_out_edge_next(irn, last) _get_irn_out_edge_next(irn, last)
#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_edge_private_data(edge, ofs) get_edge_private_data_(edge,ofs)
#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)
#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)
#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)
#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)
#define get_block_succ_next(irn, last) get_irn_out_edge_next_(irn, last)
#endif
#endif
......@@ -68,7 +68,7 @@ void set_opt_##name(int flag) { \
else libFIRM_opt &= ~irf_##name; \
} \
int (get_opt_##name)(void) { \
return _get_opt_##name(); \
return get_opt_##name##_(); \
}
/* an internal flag can only be set from outside */
......
......@@ -66,7 +66,7 @@ void firm_init_flags(void);
/* generate the getter functions for external access */
#define E_FLAG(name, value, def) \
static inline int _get_opt_##name(void) { \
static inline int get_opt_##name##_(void) { \
return libFIRM_opt & irf_##name; \
}
......@@ -92,7 +92,7 @@ static inline void set_##name##_running(int flag) {\
#undef E_FLAG
#undef R_FLAG
static inline int _get_optimize(void)
static inline int get_optimize_(void)
{
return get_opt_optimize();
}
......@@ -102,9 +102,9 @@ static inline firm_verification_t get_node_verification_mode(void)
return opt_do_node_verification;
}
#define get_optimize() _get_optimize()
#define get_opt_cse() _get_opt_cse()
#define get_opt_dyn_meth_dispatch() _get_opt_dyn_meth_dispatch()
#define get_opt_suppress_downcast_optimization() _get_opt_suppress_downcast_optimization()
#define get_optimize() get_optimize_()
#define get_opt_cse() get_opt_cse_()
#define get_opt_dyn_meth_dispatch() get_opt_dyn_meth_dispatch_()
#define get_opt_suppress_downcast_optimization() get_opt_suppress_downcast_optimization_()
#endif
......@@ -460,7 +460,7 @@ void free_ir_graph(ir_graph *irg)
int (is_ir_graph)(const void *thing)
{
return _is_ir_graph(thing);
return is_ir_graph_(thing);
}
#ifdef DEBUG_libfirm
......@@ -483,117 +483,117 @@ size_t get_irg_idx(const ir_graph *irg)
ir_node *(get_idx_irn)(const ir_graph *irg, unsigned idx)
{
return _get_idx_irn(irg, idx);
return get_idx_irn_(irg, idx);
}
ir_node *(get_irg_start_block)(const ir_graph *irg)
{
return _get_irg_start_block(irg);
return get_irg_start_block_(irg);
}
void (set_irg_start_block)(ir_graph *irg, ir_node *node)
{
_set_irg_start_block(irg, node);
set_irg_start_block_(irg, node);
}
ir_node *(get_irg_start)(const ir_graph *irg)
{
return _get_irg_start(irg);
return get_irg_start_(irg);
}
void (set_irg_start)(ir_graph *irg, ir_node *node)
{
_set_irg_start(irg, node);
set_irg_start_(irg, node);
}
ir_node *(get_irg_end_block)(const ir_graph *irg)
{
return _get_irg_end_block(irg);
return get_irg_end_block_(irg);
}
void (set_irg_end_block)(ir_graph *irg, ir_node *node)
{
_set_irg_end_block(irg, node);
set_irg_end_block_(irg, node);
}
ir_node *(get_irg_end)(const ir_graph *irg)
{
return _get_irg_end(irg);
return get_irg_end_(irg);
}
void (set_irg_end)(ir_graph *irg, ir_node *node)
{
_set_irg_end(irg, node);
set_irg_end_(irg, node);
}
ir_node *(get_irg_initial_exec)(const ir_graph *irg)
{
return _get_irg_initial_exec(irg);
return get_irg_initial_exec_(irg);
}
void (set_irg_initial_exec)(ir_graph *irg, ir_node *node)
{
_set_irg_initial_exec(irg, node);
set_irg_initial_exec_(irg, node);
}
ir_node *(get_irg_frame)(const ir_graph *irg)
{
return _get_irg_frame(irg);
return get_irg_frame_(irg);
}
void (set_irg_frame)(ir_graph *irg, ir_node *node)
{
_set_irg_frame(irg, node);
set_irg_frame_(irg, node);
}
ir_node *(get_irg_initial_mem)(const ir_graph *irg)
{
return _get_irg_initial_mem(irg);
return get_irg_initial_mem_(irg);
}
void (set_irg_initial_mem)(ir_graph *irg, ir_node *node)
{
_set_irg_initial_mem(irg, node);
set_irg_initial_mem_(irg, node);
}
ir_node *(get_irg_args)(const ir_graph *irg)
{
return _get_irg_args(irg);
return get_irg_args_(irg);
}
void (set_irg_args)(ir_graph *irg, ir_node *node)
{
_set_irg_args(irg, node);
set_irg_args_(irg, node);
}
ir_node *(get_irg_no_mem)(const ir_graph *irg)
{
return _get_irg_no_mem(irg);
return get_irg_no_mem_(irg);
}
void (set_irg_no_mem)(ir_graph *irg, ir_node *node)
{
_set_irg_no_mem(irg, node);
set_irg_no_mem_(irg, node);
}