-
Notifications
You must be signed in to change notification settings - Fork 0
/
bv.wrap.go
598 lines (552 loc) · 13.5 KB
/
bv.wrap.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
// Generated by genwrap.go. DO NOT EDIT
package z3
import "runtime"
/*
#cgo LDFLAGS: -lz3
#include <z3.h>
#include <stdlib.h>
*/
import "C"
// Eq returns a Value that is true if l and r are equal.
func (l BV) Eq(r BV) Bool {
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_eq(ctx.c, l.c, r.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(r)
return Bool(val)
}
// NE returns a Value that is true if l and r are not equal.
func (l BV) NE(r BV) Bool {
return l.ctx.Distinct(l, r)
}
// Not returns the bit-wise negation of l.
func (l BV) Not() BV {
// Generated from bv.go:117.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bvnot(ctx.c, l.c)
})
runtime.KeepAlive(l)
return BV(val)
}
// AllBits returns a 1-bit bit-vector that is the bit-wise "and" of
// all bits.
func (l BV) AllBits() BV {
// Generated from bv.go:122.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bvredand(ctx.c, l.c)
})
runtime.KeepAlive(l)
return BV(val)
}
// AnyBits returns a 1-bit bit-vector that is the bit-wise "or" of all
// bits.
func (l BV) AnyBits() BV {
// Generated from bv.go:127.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bvredor(ctx.c, l.c)
})
runtime.KeepAlive(l)
return BV(val)
}
// And returns the bit-wise and of l and r.
//
// l and r must have the same size.
func (l BV) And(r BV) BV {
// Generated from bv.go:133.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bvand(ctx.c, l.c, r.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(r)
return BV(val)
}
// Or returns the bit-wise or of l and r.
//
// l and r must have the same size.
func (l BV) Or(r BV) BV {
// Generated from bv.go:139.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bvor(ctx.c, l.c, r.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(r)
return BV(val)
}
// Xor returns the bit-wise xor of l and r.
//
// l and r must have the same size.
func (l BV) Xor(r BV) BV {
// Generated from bv.go:145.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bvxor(ctx.c, l.c, r.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(r)
return BV(val)
}
// Nand returns the bit-wise nand of l and r.
//
// l and r must have the same size.
func (l BV) Nand(r BV) BV {
// Generated from bv.go:151.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bvnand(ctx.c, l.c, r.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(r)
return BV(val)
}
// Nor returns the bit-wise nor of l and r.
//
// l and r must have the same size.
func (l BV) Nor(r BV) BV {
// Generated from bv.go:157.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bvnor(ctx.c, l.c, r.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(r)
return BV(val)
}
// Xnor returns the bit-wise xnor of l and r.
//
// l and r must have the same size.
func (l BV) Xnor(r BV) BV {
// Generated from bv.go:163.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bvxnor(ctx.c, l.c, r.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(r)
return BV(val)
}
// Neg returns the two's complement negation of l.
func (l BV) Neg() BV {
// Generated from bv.go:167.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bvneg(ctx.c, l.c)
})
runtime.KeepAlive(l)
return BV(val)
}
// Add returns the two's complement sum of l and r.
//
// l and r must have the same size.
func (l BV) Add(r BV) BV {
// Generated from bv.go:173.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bvadd(ctx.c, l.c, r.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(r)
return BV(val)
}
// Sub returns the two's complement subtraction l minus r.
//
// l and r must have the same size.
func (l BV) Sub(r BV) BV {
// Generated from bv.go:179.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bvsub(ctx.c, l.c, r.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(r)
return BV(val)
}
// Mul returns the two's complement product of l and r.
//
// l and r must have the same size.
func (l BV) Mul(r BV) BV {
// Generated from bv.go:185.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bvmul(ctx.c, l.c, r.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(r)
return BV(val)
}
// UDiv returns the floor of l / r, treating l and r as unsigned.
//
// If r is 0, the result is unconstrained.
//
// l and r must have the same size.
func (l BV) UDiv(r BV) BV {
// Generated from bv.go:193.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bvudiv(ctx.c, l.c, r.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(r)
return BV(val)
}
// SDiv returns l / r rounded toward 0, treating l and r as two's
// complement signed numbers.
//
// If r is 0, the result is unconstrained.
//
// l and r must have the same size.
func (l BV) SDiv(r BV) BV {
// Generated from bv.go:202.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bvsdiv(ctx.c, l.c, r.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(r)
return BV(val)
}
// URem returns the unsigned remainder of l divided by r.
//
// l and r must have the same size.
func (l BV) URem(r BV) BV {
// Generated from bv.go:208.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bvurem(ctx.c, l.c, r.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(r)
return BV(val)
}
// SRem returns the two's complement signed remainder of l divided by r.
//
// The sign of the result follows the sign of l.
//
// l and r must have the same size.
func (l BV) SRem(r BV) BV {
// Generated from bv.go:216.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bvsrem(ctx.c, l.c, r.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(r)
return BV(val)
}
// SMod returns the two's complement signed modulus of l divided by r.
//
// The sign of the result follows the sign of r.
//
// l and r must have the same size.
func (l BV) SMod(r BV) BV {
// Generated from bv.go:224.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bvsmod(ctx.c, l.c, r.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(r)
return BV(val)
}
// ULT returns the l < r, where l and r are unsigned.
//
// l and r must have the same size.
func (l BV) ULT(r BV) Bool {
// Generated from bv.go:230.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bvult(ctx.c, l.c, r.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(r)
return Bool(val)
}
// SLT returns the l < r, where l and r are signed.
//
// l and r must have the same size.
func (l BV) SLT(r BV) Bool {
// Generated from bv.go:236.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bvslt(ctx.c, l.c, r.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(r)
return Bool(val)
}
// ULE returns the l <= r, where l and r are unsigned.
//
// l and r must have the same size.
func (l BV) ULE(r BV) Bool {
// Generated from bv.go:242.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bvule(ctx.c, l.c, r.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(r)
return Bool(val)
}
// SLE returns the l <= r, where l and r are signed.
//
// l and r must have the same size.
func (l BV) SLE(r BV) Bool {
// Generated from bv.go:248.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bvsle(ctx.c, l.c, r.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(r)
return Bool(val)
}
// UGE returns the l >= r, where l and r are unsigned.
//
// l and r must have the same size.
func (l BV) UGE(r BV) Bool {
// Generated from bv.go:254.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bvuge(ctx.c, l.c, r.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(r)
return Bool(val)
}
// SGE returns the l >= r, where l and r are signed.
//
// l and r must have the same size.
func (l BV) SGE(r BV) Bool {
// Generated from bv.go:260.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bvsge(ctx.c, l.c, r.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(r)
return Bool(val)
}
// UGT returns the l > r, where l and r are unsigned.
//
// l and r must have the same size.
func (l BV) UGT(r BV) Bool {
// Generated from bv.go:266.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bvugt(ctx.c, l.c, r.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(r)
return Bool(val)
}
// SGT returns the l > r, where l and r are signed.
//
// l and r must have the same size.
func (l BV) SGT(r BV) Bool {
// Generated from bv.go:272.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bvsgt(ctx.c, l.c, r.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(r)
return Bool(val)
}
// Concat returns concatenation of l and r.
//
// The result is a bit-vector whose length is the sum of the lengths
// of l and r.
func (l BV) Concat(r BV) BV {
// Generated from bv.go:279.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_concat(ctx.c, l.c, r.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(r)
return BV(val)
}
// Extract returns bits [high, low] (inclusive) of l, where bit 0 is
// the least significant bit.
func (l BV) Extract(high int, low int) BV {
// Generated from bv.go:284.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_extract(ctx.c, C.unsigned(high), C.unsigned(low), l.c)
})
runtime.KeepAlive(l)
return BV(val)
}
// SignExtend returns l sign-extended to a bit-vector of length m+i,
// where m is the length of l.
func (l BV) SignExtend(i int) BV {
// Generated from bv.go:289.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_sign_ext(ctx.c, C.unsigned(i), l.c)
})
runtime.KeepAlive(l)
return BV(val)
}
// ZeroExtend returns l zero-extended to a bit-vector of length m+i,
// where m is the length of l.
func (l BV) ZeroExtend(i int) BV {
// Generated from bv.go:294.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_zero_ext(ctx.c, C.unsigned(i), l.c)
})
runtime.KeepAlive(l)
return BV(val)
}
// Repeat returns l repeated up to length i.
func (l BV) Repeat(i int) BV {
// Generated from bv.go:298.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_repeat(ctx.c, C.unsigned(i), l.c)
})
runtime.KeepAlive(l)
return BV(val)
}
// Lsh returns l shifted left by i bits.
//
// This is equivalent to l * 2^i.
//
// l and i must have the same size. The result has the same sort.
func (l BV) Lsh(i BV) BV {
// Generated from bv.go:306.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bvshl(ctx.c, l.c, i.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(i)
return BV(val)
}
// URsh returns l logically shifted right by i bits.
//
// This is equivalent to l / 2^i, where l and i are unsigned.
//
// l and i must have the same size. The result has the same sort.
func (l BV) URsh(i BV) BV {
// Generated from bv.go:314.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bvlshr(ctx.c, l.c, i.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(i)
return BV(val)
}
// SRsh returns l arithmetically shifted right by i bits.
//
// This is like URsh, but the sign of the result is the sign of l.
//
// l and i must have the same size. The result has the same sort.
func (l BV) SRsh(i BV) BV {
// Generated from bv.go:322.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bvashr(ctx.c, l.c, i.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(i)
return BV(val)
}
// RotateLeft returns l rotated left by i bits.
//
// l and i must have the same size.
func (l BV) RotateLeft(i BV) BV {
// Generated from bv.go:328.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_ext_rotate_left(ctx.c, l.c, i.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(i)
return BV(val)
}
// RotateRight returns l rotated right by i bits.
//
// l and i must have the same size.
func (l BV) RotateRight(i BV) BV {
// Generated from bv.go:334.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_ext_rotate_right(ctx.c, l.c, i.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(i)
return BV(val)
}
// SToInt converts signed bit-vector l to an integer.
func (l BV) SToInt() Int {
// Generated from bv.go:338.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bv2int(ctx.c, l.c, true)
})
runtime.KeepAlive(l)
return Int(val)
}
// UToInt converts unsigned bit-vector l to an integer.
func (l BV) UToInt() Int {
// Generated from bv.go:342.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_bv2int(ctx.c, l.c, false)
})
runtime.KeepAlive(l)
return Int(val)
}
// IEEEToFloat converts l into a floating-point number, interpreting l
// in IEEE 754-2008 format.
//
// The size of l must equal ebits+sbits of s.
func (l BV) IEEEToFloat(s Sort) Float {
// Generated from bv.go:349.
ctx := l.ctx
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_fpa_to_fp_bv(ctx.c, l.c, s.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(s)
return Float(val)
}
// SToFloat converts signed bit-vector l into a floating-point number.
//
// If necessary, the result will be rounded according to the current
// rounding mode.
func (l BV) SToFloat(s Sort) Float {
// Generated from bv.go:356.
ctx := l.ctx
rm := ctx.rm()
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_fpa_to_fp_signed(ctx.c, rm.c, l.c, s.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(s)
return Float(val)
}
// UToFloat converts unsigned bit-vector l into a floating-point number.
//
// If necessary, the result will be rounded according to the current
// rounding mode.
func (l BV) UToFloat(s Sort) Float {
// Generated from bv.go:363.
ctx := l.ctx
rm := ctx.rm()
val := wrapValue(ctx, func() C.Z3_ast {
return C.Z3_mk_fpa_to_fp_unsigned(ctx.c, rm.c, l.c, s.c)
})
runtime.KeepAlive(l)
runtime.KeepAlive(s)
return Float(val)
}