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);
22 /** Undefine this to disable debugging mode. */
26 * Convenient block getter.
27 * Works also, if the given node is a block.
28 * @param irn The node.
29 * @return The block of the node, or the node itself, if the node is a
32 static INLINE const ir_node *get_block(const ir_node *irn)
34 return is_Block(irn) ? irn : get_nodes_block(irn);
37 static INLINE int is_firm_be_mode(const ir_mode *mode)
39 return mode_is_data(mode);
43 * Check, if a node produces or consumes a data value.
44 * If it does, it is significant for scheduling and register allocation.
45 * A node produces/consumes a data value, if one of its operands is of
46 * mode datab, or his retuning mode is of mode datab.
47 * @param irn The node to check for.
48 * @return 1, if the node is a data node, 0 if not.
50 static INLINE int is_data_node(const ir_node *irn)
54 /* If the node produces a data value, return immediately. */
55 if(is_firm_be_mode(get_irn_mode(irn)))
58 /* else check, if it takes a data value, if that is so, return */
59 for(i = 0, n = get_irn_arity(irn); i < n; ++i) {
60 ir_node *op = get_irn_n(irn, i);
61 if(is_firm_be_mode(get_irn_mode(op)))
65 /* Else the node does not produce/consume a data value */
70 * Dump a vcg graph containing the controlflow graph, the schedule and
71 * allocated registers.
72 * @param irg The irg. Note that scheduling, register allocation must
73 * have been performed.
75 void dump_allocated_irg(arch_env_t *env, ir_graph *irg, char *suffix);
77 void be_clear_links(ir_graph *irg);
79 static INLINE FILE *ffopen(const char *base, const char *ext, const char *mode) {
83 snprintf(buf, sizeof(buf), "%s.%s", base, ext);
84 buf[sizeof(buf) - 1] = '\0';
85 if (! (out = fopen(buf, mode))) {
86 fprintf(stderr, "Cannot open file %s in mode %s\n", buf, mode);
93 * Dump a graph with schedule edges.
94 * @param irg The graph.
95 * @param suffix A suffix to its file name.
97 void dump_ir_block_graph_sched(ir_graph *irg, const char *suffix);
100 * Dump a extended block graph with schedule edges.
101 * @param irg The graph.
102 * @param suffix A suffix to its file name.
104 void dump_ir_extblock_graph_sched(ir_graph *irg, const char *suffix);
107 * Dumps a graph and numbers all dumps.
108 * @param irg The graph
109 * @param suffix A suffix to its file name.
110 * @param dumper The dump function
112 void be_dump(ir_graph *irg, const char *suffix, void (*dumper)(ir_graph *, const char *));
115 * Returns the number of reachable nodes in an irg.
116 * @param irg The irg.
117 * @return The number of reachable nodes.
119 unsigned get_num_reachable_nodes(ir_graph *irg);
122 * Sets all node inputs to BAD node.
123 * @param irn The node to be killed.
125 void be_kill_node(ir_node *irn);
128 * Search for an irn in @p accept.
129 * The search is started at @p start_point_exclusive and continues upwards the dom-tree
130 * @return The first node out of accept if found. Else NULL is returned.
132 ir_node *dom_up_search(pset *accept, ir_node *start_point_exclusive);
135 * Gets the Proj with number pn from irn.
137 ir_node *be_get_Proj_for_pn(const ir_node *irn, long pn);
139 #endif /* _BEUTIL_H */