/* ==================================================================== * * TI_RES_Can_Dual_Issue * * See interface description * * ==================================================================== */ BOOL TI_RES_Can_Dual_Issue( TOP opcode1, TOP opcode2 ) { INT min_length, i; SI_RR rr1, rr2; /* Quick check to see if we could ever dual issue something. */ if (!PROC_has_same_cycle_branch_shadow()) return FALSE; /* Resource requirements for each. */ rr1 = TSI_Resource_Requirement(opcode1); rr2 = TSI_Resource_Requirement(opcode2); /* We only have to check up to the end of the shorter of the two resource * requests. */ if ( SI_RR_Length(rr1) < SI_RR_Length(rr2) ) min_length = SI_RR_Length(rr1); else min_length = SI_RR_Length(rr2); /* Check each cycle. */ for ( i = 0; i < min_length; ++i ) { SI_RRW rrw = SI_RRW_Initial(); rrw = SI_RRW_Reserve(rrw,SI_RR_Cycle_RRW(rr1,i)); rrw = SI_RRW_Reserve(rrw,SI_RR_Cycle_RRW(rr2,i)); if ( SI_RRW_Has_Overuse(rrw) ) return FALSE; } return TRUE; }
/* ==================================================================== * * TI_RES_RES_Set_BB_Cycle_Count * * See interface description * * ==================================================================== */ void TI_RES_RES_Set_BB_Cycle_Count( TI_RES_RES *res, INT length ) { INT i; BOOL cyclic = TI_RES_RES_cyclic(res); if ( length > TI_RES_RES_alloc_size(res) ) { INT new_alloc_size = length * 2; TI_RES_RES_alloc_size(res) = new_alloc_size; TI_RES_RES_rrtab(res) = TYPE_MEM_POOL_ALLOC_N(SI_RRW, TI_RES_RES_pool(res), new_alloc_size); if ( cyclic ) { TI_RES_RES_uncommon_res_ids(res) = TYPE_MEM_POOL_ALLOC_N(SI_RESOURCE_ID_SET, TI_RES_RES_pool(res), new_alloc_size); } } TI_RES_RES_length(res) = length; /* Initialize the part of the table we will use */ for ( i = 0; i < length; ++i ) { TI_RES_RES_rrtab(res)[i] = SI_RRW_Initial(); } if ( cyclic ) { INT id; BS *si_ids = TI_RES_RES_si_ids(res); SI_RESOURCE_ID_SET *uncommon_res_ids = TI_RES_RES_uncommon_res_ids(res); INT common_length = MIN(TI_RES_RES_min_rr_length(res), length); /* For each cycle, compute the set of resources that not all the OPs in * the loop use in that cycle. We do this by computing its complement -- * the set of resources that all the OPs use in the cycle -- and then * complementing it in place. */ /* Compute common resources into "uncommon_res_ids" * * NOTE: the following loop also initializes the "res_ids" * from common_length to the end of the vector. These * are by definition not common to all OPs, and we will leave * the setting unchanged in the following loops. */ for ( i = 0; i < length; ++i ) { uncommon_res_ids[i] = SI_RESOURCE_ID_SET_Universe(); } for ( id = BS_Choose(si_ids); id != BS_CHOOSE_FAILURE; id = BS_Choose_Next(si_ids,id) ) { const SI_RESOURCE_ID_SET* resource_ids_used = SI_ID_II_Cycle_Resource_Ids_Used(id,length); for ( i = 0; i < common_length; ++i ) { uncommon_res_ids[i] = SI_RESOURCE_ID_SET_Intersection(uncommon_res_ids[i], resource_ids_used[i]); } } /* Complement in place */ for ( i = 0; i < common_length; ++i ) { uncommon_res_ids[i] = SI_RESOURCE_ID_SET_Complement(uncommon_res_ids[i]); } } }