cloud9_root/src/cloud9/lib/Core/CacheSideChannel.cpp
// generate set equality constraints for <symbolic,constant> address pairs
generate set equality constraints for  address pairs
generate set equality constraints for address pairs
ref<Expr> CacheChannel::generateSetCnstrSC(ref<Expr>& addressI, ref<Expr>& addressJ) {
	int set;
	ref<Expr> setAddr;
	pairT setPair(addressI, addressJ);
	atomicCnstr++;
	{
		if (setPairCache.count(setPair)) {
#ifdef _CACHE_CHANNEL_DEBUG
			fprintf(stdout, "cached result found.....\n");
			fflush(stdout);
#endif
			return setPairCache[setPair];
		}
	}
	if (addressI->getKind() == Expr::Constant) {
		ConstantExpr* CE = dyn_cast < ConstantExpr > (addressI);
		uint64_t addrRaw = CE->getZExtValue();
		set = CACHE_SET(addrRaw, nset, line);
		if (setCache.count(addressJ)) setAddr = setCache[addressJ];
		else { 
			ref<Expr> blAddr = LShrExpr::create(addressJ, ConstantExpr::alloc(log_base2(line), addressJ->getWidth()));
			setAddr = AndExpr::create(blAddr, ConstantExpr::alloc(nset - 1, addressJ->getWidth()));
			setCache[addressJ] = setAddr;
		}
	} else {
		ConstantExpr* CE = dyn_cast < ConstantExpr > (addressJ);
		uint64_t addrRaw = CE->getZExtValue();
		set = CACHE_SET(addrRaw, nset, line);
		if (setCache.count(addressI)) setAddr = setCache[addressI];
		else { 
			ref<Expr> blAddr = LShrExpr::create(addressI, ConstantExpr::alloc(log_base2(line), addressI->getWidth()));
			setAddr = AndExpr::create(blAddr, ConstantExpr::alloc(nset - 1, addressI->getWidth()));
			setCache[addressI] = setAddr;
		}
	}
	setPairCache[setPair] = EqExpr::create(setAddr, ConstantExpr::alloc(set, setAddr->getWidth()));
	return setPairCache[setPair];
}
ref < Expr > CacheChannel :: generateSetCnstrSC ( ref < Expr > & addressI , ref < Expr > & addressJ ) { int set ; ref < Expr > setAddr ; pairT setPair ( addressI , addressJ ) ; atomicCnstr ++ ; { if ( setPairCache . count ( setPair ) ) { #ifdef _CACHE_CHANNEL_DEBUG fprintf ( stdout , " \n " ) ; fflush ( stdout ) ; #endif return setPairCache [ setPair ] ; } } if ( addressI -> getKind ( ) == Expr :: Constant ) { ConstantExpr * CE = dyn_cast < ConstantExpr > ( addressI ) ; uint64_t addrRaw = CE -> getZExtValue ( ) ; set = CACHE_SET ( addrRaw , nset , line ) ; if ( setCache . count ( addressJ ) ) setAddr = setCache [ addressJ ] ; else { ref < Expr > blAddr = LShrExpr :: create ( addressJ , ConstantExpr :: alloc ( log_base2 ( line ) , addressJ -> getWidth ( ) ) ) ; setAddr = AndExpr :: create ( blAddr , ConstantExpr :: alloc ( nset - 1 , addressJ -> getWidth ( ) ) ) ; setCache [ addressJ ] = setAddr ; } } else { ConstantExpr * CE = dyn_cast < ConstantExpr > ( addressJ ) ; uint64_t addrRaw = CE -> getZExtValue ( ) ; set = CACHE_SET ( addrRaw , nset , line ) ; if ( setCache . count ( addressI ) ) setAddr = setCache [ addressI ] ; else { ref < Expr > blAddr = LShrExpr :: create ( addressI , ConstantExpr :: alloc ( log_base2 ( line ) , addressI -> getWidth ( ) ) ) ; setAddr = AndExpr :: create ( blAddr , ConstantExpr :: alloc ( nset - 1 , addressI -> getWidth ( ) ) ) ; setCache [ addressI ] = setAddr ; } } setPairCache [ setPair ] = EqExpr :: create ( setAddr , ConstantExpr :: alloc ( set , setAddr -> getWidth ( ) ) ) ; return setPairCache [ setPair ] ; }
generate set equality constraints for <symbolic,constant> address pairs
generate set equality constraints for <symbolic constant > address pairs
/* optimization to reduce memory consumption */ /* end optimization branch */ /* otherwise allocate new memory */ /* for optimizing memory consumption */ /* allocate new memory and store in the cache */ /* for optimizing memory consumption */ /* allocate new memory and store in the cache */