Esempio n. 1
0
/*
 *	FRPize a superblock using the if-converter
 */
void El_frpize_sbs(Procedure *f)
{
    Basicblock *entry_bb;
    Hyperblock *hb;
    List_set<Basicblock*> hb_bbs;
    Hash_set<Hyperblock*> all_hbs;
    bool push_flag, applied;
    Dlist<Region*> rstack;
    Region *rtmp;
    Compound_region *new_hb;

    if (dbg(cpr, 2))
        cdbg << "Enter frpize sbs" << endl;

    // First find all the HBs in f and add them to set all_hbs
    rstack.push(f);
    while (! rstack.is_empty()) {
        rtmp = rstack.pop();
        push_flag = true;
        if (rtmp->is_hb()) {
	    all_hbs += ((Hyperblock *) rtmp);
            push_flag = false;  // Only ops below, so don't waste time!
        }
        else if (rtmp->is_bb()) {
            push_flag = false;  // Only ops below, so don't waste time!
        }
        if (push_flag==true) {
            for (Region_subregions subri(rtmp); subri!=0; subri++) {
                if ((*subri)->is_compound())
                    rstack.push(*subri);
            }
        }
    }

    // Now walk thru hash_set and frpize it
    applied = false;
    for (Hash_set_iterator<Hyperblock*> hseti(all_hbs); hseti!=0; hseti++) {
	hb = *hseti;
	if (dbg(cpr, 2))
	    cdbg << "Processing HB " << hb->id() << endl;
	if (! El_is_frpizable(hb)) {
	    if (dbg(cpr, 2))
		cdbg << "\tHB " << hb->id() << " not frpizable" << endl;
	    continue;
	}
	hb_bbs.clear();
	El_find_bbs_in_hb(hb, &entry_bb, hb_bbs);
	El_remove_region(hb, false);
	El_fprize_this_sb(f, entry_bb, hb_bbs);
	new_hb = entry_bb->parent();
	if (! new_hb->is_hb())
	   El_punt("El_frpize_sbs: HB not correctly inserted");
	// Copy over id/flags/lcode_attrs from hb to new_hb
	new_hb->set_id(hb->id());
	delete new_hb->attributes;
	new_hb->attributes = new Graph_attribute(*(hb->attributes)) ;
	((Region *)new_hb)->copy_flags(hb);
	// 1 of the flags will be the SB flag, so reset that one
	new_hb->reset_flag(EL_REGION_SUPERBLOCK);
	new_hb->set_flag(EL_REGION_HYPERBLOCK_FRP);
	applied = true;
	delete hb;
    }

    if (applied == true)
	f->set_flag(EL_PROC_HYPERBLOCK);
}