#include "set.h"
#include "debug.h"
+/* define this for gneral block shaping (buggy yet) */
+#undef GENERAL_SHAPE
+
typedef struct partition_t partition_t;
typedef struct block_t block_t;
typedef struct node_t node_t;
set_irn_in(p, j, &phi_ins[k * n]);
}
}
+ DEL_ARR_F(phi_ins);
/* fix inputs of the meet block */
set_irn_in(meet_block, j, ins);
DEL_ARR_F(ins);
} /* apply */
-/**
- * Create a partition for a given meet block.
- *
- * @param block the meet block
- * @param preds array of candidate predecessors
- * @param n_preds number of elements in preds
- * @param env the environment
- */
-static void partition_for_block(ir_node *block, ir_node *preds[], int n_preds, environment_t *env) {
- partition_t *part = create_partition(block, env);
- int i;
-
- for (i = n_preds - 1; i >= 0; --i) {
- ir_node *pred = preds[i];
- ir_node *block;
- block_t *bl;
- node_t *node;
-
- mark_irn_visited(pred);
-
- block = get_nodes_block(pred);
- bl = create_block(block, part, env);
- node = create_node(pred, bl, env);
-
- bl->cf_root = node;
- }
-
- dump_partition("Created", part);
-} /* partition_for_block */
-
-
/**
* Create a partition for a the end block.
*
dump_partition("Created", part);
} /* partition_for_end_block */
+#ifdef GENERAL_SHAPE
+/**
+ * Create a partition for a given meet block.
+ *
+ * @param block the meet block
+ * @param preds array of candidate predecessors
+ * @param n_preds number of elements in preds
+ * @param env the environment
+ */
+static void partition_for_block(ir_node *block, ir_node *preds[], int n_preds, environment_t *env) {
+ partition_t *part = create_partition(block, env);
+ int i;
+
+ for (i = n_preds - 1; i >= 0; --i) {
+ ir_node *pred = preds[i];
+ ir_node *block;
+ block_t *bl;
+ node_t *node;
+
+ mark_irn_visited(pred);
+
+ block = get_nodes_block(pred);
+ bl = create_block(block, part, env);
+ node = create_node(pred, bl, env);
+
+ bl->cf_root = node;
+ }
+
+ dump_partition("Created", part);
+} /* partition_for_block */
+
/**
* Walker: clear the links of all block phi lists and normal
* links.
*/
static void clear_phi_links(ir_node *irn, void *env) {
+ (void) env;
if (is_Block(irn)) {
set_Block_phis(irn, NULL);
set_irn_link(irn, NULL);
* Compare two nodes for root ordering.
*/
static int cmp_nodes(const void *a, const void *b) {
- const ir_node *irn_a = a;
- const ir_node *irn_b = b;
- ir_opcode code_a = get_irn_opcode(irn_a);
- ir_opcode code_b = get_irn_opcode(irn_b);
- ir_mode *mode_a, *mode_b;
- unsigned idx_a, idx_b;
+ ir_node *const *pa = a;
+ ir_node *const *pb = b;
+ const ir_node *irn_a = *pa;
+ const ir_node *irn_b = *pb;
+ ir_opcode code_a = get_irn_opcode(irn_a);
+ ir_opcode code_b = get_irn_opcode(irn_b);
+ ir_mode *mode_a, *mode_b;
+ unsigned idx_a, idx_b;
/* try opcode first */
if (code_a != code_b)
bl->roots = NULL;
}
} /* add_roots */
+#endif /* GENERAL_SHAPE */
/* Combines congruent end blocks into one. */
int shape_blocks(ir_graph *irg) {
/* register a debug mask */
FIRM_DBG_REGISTER(dbg, "firm.opt.blocks");
- firm_dbg_set_mask(dbg, 7);
DEBUG_ONLY(part_nr = 0);
DB((dbg, LEVEL_1, "Shaping blocks for %+F\n", irg));
ir_reserve_resources(irg, IR_RESOURCE_IRN_LINK | IR_RESOURCE_PHI_LIST);
+#ifdef GENERAL_SHAPE
/*
* Detect, which nodes are live-out only: these are the roots of our blocks.
* Build phi lists.
*/
irg_walk_graph(irg, clear_phi_links, find_liveouts, &env);
+#endif
ir_reserve_resources(irg, IR_RESOURCE_IRN_VISITED);
inc_irg_visited(irg);
+#ifdef GENERAL_SHAPE
/*
* Detect all control flow meets and create partitions.
*/
/* add root nodes to the partition blocks */
add_roots(irg, &env);
+#else
+ partition_for_end_block(get_irg_end_block(irg), &env);
+#endif
while (! list_empty(&env.partitions))
propagate(&env);
set_trouts_inconsistent();
}
+ DEL_ARR_F(env.live_outs);
del_set(env.opcode2id_map);
obstack_free(&env.obst, NULL);
current_ir_graph = rem;