Exemplo n.º 1
0
static void
btor_delete_btor_parser (BtorBTORParser * parser)
{
  BtorNode *e;
  int i;

  for (i = 0; i < BTOR_COUNT_STACK (parser->exps); i++)
    if ((e = parser->exps.start[i]))
      btor_release_exp (parser->btor, parser->exps.start[i]);

  BTOR_RELEASE_STACK (parser->mem, parser->exps);
  BTOR_RELEASE_STACK (parser->mem, parser->info);
  BTOR_RELEASE_STACK (parser->mem, parser->inputs);
  BTOR_RELEASE_STACK (parser->mem, parser->outputs);
  BTOR_RELEASE_STACK (parser->mem, parser->regs);
  BTOR_RELEASE_STACK (parser->mem, parser->nexts);

  BTOR_RELEASE_STACK (parser->mem, parser->op);
  BTOR_RELEASE_STACK (parser->mem, parser->constant);
  BTOR_RELEASE_STACK (parser->mem, parser->symbol);

  BTOR_DELETEN (parser->mem, parser->parsers, SIZE_PARSERS);
  BTOR_DELETEN (parser->mem, parser->ops, SIZE_PARSERS);

  btor_freestr (parser->mem, parser->error);
  BTOR_DELETE (parser->mem, parser);
}
Exemplo n.º 2
0
void
btor_delete_param_cache_tuple (Btor * btor, BtorParamCacheTuple * t)
{
  assert (btor);
  assert (t);
  
  int i;

  btor_release_exp (btor, t->exp);
  if (t->args)
    {
      for (i = 0; i < t->num_args; i++)
        btor_release_exp (btor, t->args[i]);
      BTOR_DELETEN (btor->mm, t->args, t->num_args);
    }
  BTOR_DELETE (btor->mm, t);
}
Exemplo n.º 3
0
static int
btor_passdown_lingeling_options (BtorSATMgr * smgr,
				 const char * optstr,
				 LGL * external_lgl)
{
  char * str, * p, * next, * eq, * opt, * val;
  LGL * lgl = external_lgl ? external_lgl : 0;
  int len, valid, res = 1;

  assert (optstr);
  len = strlen (optstr);

  BTOR_NEWN (smgr->mm, str, len + 1);
  strcpy (str, optstr);

  res = 1;

  for (p = str; *p; p = next)
    {
      if (*p == ',')
	next = p + 1;
      else
	{
	  opt = p;
	  while (*p != ',' && *p)
	    p++;

	  if (*p)
	    {
	      assert (*p == ',');
	      *p = 0;
	      next = p + 1;
	    }
	  else next = p;

	  val = eq = 0;

	  if (!isalpha (*opt))
	    valid = 0;
	  else
	    {
	      for (p = opt + 1; isalnum (*p); p++)
		;

	      if (*p == '=')
		{
		  *(eq = p++) = 0;
		  val = p;
		  if (*p == '-') p++;
		  if (isdigit (*p))
		    {
		      while (isdigit (*p))
			p++;

		      valid = !*p;
		    }
		  else
		    valid = 0;
		}
	      else
		valid = 0;
	    }

	  if (valid)
	    {
	      if (!lgl)
		{
		  assert (!external_lgl);
		  lgl = lglinit ();
		}

	      if (lglhasopt (lgl, opt))
		{
		  if (external_lgl && val)
		    {
		      assert (lgl == external_lgl);
		      btor_msg_sat (smgr, 2,
			"setting Lingeling option --%s=%s", opt, val);
		      lglsetopt (lgl, opt, atoi (val));
		    }
		}
	      else
		valid = 0;
	    }

	  if (!valid) res = 0;
	  if (valid || external_lgl) continue;

	  if (eq) *eq = '=';
	  btor_msg_sat (smgr, 0,
	    "*** can not pass down to Lingeling invalid option '%s'", optstr);
	}
    }

  BTOR_DELETEN (smgr->mm, str, len + 1);
  if (lgl && !external_lgl) lglrelease (lgl);

  return res;
}
Exemplo n.º 4
0
static void
udiv_urem_const (BtorMemMgr * mm, const char * Ain, const char * Din,
                 char **Qptr, char **Rptr)
{
  char *A, *nD, **S, **C;
  char *Q, *R;
  int size, i, j;

  assert (mm != NULL);
  assert (Ain != NULL);
  assert (Din != NULL);
  assert (Qptr != NULL);
  assert (Rptr != NULL);
  assert (is_valid_const_3vl (Ain));
  assert (is_valid_const_3vl (Din));
  assert (strlen (Ain) == strlen (Din));

  size = (int) strlen (Ain);
  assert (size > 0);

  BTOR_NEWN (mm, A, size);
  for (i = 0; i < size; i++)
    A[i] = Ain[size - 1 - i];

  BTOR_NEWN (mm, nD, size);
  for (i = 0; i < size; i++)
    nD[i] = BTOR_NOT_CONST_3VL(Din[size - 1 - i]);

  BTOR_NEWN (mm, S, size + 1);
  for (j = 0; j <= size; j++)
    {
      BTOR_NEWN (mm, S[j], size + 1);
      for (i = 0; i <= size; i++)
        S[j][i] = '0';
    }

  BTOR_NEWN (mm, C, size + 1);
  for (j = 0; j <= size; j++)
    {
      BTOR_NEWN (mm, C[j], size + 1);
      for (i = 0; i <= size; i++)
        C[j][i] = '0';
    }

  BTOR_NEWN (mm, R, size + 1);
  BTOR_NEWN (mm, Q, size + 1);
  R[size] = '\0';
  Q[size] = '\0';

  for (j = 0; j <= size - 1; j++)
    {
      S[j][0] = A[size - j - 1];
      C[j][0] = '1';

      for (i = 0; i <= size - 1; i++)
        btor_SC_GATE_CO_const (&C[j][i + 1], S[j][i], nD[i], C[j][i]);

      Q[j] = BTOR_OR_CONST_3VL (C[j][size], S[j][size]);

      for (i = 0; i <= size - 1; i++)
        btor_SC_GATE_S_const (&S[j + 1][i + 1], S[j][i], nD[i], C[j][i], Q[j]);
    }

  for (i = size; i >= 1; i--)
    R[size - i] = S[size][i];

  for (j = 0; j <= size; j++)
    BTOR_DELETEN (mm, C[j], size + 1);
  BTOR_DELETEN (mm, C, size + 1);

  for (j = 0; j <= size; j++)
    BTOR_DELETEN (mm, S[j], size + 1);
  BTOR_DELETEN (mm, S, size + 1);

  BTOR_DELETEN (mm, nD, size);
  BTOR_DELETEN (mm, A, size);

  *Qptr = Q;
  *Rptr = R;

}