コード例 #1
0
static void
add_to_index_map (Btor * btor,
                  BtorPtrHashTable * map_value_index,
                  BtorNode * lambda,
                  BtorNode * index,
                  BtorNode * value)
{
  BtorMemMgr *mm;
  BtorPtrHashBucket *b;
  BtorPtrHashTable *t;
  BtorNodePtrStack *indices;
  BtorNode *offset;

  mm = btor->mm;

  if (!(b = btor_find_in_ptr_hash_table (map_value_index, lambda)))
    {
      b = btor_insert_in_ptr_hash_table (map_value_index, lambda);
      t = btor_new_ptr_hash_table (mm, 0, 0);
      b->data.asPtr = t;
    }
  else
    t = b->data.asPtr;
  assert (t);

  if (!(b = btor_find_in_ptr_hash_table (t, value)))
    {
      b = btor_insert_in_ptr_hash_table (t, value);
      BTOR_NEW (mm, indices);
      BTOR_INIT_STACK (*indices);
      b->data.asPtr = indices;
    }
  else
    indices = (BtorNodePtrStack *) b->data.asPtr;
  assert (indices);
  if (BTOR_IS_BV_CONST_NODE (BTOR_REAL_ADDR_NODE (index)))
    offset = index;
  else
    {
      assert (BTOR_IS_REGULAR_NODE (index));
      assert (BTOR_IS_ADD_NODE (index));
      extract_base_addr_offset (index, 0, &offset);
      assert (BTOR_IS_BV_CONST_NODE (BTOR_REAL_ADDR_NODE (offset)));
    }

  /* generate inverted bit string for constants if required */
  if (BTOR_IS_INVERTED_NODE (offset) && !btor_const_get_invbits (offset))
    btor_const_set_invbits (
        offset, btor_not_bv (mm, btor_const_get_bits (offset)));

  BTOR_PUSH_STACK (mm, *indices, index);
}
コード例 #2
0
BtorAIGMap * 
btor_new_aig_map (Btor * btor, BtorAIGMgr * amgr_src, BtorAIGMgr * amgr_dst)
{
  assert (btor);
  assert (amgr_src);
  assert (amgr_dst);

  BtorAIGMap *res;

  BTOR_NEW (btor->mm, res);
  res->btor = btor;
  res->amgr_src = amgr_src;
  res->amgr_dst = amgr_dst;
  res->table = btor_new_ptr_hash_table (btor->mm, 0, 0);
  return res;
}
コード例 #3
0
BtorNodeMap *
btor_new_node_map (Btor * btor)
{
  BtorNodeMap *res;

  assert (btor);
  
  BTOR_NEW (btor->mm, res);
  res->btor = btor;
  res->table = btor_new_ptr_hash_table (btor->mm, 
                                        (BtorHashPtr) btor_hash_exp_by_id, 
                                        (BtorCmpPtr) btor_compare_exp_by_id);
  res->simplify = 0;

  return res;
}
コード例 #4
0
ファイル: btorsat.c プロジェクト: hellok/kint
BtorSATMgr *
btor_new_sat_mgr (BtorMemMgr * mm)
{
  BtorSATMgr *smgr;

  assert (mm != NULL);

  BTOR_NEW (mm, smgr);

  smgr->verbosity = 0;
  smgr->mm = mm;
  smgr->satcalls = 0;
  smgr->initialized = 0;
  smgr->clauses = smgr->maxvar = 0;
  smgr->output = stdout;

  btor_enable_default_sat (smgr);

  return smgr;
}
コード例 #5
0
BtorParamCacheTuple *
btor_copy_param_cache_tuple (Btor * btor, BtorParamCacheTuple * t)
{
  assert (btor);
  assert (t);

  BtorParamCacheTuple *result;

  BTOR_NEW (btor->mm, result);
  BTOR_CLR (result);

  result->exp = btor_copy_exp (btor, t->exp);
  result->hash = t->hash;
  result->num_args = t->num_args;

  BTOR_NEWN (btor->mm, result->args, result->num_args);
  memcpy (result->args, t->args, t->num_args * sizeof (*result->args));

  return result;
}
コード例 #6
0
ファイル: btorbtor.c プロジェクト: hellok/kint
static BtorBTORParser *
btor_new_btor_parser (Btor * btor, BtorParseOpt * opts)
{
  BtorMemMgr *mem = btor->mm;
  BtorBTORParser *res;

  (void) opts->incremental;		// TODO what about incremental?
  (void) opts->need_model;		// TODO use at least this

  assert (opts->verbosity >= -1);

  BTOR_NEW (mem, res);
  BTOR_CLR (res);

  res->mem = mem;
  res->btor = btor;

  BTOR_NEWN (mem, res->parsers, SIZE_PARSERS);
  BTOR_NEWN (mem, res->ops, SIZE_PARSERS);
  BTOR_CLRN (res->ops, SIZE_PARSERS);

  new_parser (res, parse_add, "add");
  new_parser (res, parse_and, "and");
  new_parser (res, parse_array, "array");
  new_parser (res, parse_concat, "concat");
  new_parser (res, parse_cond, "cond");
  new_parser (res, parse_acond, "acond");
  new_parser (res, parse_const, "const");
  new_parser (res, parse_constd, "constd");
  new_parser (res, parse_consth, "consth");
  new_parser (res, parse_eq, "eq");
  new_parser (res, parse_iff, "iff");
  new_parser (res, parse_implies, "implies");
  new_parser (res, parse_mul, "mul");
  new_parser (res, parse_nand, "nand");
  new_parser (res, parse_neg, "neg");
  new_parser (res, parse_inc, "inc");
  new_parser (res, parse_dec, "dec");
  new_parser (res, parse_ne, "ne");
  new_parser (res, parse_next, "next"); /* only in parser */
  new_parser (res, parse_anext, "anext"); /* only in parser */
  new_parser (res, parse_nor, "nor");
  new_parser (res, parse_not, "not");
  new_parser (res, parse_one, "one");
  new_parser (res, parse_ones, "ones");
  new_parser (res, parse_or, "or");
  new_parser (res, parse_proxy, "proxy");
  new_parser (res, parse_read, "read");
  new_parser (res, parse_redand, "redand");
  new_parser (res, parse_redor, "redor");
  new_parser (res, parse_redxor, "redxor");
  new_parser (res, parse_rol, "rol");
  new_parser (res, parse_root, "root"); /* only in parser */
  new_parser (res, parse_ror, "ror");
  new_parser (res, parse_saddo, "saddo");
  new_parser (res, parse_sdivo, "sdivo");
  new_parser (res, parse_sdiv, "sdiv");
  new_parser (res, parse_sext, "sext");
  new_parser (res, parse_sgte, "sgte");
  new_parser (res, parse_sgt, "sgt");
  new_parser (res, parse_slice, "slice");
  new_parser (res, parse_sll, "sll");
  new_parser (res, parse_slte, "slte");
  new_parser (res, parse_slt, "slt");
  new_parser (res, parse_smod, "smod");
  new_parser (res, parse_smulo, "smulo");
  new_parser (res, parse_sra, "sra");
  new_parser (res, parse_srem, "srem");
  new_parser (res, parse_srl, "srl");
  new_parser (res, parse_ssubo, "ssubo");
  new_parser (res, parse_sub, "sub");
  new_parser (res, parse_uaddo, "uaddo");
  new_parser (res, parse_udiv, "udiv");
  new_parser (res, parse_uext, "uext");
  new_parser (res, parse_ugte, "ugte");
  new_parser (res, parse_ugt, "ugt");
  new_parser (res, parse_ulte, "ulte");
  new_parser (res, parse_ult, "ult");
  new_parser (res, parse_umulo, "umulo");
  new_parser (res, parse_urem, "urem");
  new_parser (res, parse_usubo, "usubo");
  new_parser (res, parse_var, "var");
  new_parser (res, parse_write, "write");
  new_parser (res, parse_xnor, "xnor");
  new_parser (res, parse_xor, "xor");
  new_parser (res, parse_zero, "zero");

  res->verbosity = opts->verbosity;

  return res;
}
コード例 #7
0
BtorParamCacheTuple *
btor_new_param_cache_tuple (Btor * btor, BtorNode * exp)
{
  assert (btor);
  assert (exp);
  assert (BTOR_IS_REGULAR_NODE (exp));

  int i;
  unsigned int hash;
  BtorNode *param, *arg, *cur;
  BtorParamCacheTuple *t;
  BtorParameterizedIterator it;
  BtorNodeIterator pit;

  BTOR_NEW (btor->mm, t);
  BTOR_CLR (t);
  t->exp = btor_copy_exp (btor, exp);

  btor_init_parameterized_iterator (&it, btor, exp);

  hash = BTOR_REAL_ADDR_NODE (exp)->id;
  if (btor_has_next_parameterized_iterator (&it))
    {
      t->num_args = it.num_params; 
      if (BTOR_IS_LAMBDA_NODE (exp))
        t->num_args += btor_get_fun_arity (btor, exp);

      BTOR_NEWN (btor->mm, t->args, t->num_args);

      i = 0;
      if (BTOR_IS_LAMBDA_NODE (exp))
        {
          btor_init_lambda_iterator (&pit, exp);
          while (btor_has_next_lambda_iterator (&pit))
            {
              cur = btor_next_lambda_iterator (&pit);
              arg = btor_param_cur_assignment (cur->e[0]);
              if (!arg)
                arg = cur->e[0];
              assert (arg);
              t->args[i++] = btor_copy_exp (btor, arg);
              hash += (unsigned int) BTOR_GET_ID_NODE (arg);
            }
        }

      do
        {
          param = btor_next_parameterized_iterator (&it);
          assert (BTOR_IS_REGULAR_NODE (param));
          assert (BTOR_IS_PARAM_NODE (param));
          arg = btor_param_cur_assignment (param);
          if (!arg)
            arg = param;
          assert (arg);
          t->args[i++] = btor_copy_exp (btor, arg);
          hash += (unsigned int) BTOR_GET_ID_NODE (arg);
        }
      while (btor_has_next_parameterized_iterator (&it));
    }
  else if (BTOR_IS_LAMBDA_NODE (exp))
    {
      btor_init_lambda_iterator (&pit, exp);
      t->num_args = btor_get_fun_arity (btor, exp);
      BTOR_NEWN (btor->mm, t->args, t->num_args);

      i = 0;
      while (btor_has_next_lambda_iterator (&pit))
        {
          cur = btor_next_lambda_iterator (&pit);
          arg = btor_param_cur_assignment (cur->e[0]);
          if (!arg)
            arg = cur->e[0];
          assert (arg);
          t->args[i++] = btor_copy_exp (btor, arg);
          hash += (unsigned int) BTOR_GET_ID_NODE (arg);
        }
    }
  hash *= 7334147u;
  t->hash = hash;

  return t;
}