Skip to content
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

Add llvm_ffi_setup command #1940

Merged
merged 40 commits into from
Oct 5, 2023
Merged

Add llvm_ffi_setup command #1940

merged 40 commits into from
Oct 5, 2023

Conversation

qsctr
Copy link
Contributor

@qsctr qsctr commented Sep 16, 2023

Add the llvm_ffi_setup command, which generates a LLVMSetup spec that can be used to verify a Cryptol foreign function implementation in LLVM against its reference Cryptol specification.

The code supports all Cryptol types that are supported by the Cryptol FFI, with the exception of Integer, Rational, and Z, since those use gmp which would be hard for SAW to handle without additional overrides. Support for Cryptol floating point types is implemented here, but remains unimplemented in SAW Core (#1237), so we can generate the spec for floating point types but llvm_verify won't be able to actually do the verification.

Two integration tests are included: test_ffi_verify extends the Cryptol FFI test suite's test-ffi module with Cryptol implementations for most foreign functions, and verifies them with llvm_ffi_setup and llvm_verify. test_ffi_verify_salsa is a more nontrivial test which verifies djb's Salsa20 reference implementation, as a Cryptol foreign function, against the spec from cryptol-specs, similar to @WeeknightMVP's example.

See the manual for more documentation.

Closes #1842.

TODO:

  • Bit
  • machine-size bitvectors
  • any bitvector <= 64 bits
  • flat arrays
  • multidimensional arrays
  • tuples
  • records
  • size polymorphism
  • llvm_ffi_verify
  • documentation

@qsctr qsctr added the type: enhancement Issues describing an improvement to an existing feature or capability label Sep 16, 2023
@qsctr qsctr self-assigned this Sep 16, 2023
@RyanGlScott RyanGlScott mentioned this pull request Sep 22, 2023
@qsctr qsctr marked this pull request as ready for review September 28, 2023 16:28
@qsctr qsctr changed the title Add llvm_ffi_setup command Add llvm_ffi_setup and llvm_ffi_verify Oct 2, 2023
@qsctr
Copy link
Contributor Author

qsctr commented Oct 3, 2023

@andreistefanescu doesn't want to add llvm_ffi_verify because it increases the number of built in commands implemented in Haskell, so I am removing it. I put the code on a branch llvm_ffi_verify in case it ever ends up being useful for something.

@qsctr qsctr changed the title Add llvm_ffi_setup and llvm_ffi_verify Add llvm_ffi_setup command Oct 3, 2023
Copy link
Contributor

@andreistefanescu andreistefanescu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@qsctr qsctr added the PR: ready to merge Magic flag for pull requests to ask Mergify to merge given an approval and a successful CI run label Oct 5, 2023
@mergify mergify bot merged commit 3d16d6d into master Oct 5, 2023
40 checks passed
@mergify mergify bot deleted the ffi-verify branch October 5, 2023 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: ready to merge Magic flag for pull requests to ask Mergify to merge given an approval and a successful CI run type: enhancement Issues describing an improvement to an existing feature or capability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add SAW command to simplify verification of FFI functions
2 participants