template<>
Node RewriteRule<ConcatFlatten>::apply(Node node) {
+ Debug("bv-rewrite") << "RewriteRule<ConcatFlatten>(" << node << ")" << std::endl;
NodeBuilder<> result(kind::BITVECTOR_CONCAT);
std::vector<Node> processing_stack;
processing_stack.push_back(node);
template<>
Node RewriteRule<ConcatExtractMerge>::apply(Node node) {
+
+ Debug("bv-rewrite") << "RewriteRule<ConcatExtractMerge>(" << node << ")" << std::endl;
+
std::vector<Node> mergedExtracts;
Node current = node[0];
template<>
Node RewriteRule<ConcatConstantMerge>::apply(Node node) {
+
+ Debug("bv-rewrite") << "RewriteRule<ConcatConstantMerge>(" << node << ")" << std::endl;
+
std::vector<Node> mergedConstants;
for (unsigned i = 0, end = node.getNumChildren(); i < end;) {
if (node[i].getKind() != kind::CONST_BITVECTOR) {
}
// Add the new merged constant
mergedConstants.push_back(utils::mkConst(current));
- i = j + 1;
+ i = j;
}
}
+ Debug("bv-rewrite") << "RewriteRule<ConcatConstantMerge>(" << node << ") => " << utils::mkConcat(mergedConstants) << std::endl;
+
return utils::mkConcat(mergedConstants);
}
template<>
Node RewriteRule<ExtractWhole>::apply(Node node) {
+ Debug("bv-rewrite") << "RewriteRule<ExtractWhole>(" << node << ")" << std::endl;
return node[0];
}
template<>
Node RewriteRule<ExtractConstant>::apply(Node node) {
+ Debug("bv-rewrite") << "RewriteRule<ExtractConstant>(" << node << ")" << std::endl;
Node child = node[0];
BitVector childValue = child.getConst<BitVector>();
return utils::mkConst(childValue.extract(utils::getExtractHigh(node), utils::getExtractLow(node)));
template<>
bool RewriteRule<ExtractConcat>::applies(Node node) {
+ Debug("bv-rewrite") << "RewriteRule<ExtractConcat>(" << node << ")" << std::endl;
if (node.getKind() != kind::BITVECTOR_EXTRACT) return false;
if (node[0].getKind() != kind::BITVECTOR_CONCAT) return false;
return true;
template<>
Node RewriteRule<ExtractConcat>::apply(Node node) {
+ Debug("bv-rewrite") << "RewriteRule<ExtractConcat>(" << node << ")" << std::endl;
int extract_high = utils::getExtractHigh(node);
int extract_low = utils::getExtractLow(node);
template<>
Node RewriteRule<ExtractExtract>::apply(Node node) {
+ Debug("bv-rewrite") << "RewriteRule<ExtractExtract>(" << node << ")" << std::endl;
+
// x[i:j][k:l] ~> x[k+j:l+j]
Node child = node[0];
unsigned k = utils::getExtractHigh(node);
template<>
bool RewriteRule<FailEq>::applies(Node node) {
+ Debug("bv-rewrite") << "RewriteRule<FailEq>(" << node << ")" << std::endl;
if (node.getKind() != kind::EQUAL) return false;
if (node[0].getKind() != kind::CONST_BITVECTOR) return false;
if (node[1].getKind() != kind::CONST_BITVECTOR) return false;
template<>
Node RewriteRule<SimplifyEq>::apply(Node node) {
+ Debug("bv-rewrite") << "RewriteRule<SimplifyEq>(" << node << ")" << std::endl;
return utils::mkTrue();
}
template<>
Node RewriteRule<ReflexivityEq>::apply(Node node) {
+ Debug("bv-rewrite") << "RewriteRule<ReflexivityEq>(" << node << ")" << std::endl;
return node[1].eqNode(node[0]);;
}