25 #ifndef FIRM_IR_IRHOOKS_H
26 #define FIRM_IR_IRHOOKS_H
87 typedef struct hook_entry {
91 void (*_hook_new_ir_op)(
void *context,
ir_op *op);
94 void (*_hook_free_ir_op)(
void *context,
ir_op *op);
100 void (*_hook_set_irn_n)(
void *context,
ir_node *src,
107 void (*_hook_turn_into_id)(
void *context,
ir_node *node);
110 void (*_hook_normalize)(
void *context,
ir_node *node);
117 void (*_hook_free_graph)(
void *context,
ir_graph *irg);
129 void (*_hook_merge_nodes)(
void *context,
ir_node **new_node_array,
int new_num_entries,
133 void (*_hook_reassociate)(
void *context,
int start);
136 void (*_hook_lower)(
void *context,
ir_node *node);
142 void (*_hook_tail_rec)(
void *context,
ir_graph *irg,
int n_calls);
148 void (*_hook_dead_node_elim)(
void *context,
ir_graph *irg,
int start);
157 void (*_hook_arch_dep_replace_mul_with_shifts)(
void *context,
ir_node *irn);
160 void (*_hook_arch_dep_replace_division_by_const)(
void *context,
ir_node *irn);
163 void (*_hook_new_mode)(
void *context,
ir_mode *mode);
166 void (*_hook_new_entity)(
void *context,
ir_entity *ent);
169 void (*_hook_new_type)(
void *context,
ir_type *tp);
172 void (*_hook_node_info)(
void *context, FILE *f,
const ir_node *n);
241 #define hook_exec(what, args) do { \
243 for (_p = hooks[what]; _p; _p = _p->next){ \
244 void *hook_ctx_ = _p->context; \
245 _p->hook._##what args; \
250 #define hook_new_ir_op(op) hook_exec(hook_new_ir_op, (hook_ctx_, op))
252 #define hook_free_ir_op(op) hook_exec(hook_free_ir_op, (hook_ctx_, op))
254 #define hook_new_node(graph, node) hook_exec(hook_new_node, (hook_ctx_, graph, node))
256 #define hook_set_irn_n(src, pos, tgt, old_tgt) \
257 hook_exec(hook_set_irn_n, (hook_ctx_, src, pos, tgt, old_tgt))
259 #define hook_replace(old, nw) hook_exec(hook_replace, (hook_ctx_, old, nw))
261 #define hook_turn_into_id(node) hook_exec(hook_turn_into_id, (hook_ctx_, node))
263 #define hook_normalize(node) hook_exec(hook_normalize, (hook_ctx_, node))
265 #define hook_new_graph(irg, ent) hook_exec(hook_new_graph, (hook_ctx_, irg, ent))
267 #define hook_free_graph(irg) hook_exec(hook_free_graph, (hook_ctx_, irg))
269 #define hook_irg_walk(irg, pre, post) hook_exec(hook_irg_walk, (hook_ctx_, irg, pre, post))
271 #define hook_irg_walk_blkwise(irg, pre, post) \
272 hook_exec(hook_irg_walk_blkwise, (hook_ctx_, irg, pre, post))
274 #define hook_irg_block_walk(irg, node, pre, post) \
275 hook_exec(hook_irg_block_walk, (hook_ctx_, irg, node, pre, post))
277 #define hook_merge_nodes(new_node_array, new_num_entries, old_node_array, old_num_entries, opt) \
278 hook_exec(hook_merge_nodes, (hook_ctx_, new_node_array, new_num_entries, old_node_array, old_num_entries, opt))
280 #define hook_reassociate(start) hook_exec(hook_reassociate, (hook_ctx_, start))
282 #define hook_lower(node) hook_exec(hook_lower, (hook_ctx_, node))
284 #define hook_inline(call, irg) hook_exec(hook_inline, (hook_ctx_, call, irg))
286 #define hook_tail_rec(irg, n_calls) hook_exec(hook_tail_rec, (hook_ctx_, irg, n_calls))
288 #define hook_strength_red(irg, node) \
289 hook_exec(hook_strength_red, (hook_ctx_, irg, node))
291 #define hook_dead_node_elim(irg, start) hook_exec(hook_dead_node_elim, (hook_ctx_, irg, start))
293 #define hook_if_conversion(irg, phi, pos, mux, reason) \
294 hook_exec(hook_if_conversion, (hook_ctx_, irg, phi, pos, mux, reason))
296 #define hook_func_call(irg, call) \
297 hook_exec(hook_func_call, (hook_ctx_, irg, call))
299 #define hook_arch_dep_replace_mul_with_shifts(irn) \
300 hook_exec(hook_arch_dep_replace_mul_with_shifts, (hook_ctx_, irn))
302 #define hook_arch_dep_replace_division_by_const(irn) \
303 hook_exec(hook_arch_dep_replace_division_by_const, (hook_ctx_, irn))
305 #define hook_new_mode(mode) hook_exec(hook_new_mode, (hook_ctx_, mode))
307 #define hook_new_entity(ent) hook_exec(hook_new_entity, (hook_ctx_, ent))
309 #define hook_new_type(tp) hook_exec(hook_new_type, (hook_ctx_, tp))
311 #define hook_node_info(F, node) hook_exec(hook_node_info, (hook_ctx_, F, node))