void Planner::plan() {
DEBUG("Planning\n");
e->get_scheduler()->reset();
-
+
if (!cgen->canReuseEncoding()) {
processChanges();
cgen->reset();
}
void Planner::processChanges() {
- ChangeIterator *cit=changeset->iterator();
- for(;cit->hasNext();) {
- MCChange *change=cit->next();
- cit->remove();
+ while(!changeset->isEmpty()) {
+ MCChange *change=changeset->getFirstKey();
+ if (change==NULL)
+ break;
+ changeset->remove(change);
if (completedset->contains(change)) {
delete change;
continue;
} else ASSERT(false);
completedset->add(change);
}
- delete cit;
- for(cit=completedset->iterator();cit->hasNext();) {
+ ChangeIterator *cit=completedset->iterator();
+
+ for(;cit->hasNext();) {
MCChange *change=cit->next();
cit->remove();
delete change;
}
/** This function propagate news values that a function or add
- operation may generate.
-*/
+ operation may generate.
+ */
void Planner::processNewReturnValue(MCChange *change) {
EPRecord *record=change->getRecord();
}
/** This function registers a new address for a load operation. We
- iterate over all stores to that new address and grab their values
- and propagate them.
-*/
+ iterate over all stores to that new address and grab their values
+ and propagate them.
+ */
void Planner::processNewLoadAddress(MCChange *change) {
EPRecord *load=change->getRecord();
void *addr=(void *)change->getValue();
RecordSet *storeset=e->getStoreTable(addr);
- if (storeset == NULL)
+ if (storeset == NULL)
return;
RecordIterator *rit=storeset->iterator();
while(rit->hasNext()) {
}
/** This function processes a new address for a store. We push our
- values to all loads from that address. */
+ values to all loads from that address. */
void Planner::processNewStoreAddress(MCChange *change) {
EPRecord *store=change->getRecord();
void *addr=(void *)change->getValue();
RecordSet *rset=e->getLoadTable(addr);
- if (rset == NULL)
+ if (rset == NULL)
return;
RecordIterator *rit=rset->iterator();
IntHashSet *valset=store->getStoreSet();
/** This function pushes a new store value to all loads that share an
- address. */
+ address. */
void Planner::processNewStoreValue(MCChange *change) {
EPRecord *store=change->getRecord();
void Planner::registerLoadValue(EPRecord *record, uint64_t val, unsigned int index) {
if (index==VC_ADDRINDEX)
val+=record->getOffset();
-
+
bool is_new=record->getSet(index)->add(val);
if (is_new) {
switch(index) {
//propagate our value to new loads
MCChange * change=new MCChange(record, val, VC_ADDRINDEX);
addChange(change);
-
+
//look at new stores and update our read from set
RecordSet *storeset=e->getStoreTable((void *)val);
RecordIterator *rit=storeset->iterator();
while(rit->hasNext()) {
EPRecord *store=rit->next();
-
+
if (e->compatibleStoreLoad(store, record)) {
IntIterator * it=store->getStoreSet()->iterator();
while(it->hasNext()) {
val+=record->getOffset();
bool is_new=record->getSet(index)->add(val);
-
+
if (index==VC_ADDRINDEX) {
if (is_new)
- e->addStoreTable((void *)val, record);
+ e->addStoreTable((void *)val, record);
MCChange * change=new MCChange(record, val, index);
addChange(change);
} else if (index==VC_BASEINDEX) {