BtorNode * boolector_add (Btor * btor, BtorNode * e0, BtorNode * e1) { BTOR_ABORT_ARG_NULL_BOOLECTOR (btor); BTOR_ABORT_ARG_NULL_BOOLECTOR (e0); BTOR_ABORT_ARG_NULL_BOOLECTOR (e1); BTOR_ABORT_REFS_NOT_POS_BOOLECTOR (e0); BTOR_ABORT_REFS_NOT_POS_BOOLECTOR (e1); e0 = btor_pointer_chase_simplified_exp (btor, e0); e1 = btor_pointer_chase_simplified_exp (btor, e1); BTOR_ABORT_ARRAY_BOOLECTOR (e0); BTOR_ABORT_ARRAY_BOOLECTOR (e1); BTOR_ABORT_NE_BW (e0, e1); btor->external_refs++; return btor_add_exp (btor, e0, e1); }
static inline BtorNode * create_pattern_cpy (Btor * btor, BtorNode * lower, BtorNode * upper, BtorNode * src_array, BtorNode * dst_array, BtorNode * src_addr, BtorNode * dst_addr, BtorBitVector * offset) { assert (!BTOR_IS_INVERTED_NODE (lower)); assert (!BTOR_IS_INVERTED_NODE (upper)); assert (BTOR_IS_ADD_NODE (lower)); assert (BTOR_IS_ADD_NODE (upper)); BtorNode *res, *param, *ite, *read, *cond, *read_src, *add, *sub; param = btor_param_exp (btor, btor_get_exp_width (btor, lower), 0); read = btor_read_exp (btor, dst_array, param); cond = create_range (btor, lower, upper, param, offset); sub = btor_sub_exp (btor, param, dst_addr); add = btor_add_exp (btor, src_addr, sub); read_src = btor_read_exp (btor, src_array, add); ite = btor_cond_exp (btor, cond, read_src, read); res = btor_lambda_exp (btor, param, ite); btor_release_exp (btor, param); btor_release_exp (btor, read); btor_release_exp (btor, cond); btor_release_exp (btor, sub); btor_release_exp (btor, add); btor_release_exp (btor, read_src); btor_release_exp (btor, ite); return res; }
static BtorNode * btor_map_node_internal (Btor * btor, BtorNodeMap * map, BtorNode * exp) { assert (btor); assert (exp); assert (BTOR_IS_REGULAR_NODE (exp)); BtorNode * m[3], * src, * dst, * real_exp; int i; m[0] = m[1] = m[2] = 0; for (i = 0; i < exp->arity; i++) { src = exp->e[i]; dst = btor_mapped_node (map, src); m[i] = dst ? dst : src; assert (BTOR_REAL_ADDR_NODE (m[i])->btor == btor); } assert (exp->kind != BTOR_PROXY_NODE); switch (exp->kind) { case BTOR_BV_CONST_NODE: // FIXME real_exp = exp weil BTOR_IS_REGULAR_NODE (exp) real_exp = BTOR_REAL_ADDR_NODE (exp); if (real_exp->btor != btor) { BtorNode * res = btor_const_exp (btor, btor_const_get_bits (exp)); if (real_exp != exp) res = BTOR_INVERT_NODE (res); return res; } // ELSE FALL THROUGH!!! case BTOR_BV_VAR_NODE: case BTOR_UF_NODE: return btor_copy_exp (btor, exp); case BTOR_SLICE_NODE: return btor_slice_exp (btor, m[0], btor_slice_get_upper (exp), btor_slice_get_lower (exp)); case BTOR_AND_NODE: return btor_and_exp (btor, m[0], m[1]); case BTOR_BEQ_NODE: case BTOR_FEQ_NODE: return btor_eq_exp (btor, m[0], m[1]); case BTOR_ADD_NODE: return btor_add_exp (btor, m[0], m[1]); case BTOR_MUL_NODE: return btor_mul_exp (btor, m[0], m[1]); case BTOR_ULT_NODE: return btor_ult_exp (btor, m[0], m[1]); case BTOR_SLL_NODE: return btor_sll_exp (btor, m[0], m[1]); case BTOR_SRL_NODE: return btor_srl_exp (btor, m[0], m[1]); case BTOR_UDIV_NODE: return btor_udiv_exp (btor, m[0], m[1]); case BTOR_UREM_NODE: return btor_urem_exp (btor, m[0], m[1]); case BTOR_CONCAT_NODE: return btor_concat_exp (btor, m[0], m[1]); case BTOR_LAMBDA_NODE: return btor_lambda_exp (btor, m[0], m[1]); default: assert (BTOR_IS_BV_COND_NODE (exp)); return btor_cond_exp (btor, m[0], m[1], m[2]); } }