cloud9_root/src/cloud9/lib/Core/CacheSideChannel.cpp
/**
 * generate constraints to formulate reloading of memory blocks
 * reload constraints need to be modified for the FIFO replacement policy
 */
generate constraints to formulate reloading of memory blocks
reload constraints need to be modified for the FIFO replacement policy
generate constraints to formulate reloading of memory blocks reload constraints need to be modified for the FIFO replacement policy
ref<Expr> CacheChannel::generateCnstrForInterReload(ExecutionState& state, int hStart, int hEnd, int target, bool& reload) {
	if (hStart > hEnd) {
		return NULL;
	}
	ref<Expr> addrTarget = state.memAddrs[target];
	bool set, tag;
	ref<Expr> addrStart = state.memAddrs[hStart];
	ref<Expr> notSetCnstr;
	ref<Expr> tagCnstr;
	ref<Expr> fifoCnstr = NULL;
	if (addrTarget->getKind() == Expr::Constant) {
		if (addrStart->getKind() == Expr::Constant) {
			set = generateSetCnstrCC(addrTarget, addrStart);
			tag = generateTagCnstrCC(addrTarget, addrStart);
			if (set && !tag) {
				if (nassoc == 1) reload = true;
				else if (strncasecmp(policy, "l", 1) == 0) reload = true;
				else if (strncasecmp(policy, "f", 1) == 0) {
					if (missConstraintLog.count(hStart) && missConstraintLog[hStart].first.isNull()) reload = true;
					else if (missConstraintLog.count(hStart)) {
						fifoCnstr = missConstraintLog[hStart].first;
					} else {
					}
				} else
				assert(0 && "fatal: cache replacement policy is not supported");
			}
			return fifoCnstr;
		} else {
			ref<Expr> setCnstr = generateSetCnstrSC(addrTarget, addrStart);
			notSetCnstr = NotExpr::create(setCnstr);
			tagCnstr = generateTagCnstrSC(addrTarget, addrStart);
		}
	} else {
		if (addrStart->getKind() == Expr::Constant) {
			ref<Expr> setCnstr = generateSetCnstrSC(addrTarget, addrStart);
			notSetCnstr = NotExpr::create(setCnstr);
			tagCnstr = generateTagCnstrSC(addrTarget, addrStart);
		} else {
			ref<Expr> setCnstr = generateSetCnstrSS(addrTarget, addrStart);
			notSetCnstr = NotExpr::create(setCnstr);
			tagCnstr = generateTagCnstrSS(addrTarget, addrStart);
		}
	}
	ref<Expr> retExpr = OrExpr::create(notSetCnstr, tagCnstr);
	if (nassoc > 1 && strncasecmp(policy, "f", 1) == 0) {
		if (!missConstraintLog.count(hStart)) {
			return NULL;
		} else if (!missConstraintLog[hStart].first.isNull()) {
			retExpr = OrExpr::create(retExpr, missConstraintLog[hStart].first);
		}
	}
	return retExpr;
}
ref < Expr > CacheChannel :: generateCnstrForInterReload ( ExecutionState & state , int hStart , int hEnd , int target , bool & reload ) { if ( hStart > hEnd ) { return NULL ; } ref < Expr > addrTarget = state . memAddrs [ target ] ; bool set , tag ; ref < Expr > addrStart = state . memAddrs [ hStart ] ; ref < Expr > notSetCnstr ; ref < Expr > tagCnstr ; ref < Expr > fifoCnstr = NULL ; if ( addrTarget -> getKind ( ) == Expr :: Constant ) { if ( addrStart -> getKind ( ) == Expr :: Constant ) { set = generateSetCnstrCC ( addrTarget , addrStart ) ; tag = generateTagCnstrCC ( addrTarget , addrStart ) ; if ( set && ! tag ) { if ( nassoc == 1 ) reload = true ; else if ( strncasecmp ( policy , " " , 1 ) == 0 ) reload = true ; else if ( strncasecmp ( policy , " " , 1 ) == 0 ) { if ( missConstraintLog . count ( hStart ) && missConstraintLog [ hStart ] . first . isNull ( ) ) reload = true ; else if ( missConstraintLog . count ( hStart ) ) { fifoCnstr = missConstraintLog [ hStart ] . first ; } else { } } else assert ( 0 && " " ) ; } return fifoCnstr ; } else { ref < Expr > setCnstr = generateSetCnstrSC ( addrTarget , addrStart ) ; notSetCnstr = NotExpr :: create ( setCnstr ) ; tagCnstr = generateTagCnstrSC ( addrTarget , addrStart ) ; } } else { if ( addrStart -> getKind ( ) == Expr :: Constant ) { ref < Expr > setCnstr = generateSetCnstrSC ( addrTarget , addrStart ) ; notSetCnstr = NotExpr :: create ( setCnstr ) ; tagCnstr = generateTagCnstrSC ( addrTarget , addrStart ) ; } else { ref < Expr > setCnstr = generateSetCnstrSS ( addrTarget , addrStart ) ; notSetCnstr = NotExpr :: create ( setCnstr ) ; tagCnstr = generateTagCnstrSS ( addrTarget , addrStart ) ; } } ref < Expr > retExpr = OrExpr :: create ( notSetCnstr , tagCnstr ) ; if ( nassoc > 1 && strncasecmp ( policy , " " , 1 ) == 0 ) { if ( ! missConstraintLog . count ( hStart ) ) { return NULL ; } else if ( ! missConstraintLog [ hStart ] . first . isNull ( ) ) { retExpr = OrExpr :: create ( retExpr , missConstraintLog [ hStart ] . first ) ; } } return retExpr ; }
generate constraints to formulate reloading of memory blocks
 reload constraints need to be modified for the FIFO replacement policy
generate constraints to formulate reloading of memory blocks reload constraints need to be modified for the FIFO replacement policy
/* memory block might be reloaded */ /* direct-mapped policy */ /* LRU policy */ /* FIFO policy */ /* the intermediate access is a cache miss */ /* do nothing */ /* sudiptac: for FIFO replacement policy */ /* end processing FIFO replacement policy */