Beispiel #1
0
void CFS_MGR::dump_abs_tree(ABS_NODE * an, UINT indent)
{
	while (an != NULL) {
		switch (ABS_NODE_type(an)) {
		case ABS_BB:
			fprintf(g_tfile, "\n"); dump_indent(indent);
			fprintf(g_tfile, "BB%d", IR_BB_id(ABS_NODE_bb(an)));
			break;
		case ABS_LOOP:
			fprintf(g_tfile, "\n"); dump_indent(indent);
			fprintf(g_tfile, "LOOP: HEAD=BB%d", IR_BB_id(ABS_NODE_loop_head(an)));
			dump_abs_tree(ABS_NODE_loop_body(an), indent + 4);
			break;
		case ABS_IF:
			fprintf(g_tfile, "\n"); dump_indent(indent);
			fprintf(g_tfile, "IF: HEAD=BB%d", IR_BB_id(ABS_NODE_if_head(an)));
			if (ABS_NODE_true_body(an) != NULL) {
				fprintf(g_tfile, "\n"); dump_indent(indent);
				fprintf(g_tfile, "TRUE_BODY:");
				dump_abs_tree(ABS_NODE_true_body(an), indent + 4);
			}
			if (ABS_NODE_false_body(an) != NULL) {
				fprintf(g_tfile, "\n"); dump_indent(indent);
				fprintf(g_tfile, "FALSE_BODY:");
				dump_abs_tree(ABS_NODE_false_body(an), indent + 4);
			}
			break;
		}
		an = ABS_NODE_next(an);
	}
}
Beispiel #2
0
ABS_NODE * CFS_MGR::construct_abs_loop(
						IN IR_BB * entry,
						IN ABS_NODE * parent,
						IN BITSET * cur_region,
						IN GRAPH & cur_graph,
						IN OUT BITSET & visited)
{
	IS_TRUE0(cur_region == NULL || cur_region->is_contain(IR_BB_id(entry)));
	IR_CFG * cfg = m_ru->get_cfg();
	LI<IR_BB> * li = cfg->map_bb2li(entry);
	IS_TRUE0(li != NULL && LI_loop_head(li) == entry);

	ABS_NODE * node = new_abs_node(ABS_LOOP);
	set_map_bb2abs(entry, node);
	ABS_NODE_parent(node) = parent;
	ABS_NODE_loop_head(node) = entry;
	IR_BB * body_start;
	cfg->get_loop_two_kids(entry, NULL, &body_start);
	IS_TRUE0(body_start != NULL);

	CFS_INFO * ci = map_ir2cfsinfo(cfg->get_last_xr(entry));
	IS_TRUE0(ci != NULL && CFS_INFO_head(ci) == entry);

	IS_TRUE0(CFS_INFO_loop_body(ci)->is_contain(*LI_bb_set(li)));
	BITSET loc_visited;
	ABS_NODE_loop_body(node) = construct_abs_tree(body_start, node,
												  LI_bb_set(li),
												  cur_graph, loc_visited);
	visited.bunion(loc_visited);
	visited.bunion(IR_BB_id(entry));
	return node;
}
Beispiel #3
0
AbsNode * CfsMgr::constructAbsLoop(
        IN IRBB * entry,
        IN AbsNode * parent,
        IN BitSet * cur_region,
        IN Graph & cur_graph,
        IN OUT BitSet & visited)
{
    DUMMYUSE(cur_region);
    ASSERT0(cur_region == NULL || cur_region->is_contain(BB_id(entry)));
    IR_CFG * cfg = m_ru->getCFG();
    LI<IRBB> * li = cfg->mapBB2LabelInfo(entry);
    ASSERT0(li != NULL && LI_loop_head(li) == entry);

    AbsNode * node = new_abs_node(ABS_LOOP);
    set_map_bb2abs(entry, node);
    ABS_NODE_parent(node) = parent;
    ABS_NODE_loop_head(node) = entry;
    IRBB * body_start;
    cfg->getKidOfLoop(entry, NULL, &body_start);
    ASSERT0(body_start != NULL);

    CFS_INFO * ci = map_ir2cfsinfo(cfg->get_last_xr(entry));
    CHECK_DUMMYUSE(ci);
    ASSERT0(CFS_INFO_head(ci) == entry);

    ASSERT0(CFS_INFO_loop_body(ci)->is_contain(*LI_bb_set(li)));
    BitSet loc_visited;
    ABS_NODE_loop_body(node) = constructAbsTree(body_start, node,
        LI_bb_set(li), cur_graph, loc_visited);
    visited.bunion(loc_visited);
    visited.bunion(BB_id(entry));
    return node;
}