-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bitfield Domain #1623
base: master
Are you sure you want to change the base?
Bitfield Domain #1623
Changes from 168 commits
9b0002f
582630c
3042aae
a609f3d
696c110
0630662
fd89907
8a91829
5c0fdbb
087d4a9
0116023
03961c0
d42b989
6a26669
05b3d8e
27c9876
ca7c040
1338d65
447db3d
3a00c0b
89294a9
c78510b
ec166cb
1adccde
2e05197
897d6a2
7d5913a
257cc5b
24b3719
cbfbf28
87b0189
ff8c4c7
d405853
ffc7285
5ec64ad
8cd7e62
a31dc67
28d9db0
6177b13
8e8b9cb
ed56bd8
9ae2b8f
874e1ed
5ce8db7
4170f7f
cd1bd06
5eafd97
811590d
6999a20
9f72163
c660277
146d858
55bc2b3
90e1e99
6a32e42
47b7a56
5606e67
8b1fbfc
4bf31cc
0b4b4a1
15520a8
d55eab5
6562161
2aa27f8
ad5f6f8
cfa0091
98a2d24
5914695
4a542be
15f7abe
f9f7fce
1b6459d
31def4b
2ba8f38
b6762af
b6ee7fa
a933c4e
e2366ff
addda52
29bcca1
7984a0a
ed1999a
7fa0100
96e5737
90338a7
f25a578
e9286e7
3e4928a
9bcd884
6fe1162
5301322
0fa8ca7
bad0bb8
abde7e4
937b341
ddfaace
24f305f
7c4411d
6c2c570
f237a9e
e4eefd9
8d4a4b8
8d7faf9
e2568fd
ccb13c1
88b0dfc
86fdeb5
60fbbf5
ed27d3d
58eeeb4
dbe2e00
810a966
d7b8755
541a87d
686633a
4b3a0f8
dee9036
d6e3f61
e3145ad
6c720b8
f09ead4
8b53b08
c682527
7a8b3ad
8cf7192
79a859a
bfe5dc6
ed56056
f40fefb
e1d948d
57ac94a
6c7f899
313adb8
ee9f358
288bf0d
306aa33
3862f2e
b683875
26a23f5
f70838d
2e85cc9
898a68e
0cc16dc
65237fd
5cf4620
dc68f48
312b0c3
3034ad3
1f08a87
552c333
571cde3
18ee9a9
51c13e7
e7c3237
1376824
abb48c4
dbe3f54
8bd36ce
6ecd41e
5ba10f8
54856e0
da57955
b54ca80
7dcec4c
89ff69b
cf7b349
1d78b29
4fe0097
767f998
821be43
a1807b6
0a55d08
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -395,27 +395,55 @@ struct | |
| Le, Some false -> meet_bin (ID.starting ikind (Z.succ l2)) (ID.ending ikind (Z.pred u1)) | ||
| _, _ -> a, b) | ||
| _ -> a, b) | ||
| BOr | BXor as op-> | ||
if M.tracing then M.tracel "inv" "Unhandled operator %a" d_binop op; | ||
| BOr -> | ||
(* Be careful: inv_exp performs a meet on both arguments of the BOr / BXor. *) | ||
a, b | ||
if PrecisionUtil.get_bitfield () then | ||
let a', b' = ID.meet a (ID.logand a c), ID.meet b (ID.logand b c) in | ||
let (cz, co) = ID.to_bitfield ikind c in | ||
let (az, ao) = ID.to_bitfield ikind a' in | ||
let (bz, bo) = ID.to_bitfield ikind b' in | ||
let cDef1 = Z.logand co (Z.lognot cz) in | ||
let aDef0 = Z.logand az (Z.lognot ao) in | ||
let bDef0 = Z.logand bz (Z.lognot bo) in | ||
let az = Z.logand az (Z.lognot (Z.logand bDef0 cDef1)) in | ||
let bz = Z.logand bz (Z.lognot (Z.logand aDef0 cDef1)) in | ||
ID.meet a' (ID.of_bitfield ikind (az, ao)), ID.meet b' (ID.of_bitfield ikind (bz, bo)) | ||
else a, b | ||
| BXor -> | ||
(* Be careful: inv_exp performs a meet on both arguments of the BOr / BXor. *) | ||
if PrecisionUtil.get_bitfield () then | ||
let a' = ID.meet a (ID.logxor c b) | ||
in let b' = ID.meet b (ID.logxor a c) | ||
Comment on lines
+415
to
+416
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please change to use standard indentation. let ... = ... in |
||
in a', b' | ||
else a,b | ||
| LAnd -> | ||
if ID.to_bool c = Some true then | ||
meet_bin c c | ||
else | ||
a, b | ||
| BAnd as op -> | ||
| BAnd -> | ||
(* we only attempt to refine a here *) | ||
let a = | ||
match ID.to_int b with | ||
| Some x when Z.equal x Z.one -> | ||
(match ID.to_bool c with | ||
| Some true -> ID.meet a (ID.of_congruence ikind (Z.one, Z.of_int 2)) | ||
| Some false -> ID.meet a (ID.of_congruence ikind (Z.zero, Z.of_int 2)) | ||
| None -> if M.tracing then M.tracel "inv" "Unhandled case for operator x %a 1 = %a" d_binop op ID.pretty c; a) | ||
| _ -> if M.tracing then M.tracel "inv" "Unhandled case for operator x %a %a = %a" d_binop op ID.pretty b ID.pretty c; a | ||
| None -> a) | ||
| _ -> a | ||
Comment on lines
+432
to
+433
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tracing output should still be produced if bitfield is off. |
||
in | ||
a, b | ||
if PrecisionUtil.get_bitfield () then | ||
let a', b' = ID.meet a (ID.logor a c), ID.meet b (ID.logor b c) in | ||
let (cz, co) = ID.to_bitfield ikind c in | ||
let (az, ao) = ID.to_bitfield ikind a' in | ||
let (bz, bo) = ID.to_bitfield ikind b' in | ||
let cDef0 = Z.logand cz (Z.lognot co) in | ||
let aDef1 = Z.logand ao (Z.lognot az) in | ||
let bDef1 = Z.logand bo (Z.lognot bz) in | ||
let ao = Z.logand ao (Z.lognot (Z.logand bDef1 cDef0)) in | ||
let bo = Z.logand bo (Z.lognot (Z.logand aDef1 cDef0)) in | ||
ID.meet a' (ID.of_bitfield ikind (az, ao)), ID.meet b' (ID.of_bitfield ikind (bz, bo)) | ||
else a, b | ||
Comment on lines
+435
to
+446
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||
| op -> | ||
if M.tracing then M.tracel "inv" "Unhandled operator %a" d_binop op; | ||
a, b | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should most of these computations not be moved inside your domain? (After getting the bitfields).
This works on the internal representation of these bitfield things, so maybe should be in there. Granted, the intervals also leak outside of their domain,but people intuitively understand how they work.
Also, please leave some comment here about what happens. One can puzzle it together, but it took @DrMichaelPetter and me about 10 mins yesterday to do so.