static void test_buffer(bvexp_table_t *table, bvarith_buffer_t *b) { bvmlist_t *p; thvar_t x; uint32_t h, n; printf("=== test ===\n"); n = b->bitsize; printf("poly = "); print_bvexp(stdout, b->list, n); printf("\n"); h = hash_bvmlist(b->list, n); printf("hash code = %"PRIu32"\n", h); x = bvexp_table_find(table, b, h); if (x < 0) { printf("not in table\n"); x = make_bvvar(table->vtbl, n); bvexp_table_add(table, x, b, h); printf("adding variable: "); print_def(stdout, table, x); } else { printf("found matching variable: "); print_def(stdout, table, x); p = bvexp_def(table, x); if (p == NULL || !equal_bvmlists(b->list, p, n) || bvvar_bitsize(table->vtbl, x) != n) { printf("BUG\n"); exit(1); } } printf("\n"); }
/* * Equality test */ static bool eq_hash_bvexp_hobj(bvexp_hobj_t *o, thvar_t i) { bvexp_table_t *table; uint32_t n; bool result; table = o->table; assert(0 <= i && i < table->nvars && table->def[i] != NULL); n = o->bitsize; result = false; if (bvvar_bitsize(table->vtbl, i) == n) { if (n <= 64) { result = equal_bvmlists64(o->def, table->def[i]); } else { result = equal_bvmlists(o->def, table->def[i], n); } } return result; }