예제 #1
0
파일: ir_bb.cpp 프로젝트: alibaba/xoc
//Check that all basic blocks should only end with terminator IR.
void IRBB::verify()
{
    UINT c = 0;
    C<IR*> * ct;
    for (IR * ir = BB_irlist(this).get_head(&ct);
         ir != NULL; ir = BB_irlist(this).get_next(&ct)) {
        ASSERT0(ir->is_single());
        ASSERT0(ir->get_bb() == this);
        switch (IR_code(ir)) {
        case IR_ST:
        case IR_STPR:
        case IR_STARRAY:
        case IR_IST:
        case IR_PHI:
        case IR_REGION:
        case IR_CALL:
        case IR_ICALL:
        case IR_GOTO:
        case IR_IGOTO:
        case IR_TRUEBR:
        case IR_FALSEBR:
        case IR_RETURN:
        case IR_SWITCH:
            break;
        default: ASSERT(0, ("BB does not supported this kind of IR."));
        }

        if (is_bb_down_boundary(ir)) {
            ASSERT(ir == BB_last_ir(this), ("invalid BB down boundary."));
        }

        c++;
    }
    ASSERT0(c == getNumOfIR());
}
예제 #2
0
void IRBB::dump(Region * ru, bool dump_inner_region)
{
    if (g_tfile == NULL) {
        return;
    }

    note("\n----- BB%d ------", BB_id(this));
    if (getLabelList().get_elem_count() > 0) {
        note("\nLABEL:");
        dumpBBLabel(getLabelList(), g_tfile);
    }

    //Attributes
    note("\nATTR:");
    if (BB_is_entry(this)) {
        fprintf(g_tfile, "entry_bb ");
    }

    //if (BB_is_exit(this)) {
    //    fprintf(g_tfile, "exit_bb ");
    //}

    if (BB_is_fallthrough(this)) {
        fprintf(g_tfile, "fall_through ");
    }

    if (BB_is_target(this)) {
        fprintf(g_tfile, "branch_target ");
    }

    //IR list
    note("\nSTMT NUM:%d", getNumOfIR());
    g_indent += 3;
    TypeMgr * dm = ru->get_type_mgr();
    for (IR * ir = BB_first_ir(this);
            ir != NULL; ir = BB_irlist(this).get_next()) {
        ASSERT0(ir->is_single() && ir->get_bb() == this);
        dump_ir(ir, dm, NULL, true, true, false, dump_inner_region);
    }
    g_indent -= 3;
    fprintf(g_tfile, "\n");
    fflush(g_tfile);
}