@@ -55,17 +55,36 @@ ASTVec c3_bitblast_neg(ASTVec vec) {
55
55
56
56
static ASTNode * c3_bitblast_bvle (ASTVec left , ASTVec right , bool sign , bool bvlt ) {
57
57
C3ListIter * lit , * rit ;
58
- lit = left -> tail ;
59
- rit = right -> tail ;
60
- return NULL ;
58
+ ASTNode * prevbit = bb -> ASTTrue ;
59
+ lit = left -> head ;
60
+ rit = right -> head ;
61
+ while (lit -> n != left -> tail ) {
62
+ ASTNode * lnode = (ASTNode * )lit -> data ;
63
+ ASTNode * rnode = (ASTNode * )rit -> data ;
64
+ ASTNode * thisbit = ast_create_node3 (ITE , ast_create_node2 (IFF , rnode , lnode ), prevbit , rnode );
65
+ prevbit = thisbit ;
66
+ lit = lit -> n ;
67
+ rit = rit -> n ;
68
+ }
69
+ ASTNode * lmsb = (ASTNode * )lit -> data ;
70
+ ASTNode * rmsb = (ASTNode * )lit -> data ;
71
+ if (sign ) {
72
+ lmsb = ast_create_node1 (NOT , lmsb );
73
+ rmsb = ast_create_node1 (NOT , rmsb );
74
+ }
75
+ ASTNode * msb = ast_create_node3 (ITE , ast_create_node2 (IFF , rmsb , lmsb ), prevbit , rmsb );
76
+ if (bvlt ) {
77
+ msb = ast_create_node1 (NOT , msb );
78
+ }
79
+ return msb ;
61
80
}
62
81
63
82
ASTNode * c3_bitblast_cmp (ASTNode * form ) {
64
83
ASTNode * result ;
65
84
ASTVec children = form -> children ;
66
85
ASTVec left = c3_bitblast_term ((ASTNode * )children -> head -> data );
67
86
ASTVec right = c3_bitblast_term ((ASTNode * )children -> head -> n -> data );
68
- const ASTKind k = form -> kind ;
87
+ const ASTKind k = ast_get_kind ( form ) ;
69
88
switch (k ) {
70
89
case BVLE :
71
90
{
@@ -99,12 +118,13 @@ ASTNode *c3_bitblast_cmp(ASTNode *form) {
99
118
}
100
119
case BVSGT :
101
120
{
102
- // result = c3_bitblast_bvle (right, left, true , true);
121
+ result = ast_create_node1 ( NOT , c3_bitblast_bvle ( left , right , true, false) );
103
122
break ;
104
123
}
105
124
case BVSLT :
106
125
{
107
- //result = c3_bitblast_bvle (left, right, true, true);
126
+ //result = ast_create_node1 (NOT, c3_bitblast_bvle (right, left, true, false));
127
+ result = form ;
108
128
break ;
109
129
}
110
130
default :
@@ -114,7 +134,7 @@ ASTNode *c3_bitblast_cmp(ASTNode *form) {
114
134
}
115
135
116
136
ASTVec c3_bitblast_term (ASTNode * term ) {
117
- const ASTKind k = term -> kind ;
137
+ const ASTKind k = ast_get_kind ( term ) ;
118
138
ASTVec children = term -> children , result ;
119
139
unsigned int numbits = term -> value_width ;
120
140
@@ -125,8 +145,17 @@ ASTVec c3_bitblast_term(ASTNode *term) {
125
145
result = c3_bitblast_neg (kids );
126
146
break ;
127
147
}
148
+ case BVSX :
149
+ case BVZX :
150
+ {
151
+ printf ("BVSX¥n" );
152
+ /* TODO: */
153
+ result = term ;
154
+ break ;
155
+ }
128
156
case BVCONST :
129
157
{
158
+ printf ("BVCONST¥n" );
130
159
ASTVec cnts = ast_vec_new ();
131
160
ASTBVConst * bvconst = term -> bvconst ;
132
161
unsigned int i ;
@@ -147,7 +176,7 @@ ASTNode *c3_bitblast_form(ASTNode *form) {
147
176
ASTVec children = form -> children ;
148
177
ASTVec echildren = ast_vec_new ();
149
178
C3ListIter * iter ;
150
- const ASTKind k = form -> kind ;
179
+ const ASTKind k = ast_get_kind ( form ) ;
151
180
152
181
switch (k ) {
153
182
case TRUE:
@@ -172,11 +201,14 @@ ASTNode *c3_bitblast_form(ASTNode *form) {
172
201
case IFF :
173
202
case XOR :
174
203
case IMPLIES :
204
+ {
205
+ printf ("TWO¥n" );
175
206
c3_list_foreach (children , iter , child ) {
176
207
c3_list_append (echildren , c3_bitblast_form (child ));
177
208
}
178
209
result = ast_create_node (k , echildren );
179
210
break ;
211
+ }
180
212
case EQ :
181
213
{
182
214
ASTVec left = c3_bitblast_term ((ASTNode * )children -> head -> data );
@@ -193,6 +225,7 @@ ASTNode *c3_bitblast_form(ASTNode *form) {
193
225
case BVSGT :
194
226
case BVSLT :
195
227
{
228
+ printf ("BVSLT¥n" );
196
229
result = c3_bitblast_cmp (form );
197
230
break ;
198
231
}
0 commit comments