ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
watch.h
Go to the documentation of this file.
1#ifndef _watch_h_INCLUDED
2#define _watch_h_INCLUDED
3
4#include "keatures.h"
5#include "reference.h"
6#include "stack.h"
7#include "vector.h"
8
9#include <stdbool.h>
10
11#include "global.h"
13
14typedef union watch watch;
15
20
22#ifdef KISSAT_IS_BIG_ENDIAN
23 bool binary : 1;
24 unsigned lit : 31;
25#else
26 unsigned lit : 31;
27 bool binary : 1;
28#endif
29};
30
32#ifdef KISSAT_IS_BIG_ENDIAN
33 bool binary : 1;
34 unsigned ref : 31;
35#else
36 unsigned ref : 31;
37 bool binary : 1;
38#endif
39};
40
48
50
51typedef struct litwatch litwatch;
52typedef struct litpair litpair;
53typedef struct litriple litriple;
54
55typedef STACK (litwatch) litwatches;
56typedef STACK (litpair) litpairs;
57typedef STACK (litriple) litriples;
58
59struct litwatch {
60 unsigned lit;
62};
63
64struct litpair {
65 unsigned lits[2];
66};
67
68struct litriple {
69 unsigned lits[3];
70};
71
72static inline litpair kissat_litpair (unsigned lit, unsigned other) {
73 litpair res;
74 res.lits[0] = lit < other ? lit : other;
75 res.lits[1] = lit < other ? other : lit;
76 return res;
77}
78
79static inline watch kissat_binary_watch (unsigned lit) {
80 watch res;
81 res.binary.lit = lit;
82 res.binary.binary = true;
84 return res;
85}
86
87static inline watch kissat_large_watch (reference ref) {
88 watch res;
89 res.large.ref = ref;
90 res.large.binary = false;
92 return res;
93}
94
95static inline watch kissat_blocking_watch (unsigned lit) {
96 watch res;
97 res.blocking.lit = lit;
98 res.blocking.binary = false;
100 return res;
101}
102
103#define EMPTY_WATCHES(W) kissat_empty_vector (&W)
104#define SIZE_WATCHES(W) kissat_size_vector (&W)
105
106#define PUSH_WATCHES(W, E) \
107 do { \
108 KISSAT_assert (sizeof (E) == sizeof (unsigned)); \
109 kissat_push_vectors (solver, &(W), (E).raw); \
110 } while (0)
111
112#define LAST_WATCH_POINTER(WS) \
113 (watch *) kissat_last_vector_pointer (solver, &WS)
114
115#define BEGIN_WATCHES(WS) \
116 ((union watch *) kissat_begin_vector (solver, &(WS)))
117
118#define END_WATCHES(WS) ((union watch *) kissat_end_vector (solver, &(WS)))
119
120#define BEGIN_CONST_WATCHES(WS) \
121 ((union watch *) kissat_begin_const_vector (solver, &(WS)))
122
123#define END_CONST_WATCHES(WS) \
124 ((union watch *) kissat_end_const_vector (solver, &(WS)))
125
126#define RELEASE_WATCHES(WS) kissat_release_vector (solver, &(WS))
127
128#define SET_END_OF_WATCHES(WS, P) \
129 do { \
130 size_t SIZE = (unsigned *) (P) - kissat_begin_vector (solver, &WS); \
131 kissat_resize_vector (solver, &WS, SIZE); \
132 } while (0)
133
134#define REMOVE_WATCHES(W, E) \
135 kissat_remove_from_vector (solver, &(W), (E).raw)
136
137#define WATCHES(LIT) (solver->watches[KISSAT_assert ((LIT) < LITS), (LIT)])
138
139// This iterator is currently only used in 'testreferences.c'.
140//
141#define all_binary_blocking_watch_ref(WATCH, REF, WATCHES) \
142 watch WATCH, \
143 *WATCH##_PTR = (KISSAT_assert (solver->watching), BEGIN_WATCHES (WATCHES)), \
144 *const WATCH##_END = END_WATCHES (WATCHES); \
145 WATCH##_PTR != WATCH##_END && \
146 ((WATCH = *WATCH##_PTR), \
147 (REF = WATCH.type.binary ? INVALID_REF : WATCH##_PTR[1].large.ref), \
148 true); \
149 WATCH##_PTR += 1u + !WATCH.type.binary
150
151#define all_binary_blocking_watches(WATCH, WATCHES) \
152 watch WATCH, \
153 *WATCH##_PTR = (KISSAT_assert (solver->watching), BEGIN_WATCHES (WATCHES)), \
154 *const WATCH##_END = END_WATCHES (WATCHES); \
155 WATCH##_PTR != WATCH##_END && ((WATCH = *WATCH##_PTR), true); \
156 WATCH##_PTR += 1u + !WATCH.type.binary
157
158#define all_binary_large_watches(WATCH, WATCHES) \
159 watch WATCH, \
160 *WATCH##_PTR = \
161 (KISSAT_assert (!solver->watching), BEGIN_WATCHES (WATCHES)), \
162 *const WATCH##_END = END_WATCHES (WATCHES); \
163 WATCH##_PTR != WATCH##_END && ((WATCH = *WATCH##_PTR), true); \
164 ++WATCH##_PTR
165
166void kissat_remove_binary_watch (struct kissat *, watches *, unsigned);
168
170 watch dst);
171
172void kissat_flush_all_connected (struct kissat *);
173void kissat_flush_large_watches (struct kissat *);
174void kissat_watch_large_clauses (struct kissat *);
176
178
180
181#endif
#define ABC_NAMESPACE_HEADER_END
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
#define STACK(TYPE)
Definition stack.h:10
#define KISSAT_assert(ignore)
Definition global.h:13
unsigned short ref
Definition giaNewBdd.h:38
ABC_NAMESPACE_HEADER_START typedef unsigned reference
Definition reference.h:9
int lit
Definition satVec.h:130
unsigned lits[2]
Definition watch.h:65
unsigned lits[3]
Definition watch.h:69
unsigned lit
Definition watch.h:60
watch watch
Definition watch.h:61
Definition watch.h:41
unsigned raw
Definition watch.h:46
blocking_watch blocking
Definition watch.h:44
large_watch large
Definition watch.h:45
watch_type type
Definition watch.h:42
binary_watch binary
Definition watch.h:43
void kissat_watch_large_clauses(struct kissat *)
Definition watch.c:145
void kissat_flush_all_connected(struct kissat *)
Definition watch.c:104
void kissat_flush_large_watches(struct kissat *)
Definition watch.c:112
void kissat_flush_large_connected(struct kissat *)
Definition watch.c:206
void kissat_substitute_large_watch(struct kissat *, watches *, watch src, watch dst)
Definition watch.c:83
void kissat_connect_irredundant_large_clauses(struct kissat *)
Definition watch.c:171
void kissat_remove_binary_watch(struct kissat *, watches *, unsigned)
Definition watch.c:8
void kissat_remove_blocking_watch(struct kissat *, watches *, reference)
Definition watch.c:46
struct binary_tagged_literal watch_type
Definition watch.h:16
vector watches
Definition watch.h:49
struct binary_tagged_reference large_watch
Definition watch.h:19
struct binary_tagged_literal binary_watch
Definition watch.h:17
struct binary_tagged_literal blocking_watch
Definition watch.h:18