cloud9_root/src/third_party/stp/src/AST/NodeFactory/SimplifyingNodeFactory.cpp
// Move reads down through writes until, either we hit a write to an identical (syntactically) index,
// or we hit a write to an index that might be the same. This is intended to simplify things like:
// read(write(write(A,1,2),2,3),4) cheaply.
// The "children" that are passed should be the children of a READ.
Move reads down through writes until, either we hit a write to an identical (syntactically) index,
or we hit a write to an index that might be the same. This is intended to simplify things like:
read(write(write(A,1,2),2,3),4) cheaply.
The "children" that are passed should be the children of a READ.
Move reads down through writes until either we hit a write to an identical ( syntactically ) index or we hit a write to an index that might be the same . This is intended to simplify things like : read ( write ( write ( A 1 2 ) 2 3 ) 4 ) cheaply . The " children " that are passed should be the children of a READ .
ASTNode SimplifyingNodeFactory::chaseRead(const ASTVec& children, unsigned int width)
{
	assert(children[0].GetKind() == BEEV::WRITE);
	const ASTNode& readIndex = children[1];
	ASTNode write = children[0];
	const bool read_is_const = (BEEV::BVCONST == readIndex.GetKind());
        ASTVec c(2);
	while (write.GetKind() == BEEV::WRITE)
	{
		const ASTNode& write_index = write[1];
		if (readIndex == write_index)
		{
			return write[2];
		}
		else if (read_is_const && BEEV::BVCONST == write_index.GetKind())
		{
		}else
		{
		        c[0] =write_index;
		        c[1] = readIndex;
		        ASTNode n = CreateSimpleEQ(c);
		        if (n == ASTTrue)
		            {
		                return write[2];
		            }
		        else if (n == ASTFalse)
		            {
		            }
		        else
		            {
		                break;
		            }
		}
		write = write[0];
	}
	return hashing.CreateTerm(BEEV::READ, width, write,readIndex);
}
ASTNode SimplifyingNodeFactory :: chaseRead ( const ASTVec & children , unsigned int width ) { assert ( children [ 0 ] . GetKind ( ) == BEEV :: WRITE ) ; const ASTNode & readIndex = children [ 1 ] ; ASTNode write = children [ 0 ] ; const bool read_is_const = ( BEEV :: BVCONST == readIndex . GetKind ( ) ) ; ASTVec c ( 2 ) ; while ( write . GetKind ( ) == BEEV :: WRITE ) { const ASTNode & write_index = write [ 1 ] ; if ( readIndex == write_index ) { return write [ 2 ] ; } else if ( read_is_const && BEEV :: BVCONST == write_index . GetKind ( ) ) { } else { c [ 0 ] = write_index ; c [ 1 ] = readIndex ; ASTNode n = CreateSimpleEQ ( c ) ; if ( n == ASTTrue ) { return write [ 2 ] ; } else if ( n == ASTFalse ) { } else { break ; } } write = write [ 0 ] ; } return hashing . CreateTerm ( BEEV :: READ , width , write , readIndex ) ; }
Move reads down through writes until, either we hit a write to an identical (syntactically) index,
or we hit a write to an index that might be the same.
Move reads down through writes until either we hit a write to an identical ( syntactically ) index or we hit a write to an index that might be the same .
// The are definately the same. //cerr << "-"; // They are definately different. Ignore this. //cerr << "+"; // They may be the same. Exit. // We've finished the cheap tests, now do the expensive one. // I don't know if the cost of this justifies the benefit. //cerr << "#"; //cerr << "#"; //cerr << "!"; //cerr << "." //Perhaps they are the same, perhaps not.