5 #include "firm_config.h"
13 /* iterate over a list of ir_nodes linked by link field */
14 #define foreach_linked_irns(head, iter) for ((iter) = (head); (iter); (iter) = get_irn_link((iter)))
18 * This function always returns the same set.
20 pset *be_empty_set(void);
23 /** Undefine this to disable debugging mode. */
27 * Convenient block getter.
28 * Works also, if the given node is a block.
29 * @param irn The node.
30 * @return The block of the node, or the node itself, if the node is a
33 static INLINE const ir_node *get_block(const ir_node *irn)
35 return is_Block(irn) ? irn : get_nodes_block(irn);
38 static INLINE int is_firm_be_mode(const ir_mode *mode)
40 return mode_is_data(mode);
44 * Check, if a node produces or consumes a data value.
45 * If it does, it is significant for scheduling and register allocation.
46 * A node produces/consumes a data value, if one of its operands is of
47 * mode datab, or his retuning mode is of mode datab.
48 * @param irn The node to check for.
49 * @return 1, if the node is a data node, 0 if not.
51 static INLINE int is_data_node(const ir_node *irn)
55 /* If the node produces a data value, return immediately. */
56 if(is_firm_be_mode(get_irn_mode(irn)))
59 /* else check, if it takes a data value, if that is so, return */
60 for(i = 0, n = get_irn_arity(irn); i < n; ++i) {
61 ir_node *op = get_irn_n(irn, i);
62 if(is_firm_be_mode(get_irn_mode(op)))
66 /* Else the node does not produce/consume a data value */
71 * Dump a vcg graph containing the controlflow graph, the schedule and
72 * allocated registers.
73 * @param irg The irg. Note that scheduling, register allocation must
74 * have been performed.
76 void dump_allocated_irg(arch_env_t *env, ir_graph *irg, char *suffix);
78 void be_clear_links(ir_graph *irg);
80 static INLINE FILE *ffopen(const char *base, const char *ext, const char *mode) {
84 snprintf(buf, sizeof(buf), "%s.%s", base, ext);
85 buf[sizeof(buf) - 1] = '\0';
86 if (! (out = fopen(buf, mode))) {
87 fprintf(stderr, "Cannot open file %s in mode %s\n", buf, mode);
94 * Dump a graph with schedule edges.
95 * @param irg The graph.
96 * @param suffix A suffix to its file name.
98 void dump_ir_block_graph_sched(ir_graph *irg, const char *suffix);
101 * Dump a extended block graph with schedule edges.
102 * @param irg The graph.
103 * @param suffix A suffix to its file name.
105 void dump_ir_extblock_graph_sched(ir_graph *irg, const char *suffix);
108 * Dumps a graph and numbers all dumps.
109 * @param irg The graph
110 * @param suffix A suffix to its file name.
111 * @param dumper The dump function
113 void be_dump(ir_graph *irg, const char *suffix, void (*dumper)(ir_graph *, const char *));
116 * Returns the number of reachable nodes in an irg.
117 * @param irg The irg.
118 * @return The number of reachable nodes.
120 unsigned get_num_reachable_nodes(ir_graph *irg);
123 * Sets all node inputs to BAD node.
124 * @param irn The node to be killed.
126 void be_kill_node(ir_node *irn);
129 * Search for an irn in @p accept.
130 * The search is started at @p start_point_exclusive and continues upwards the dom-tree
131 * @return The first node out of accept if found. Else NULL is returned.
133 ir_node *dom_up_search(pset *accept, ir_node *start_point_exclusive);
135 #endif /* _BEUTIL_H */