-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Heapster array field implications (#1459)
* fixed the IRT description generation to match the recent change that made the translation of bitvector permissions to just be bitvectors * updated xor_swap_rust example to use the Rust type in the SAW script * added a case to the Rust to Heapster translator to handle function types with no return value * whoops, forgot to update the bitcode file for xor_swap_rust * bugfix in the Rust to Heapster translator: empty return types need to be converted to unit, not to the empty struct * tweaked the error message for when Rust types do not translate correctly to the expected LLVM type * started adding support for string literals by moving all creation of a HeapsterEnv into a single function which iterates through the globals and adds those it can handle * added a formatting example in Rust, and started defining the necessary types for it * started trying to figure out how Rust stores string literals in its generated LLVM files * fixed the prtty-printing for constant values * changed TrueEnum::fmt to use the fmt method rather than the write! macro * whoops, changed the fmt method for TrueEnum back to using the write! macro, because that seems to be the proper way to do things * whoops, forgot to add the repr(u64) pragma to the TrueEnum type * added a type-checking command for TrueEnum::fmt * moved some OpenTerm operators from SAWTranslation.hs to OpenTerm.hs * added llvmReadBlockOfShape * more work trying to translate globals * got string literals translated, but now there is some translation bug... * whoops, translating a shape always yields exactly one term * added helper function exprLLVMTypeBytes * added support for Rust slice types * whoops, combined the two cases for translating shared vs mutable references into one * updated funPerm3FromArgLayout to handle layouts with existential permissions * updated the rust_data example to use string literals * added mapM and mapBVVecM * added support for proving array permissions from other array permissions with different fields using the SImpl_LLVMArrayContents rule; to get the translation of the SImpl_LLVMArrayContents to work correctly, I had to change local implications to not use strict tuples, which in turn required changing the translation of lowned permissions (which are themselves local implications) to not use strict tuples as well * added more definitions to the arrays example now that the implication prover can map array permission contents * moved the LLVM globals code to a new file LLVMGlobalConst.hs * fixed the translation of LLVM array constants to generate SAW core BVVecs instead of SAW core Vecs * regenerated Coq files for saw-core-coq * added support for the Crucible BVZext and BVTrunc instructions, and fixed up that for BVSext * added heapster_init_env_debug and heapster_init_env_from_file_debug commands * small tweaks to rust_data.saw to get it to work * added another formatting example that we cannot handle yet... * RecurseFlag to Permissions.hs; added requireNamedPerm * widening now unfolds defined and recursive permissions * whoops, forgot to insert a bindM into the translation of SImpl_LLVMArrayContents * removed the old gen_block_perms hints that are no longer used anyway from arrays.saw * changed tupleTypeTrans to no longer having the trailing unit type on tuples of 2 or more types; updated foldList and unfoldList in the SAW core Prelude to fit this new approach; regenerated the resulting Coq files * small tweak to the expression type-checker to type-check the bodies of existential shapes as arbitrary expressions * expanded the translation of Rust slices to allow multiple fields * updated mbox proof script to work with the recent changes, though not all the mbox proofs work... * started updating the mbox proofs, but I got stuck... * moved formatting-related types in the rust_data example to their own section * finished updating mbox proofs * updated examples to match the change to the SAW translation * updated the IRT translation to match the updates to the SAW translation
- Loading branch information
Eddy Westbrook
authored
Sep 17, 2021
1 parent
55ca13b
commit fc74c6a
Showing
21 changed files
with
557 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,28 @@ | ||
enable_experimental; | ||
env <- heapster_init_env_from_file "arrays.sawcore" "arrays.bc"; | ||
|
||
heapster_typecheck_fun env "contains0_rec_" "(len:bv 64).arg0:eq(llvmword(len)), arg1:array(0,<len,*8,[(W,0) |-> exists z:bv 64.eq(llvmword(z))]), arg2:(exists z:bv 64.eq(llvmword(z))) -o arg0:true, arg1:array(0,<len,*8,[(W,0) |-> exists z:bv 64.eq(llvmword(z))]), arg2:true, ret:exists z:(bv 64).eq(llvmword(z))"; | ||
heapster_define_perm env "int64" " " "llvmptr 64" "exists x:bv 64.eq(llvmword(x))"; | ||
heapster_define_perm env "int8" " " "llvmptr 8" "exists x:bv 8.eq(llvmword(x))"; | ||
|
||
heapster_define_perm env "int64array" "len:bv 64" "llvmptr 64" "array(0,<len,*8,[(W,0) |-> int64<>])"; | ||
|
||
|
||
heapster_typecheck_fun env "contains0_rec_" "(len:bv 64).arg0:eq(llvmword(len)), arg1:int64array<len>, arg2:int64<> -o arg0:true, arg1:int64array<len>, arg2:true, ret:int64<>"; | ||
|
||
// the old way using a block entry hint | ||
// heapster_define_perm env "int64" " " "llvmptr 64" "exists x:bv 64.eq(llvmword(x))"; | ||
// heapster_block_entry_hint env "contains0" 9 "top0:bv 64, top1:llvmptr 64, top2:llvmptr 64" "frm:llvmframe 64, x0:llvmptr 64, x1:llvmptr 64" "top0:true, top1:array(0,<top0,*1,[(W,0) |-> int64<>]), top2:eq(llvmword(top0)), arg0:ptr((W,0) |-> true), arg1:ptr((W,0) |-> eq(x1)), arg2:ptr((W,0) |-> eq(x0)), arg3:ptr((W,0) |-> int64<>), frm:llvmframe [arg3:8, arg2:8, arg1:8, arg0:8], x0:eq(top2), x1:eq(top1)"; | ||
// heapster_typecheck_fun env "contains0" "(len:bv 64).arg0:array(0,<len,*1,[(W,0) |-> int64<>]), arg1:eq(llvmword(len)) -o arg0:array(0,<len,*1,[(W,0) |-> int64<>]), arg1:true, ret:int64<>"; | ||
|
||
// the new way using a gen perms hint | ||
heapster_gen_block_perms_hint env "contains0" []; // Note that we could give specific block numbers here (e.g. [9]), but giving nothing will just add a hint to every block, which works just fine for this function. | ||
heapster_typecheck_fun env "contains0" "(len:bv 64).arg0:array(0,<len,*8,[(W,0) |-> exists z:bv 64.eq(llvmword(z))]), arg1:eq(llvmword(len)) -o arg0:array(0,<len,*8,[(W,0) |-> exists z:bv 64.eq(llvmword(z))]), arg1:true, ret:exists z:(bv 64).eq(llvmword(z))"; | ||
heapster_typecheck_fun env "contains0" "(len:bv 64).arg0:int64array<len>, arg1:eq(llvmword(len)) -o arg0:int64array<len>, arg1:true, ret:int64<>"; | ||
|
||
// the new way using a gen perms hint | ||
heapster_gen_block_perms_hint env "zero_array" []; | ||
heapster_typecheck_fun env "zero_array" "(len:bv 64).arg0:array(0,<len,*8,[(W,0) |-> exists z:bv 64.eq(llvmword(z))]), arg1:eq(llvmword(len)) -o arg0:array(0,<len,*8,[(W,0) |-> exists z:bv 64.eq(llvmword(z))]), arg1:true, ret:true"; | ||
heapster_typecheck_fun env "zero_array" "(len:bv 64).arg0:int64array<len>, arg1:eq(llvmword(len)) -o arg0:int64array<len>, arg1:true, ret:true"; | ||
|
||
heapster_gen_block_perms_hint env "zero_array_from" []; | ||
heapster_typecheck_fun env "zero_array_from" "(len:bv 64, off:bv 64).arg0:array(0,<len,*8,[(W,0) |-> exists z:bv 64.eq(llvmword(z))]), arg1:eq(llvmword(len)), arg2:eq(llvmword(off)) -o arg0:array(0,<len,*8,[(W,0) |-> exists z:bv 64.eq(llvmword(z))]), arg1:true, ret:true"; | ||
heapster_typecheck_fun env "zero_array_from" "(len:bv 64, off:bv 64).arg0:int64array<len>, arg1:eq(llvmword(len)), arg2:eq(llvmword(off)) -o arg0:int64array<len>, arg1:true, ret:true"; | ||
|
||
heapster_gen_block_perms_hint env "filter_and_sum_pos" []; | ||
heapster_join_point_hint env "filter_and_sum_pos" []; | ||
heapster_typecheck_fun env "filter_and_sum_pos" "(len:bv 64).arg0:array(0,<len,*8,[(W,0) |-> exists z:bv 64.eq(llvmword(z))]), arg1:eq(llvmword(len)) -o arg0:array(0,<len,*8,[(W,0) |-> exists z:bv 64.eq(llvmword(z))]), arg1:true, ret:exists x:bv 64.eq(llvmword(x))"; | ||
heapster_typecheck_fun env "filter_and_sum_pos" "(len:bv 64).arg0:int64array<len>, arg1:eq(llvmword(len)) -o arg0:int64array<len>, arg1:true, ret:int64<>"; | ||
|
||
heapster_gen_block_perms_hint env "sum_2d" []; | ||
heapster_typecheck_fun env "sum_2d" "(l1:bv 64,l2:bv 64).arg0:array(0,<l1,*8,[(W,0) |-> array(0,<l2,*8,[(W,0) |-> exists z:bv 64.eq(llvmword(z))])]), arg1:eq(llvmword(l1)), arg2:eq(llvmword(l2)) -o arg0:array(0,<l1,*8,[(W,0) |-> array(0,<l2,*8,[(W,0) |-> exists z:bv 64.eq(llvmword(z))])]), arg1:true, arg2:true, ret:exists x:bv 64.eq(llvmword(x))"; | ||
heapster_typecheck_fun env "sum_2d" "(l1:bv 64,l2:bv 64).arg0:array(0,<l1,*8,[(W,0) |-> array(0,<l2,*8,[(W,0) |-> exists z:bv 64.eq(llvmword(z))])]), arg1:eq(llvmword(l1)), arg2:eq(llvmword(l2)) -o arg0:array(0,<l1,*8,[(W,0) |-> array(0,<l2,*8,[(W,0) |-> exists z:bv 64.eq(llvmword(z))])]), arg1:true, arg2:true, ret:int64<>"; | ||
|
||
heapster_export_coq env "arrays_gen.v"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.