Ejemplo n.º 1
0
/*
 * Test: check whether b is present in the table
 * if not add it
 */
static void test_buffer64(bvexp_table_t *table, bvarith64_buffer_t *b) {
  bvmlist64_t *p;
  thvar_t x;
  uint32_t h, n;

  printf("=== test64 ===\n");
  n = b->bitsize;

  printf("poly = ");
  print_bvexp64(stdout, b->list, n);
  printf("\n");

  h = hash_bvmlist64(b->list, n);
  printf("hash code = %"PRIu32"\n", h);

  x = bvexp_table_find64(table, b, h);
  if (x < 0) {
    printf("not in table\n");
    x = make_bvvar(table->vtbl, n);
    bvexp_table_add64(table, x, b, h);
    printf("adding variable: ");
    print_def(stdout, table, x);
  } else {
    printf("found matching variable: ");
    print_def(stdout, table, x);
    p = bvexp_def64(table, x);
    if (p == NULL || !equal_bvmlists64(b->list, p) || bvvar_bitsize(table->vtbl, x) != n) {
      printf("BUG\n");
      exit(1);
    }
  }
  printf("\n");
}
Ejemplo n.º 2
0
void bvexp_table_add64(bvexp_table_t *table, thvar_t v, bvarith64_buffer_t *buffer, uint32_t h) {
  bvmlist64_t *p;

  assert(bvvar_bitsize(table->vtbl, v) <= 64);
  assert(h == hash_bvmlist64(buffer->list, buffer->bitsize));
  assert(buffer->store == &table->store64 && buffer->ptbl == &table->pprods);

  p = bvarith64_buffer_get_mlist(buffer);
  bvexp_set_def(table, v, p);
  int_htbl_add_record(&table->htbl, h, v);
}
Ejemplo n.º 3
0
thvar_t bvexp_table_find64(bvexp_table_t *table, bvarith64_buffer_t *buffer, uint32_t h) {
  bvexp_hobj_t hobj;

  assert(h == hash_bvmlist64(buffer->list, buffer->bitsize));
  assert(buffer->store == &table->store64 && buffer->ptbl == &table->pprods);

  hobj.m.hash = (hobj_hash_t) hash_bvexp_hobj;
  hobj.m.eq = (hobj_eq_t) eq_hash_bvexp_hobj;
  hobj.m.build = NULL;
  hobj.table = table;
  hobj.def = buffer->list;
  hobj.bitsize = buffer->bitsize;
  hobj.h = h;

  return int_htbl_find_obj(&table->htbl, &hobj.m);
}
Ejemplo n.º 4
0
/*
 * Remove variable x from the table
 */
static void bvexp_table_remove_var(bvexp_table_t *table, thvar_t x) {
  void *p;
  uint32_t n, h;

  assert(0 <= x && x < table->nvars);
  p = table->def[x];
  if (p != NULL) {
    n = bvvar_bitsize(table->vtbl, x);
    if (n > 64) {
      h = hash_bvmlist(p, n);
      free_bvmlist(p, &table->store, n);
    } else {
      h = hash_bvmlist64(p, n);
      free_bvmlist64(p, &table->store64);
    }
    int_htbl_erase_record(&table->htbl, h, x);
  }
}