Exemple #1
0
/**
 * The random selector:
 * Just assure that branches are executed last, otherwise select a random node
 */
static ir_node *random_select(void *block_env, ir_nodeset_t *ready_set)
{
	int only_branches_left = 1;
	(void)block_env;

	/* assure that branches and constants are executed last */
	foreach_ir_nodeset(ready_set, irn, iter) {
		if (!is_cfop(irn)) {
			only_branches_left = 0;
			break;
		}
	}

	ir_node *rand_node = NULL;
	if (only_branches_left) {
		/* at last: schedule branches */
		rand_node = ir_nodeset_first(ready_set);
	} else {
		do {
			/* take 1 random node */
			int n = rand() % ir_nodeset_size(ready_set);
			int i = 0;
			foreach_ir_nodeset(ready_set, irn, iter) {
				rand_node = irn;
				if (i == n) {
					break;
				}
				++i;
			}
		} while (is_cfop(rand_node));
	}

	return rand_node;
}
Exemple #2
0
/* Walks back from n until it finds a real cf op. */
static ir_node *get_cf_op(ir_node *n)
{
	while (!is_cfop(n) && !is_fragile_op(n) && !is_Bad(n)) {
		n = skip_Tuple(n);
		n = skip_Proj(n);
	}
	return n;
}