ASTNode(ASTInternal *in);
//Equal iff ASTIntNode pointers are the same.
- friend bool operator==(const ASTNode node1, const ASTNode node2)
+ friend bool operator==(const ASTNode& node1, const ASTNode& node2)
{
return
((size_t) node1._int_node_ptr) ==
((size_t) node2._int_node_ptr);
}
- friend bool operator!=(const ASTNode node1, const ASTNode node2)
+ friend bool operator!=(const ASTNode& node1, const ASTNode& node2)
{
return !(node1 == node2);
}
- friend bool operator<(const ASTNode node1, const ASTNode node2)
+ friend bool operator<(const ASTNode& node1, const ASTNode& node2)
{
return
((size_t) node1._int_node_ptr) <
return result;
}
+
+// On some cases I suspect this is better than the new variant.
+ASTNode BBBVLE_variant(const BBNodeVec& left, const BBNodeVec& right, bool is_signed, BBNodeManager* nf)
+{
+ // "thisbit" represents BVLE of the suffixes of the BVs
+ // from that position . if R < L, return TRUE, else if L < R
+ // return FALSE, else return BVLE of lower-order bits. MSB is
+ // treated separately, because signed comparison is done by
+ // complementing the MSB of each BV, then doing an unsigned
+ // comparison.
+ BBNodeVec::const_iterator lit = left.begin();
+ BBNodeVec::const_iterator litend = left.end();
+ BBNodeVec::const_iterator rit = right.begin();
+ BBNode prevbit = nf->getTrue();
+ for (; lit < litend - 1; lit++, rit++)
+ {
+ BBNode thisbit = nf->CreateNode(ITE, nf->CreateNode(IFF, *rit, *lit), prevbit, *rit);
+ prevbit = thisbit;
+ }
+
+ // Handle MSB -- negate MSBs if signed comparison
+ BBNode lmsb = *lit;
+ BBNode rmsb = *rit;
+ if (is_signed)
+ {
+ lmsb = nf->CreateNode(NOT, *lit);
+ rmsb = nf->CreateNode(NOT, *rit);
+ }
+
+ BBNode msb = nf->CreateNode(ITE, nf->CreateNode(IFF, rmsb, lmsb), prevbit, rmsb);
+ return msb;
+}
+
+
+
// Workhorse for comparison routines. This does a signed BVLE if is_signed
// is true, else it's unsigned. All other comparison operators can be reduced
// to this by swapping args or complementing the result bit.
//########################################
//utilities for control bits.
- void CNFMgr::initializeCNFInfo(CNFInfo& x)
- {
- x.control = 0;
- x.clausespos = NULL;
- x.clausesneg = NULL;
- } //End of initlializeCNFInfo()
-
+
void CNFMgr::incrementSharesPos(CNFInfo& x)
{
x.control += ((x.control & 3) < 2) ? 1 : 0;
if (info.find(varphi) == info.end())
{
x = new CNFInfo();
- initializeCNFInfo(*x);
info[varphi] = x;
}
else
if (info.find(varphi) == info.end())
{
x = new CNFInfo();
- initializeCNFInfo(*x);
info[varphi] = x;
}
else
{
CNFInfo* x = info[varphi];
+ assert(!wasRenamedPos(*x));
+
//########################################
// step 1, calc new variable
//########################################