cloud9_root/src/cloud9/lib/Core/CacheSideChannel.cpp
// generate tag inequality constraints for <symbolic,constant> address pairs
generate tag inequality constraints for  address pairs
generate tag inequality constraints for address pairs
ref<Expr> CacheChannel::generateTagCnstrSC(ref<Expr>& addressI, ref<Expr>& addressJ) {
	int tag;
	ref<Expr> tagAddr;
	pairT tagPair(addressI, addressJ);
	atomicCnstr++;
	{
		if (tagPairCache.count(tagPair)) {
#ifdef _CACHE_CHANNEL_DEBUG
			fprintf(stdout, "cached result found.....\n");
			fflush(stdout);
#endif
			return tagPairCache[tagPair];
		}
	}
	if (addressI->getKind() == Expr::Constant) {
		ConstantExpr* CE = dyn_cast < ConstantExpr > (addressI);
		uint64_t addrRaw = CE->getZExtValue();
		tag = CACHE_TAG(addrRaw, nset, line);
		if (tagCache.count(addressJ)) tagAddr = tagCache[addressJ];
		else { 
			tagAddr = LShrExpr::create(addressJ, ConstantExpr::alloc(log_base2(line) + log_base2(nset), addressJ->getWidth()));
			tagCache[addressJ] = tagAddr;
		}
	} else {
		ConstantExpr* CE = dyn_cast < ConstantExpr > (addressJ);
		uint64_t addrRaw = CE->getZExtValue();
		tag = CACHE_TAG(addrRaw, nset, line);
		if (tagCache.count(addressI)) tagAddr = tagCache[addressI];
		else { 
			tagAddr = LShrExpr::create(addressI, ConstantExpr::alloc(log_base2(line) + log_base2(nset), addressI->getWidth()));
			tagCache[addressI] = tagAddr;
		}
	}
	ref<Expr> eqExpr = EqExpr::create(tagAddr, ConstantExpr::alloc(tag, tagAddr->getWidth()));
	tagPairCache[tagPair] = NotExpr::create(eqExpr);
	return tagPairCache[tagPair];
}
ref < Expr > CacheChannel :: generateTagCnstrSC ( ref < Expr > & addressI , ref < Expr > & addressJ ) { int tag ; ref < Expr > tagAddr ; pairT tagPair ( addressI , addressJ ) ; atomicCnstr ++ ; { if ( tagPairCache . count ( tagPair ) ) { #ifdef _CACHE_CHANNEL_DEBUG fprintf ( stdout , " \n " ) ; fflush ( stdout ) ; #endif return tagPairCache [ tagPair ] ; } } if ( addressI -> getKind ( ) == Expr :: Constant ) { ConstantExpr * CE = dyn_cast < ConstantExpr > ( addressI ) ; uint64_t addrRaw = CE -> getZExtValue ( ) ; tag = CACHE_TAG ( addrRaw , nset , line ) ; if ( tagCache . count ( addressJ ) ) tagAddr = tagCache [ addressJ ] ; else { tagAddr = LShrExpr :: create ( addressJ , ConstantExpr :: alloc ( log_base2 ( line ) + log_base2 ( nset ) , addressJ -> getWidth ( ) ) ) ; tagCache [ addressJ ] = tagAddr ; } } else { ConstantExpr * CE = dyn_cast < ConstantExpr > ( addressJ ) ; uint64_t addrRaw = CE -> getZExtValue ( ) ; tag = CACHE_TAG ( addrRaw , nset , line ) ; if ( tagCache . count ( addressI ) ) tagAddr = tagCache [ addressI ] ; else { tagAddr = LShrExpr :: create ( addressI , ConstantExpr :: alloc ( log_base2 ( line ) + log_base2 ( nset ) , addressI -> getWidth ( ) ) ) ; tagCache [ addressI ] = tagAddr ; } } ref < Expr > eqExpr = EqExpr :: create ( tagAddr , ConstantExpr :: alloc ( tag , tagAddr -> getWidth ( ) ) ) ; tagPairCache [ tagPair ] = NotExpr :: create ( eqExpr ) ; return tagPairCache [ tagPair ] ; }
generate tag inequality constraints for <symbolic,constant> address pairs
generate tag inequality 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 */