Beispiel #1
0
BtorNode *
boolector_srl (Btor * btor, BtorNode * e0, BtorNode * e1)
{
  int len;
  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);
  len = BTOR_REAL_ADDR_NODE (e0)->len;
  BTOR_ABORT_BOOLECTOR (!btor_is_power_of_2_util (len),
			"bit-width of 'e0' must be a power of 2");
  BTOR_ABORT_BOOLECTOR (btor_log_2_util (len) != BTOR_REAL_ADDR_NODE (e1)->len,
			"bit-width of 'e1' must be equal to log2(bit-width of 'e0')");
  btor->external_refs++;
  return btor_srl_exp (btor, e0, e1);
}
Beispiel #2
0
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]);
    }
}