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

sail model: removing uses of unbounded integers/bitvectors #6

Open
aa755 opened this issue Jul 13, 2020 · 2 comments
Open

sail model: removing uses of unbounded integers/bitvectors #6

aa755 opened this issue Jul 13, 2020 · 2 comments

Comments

@aa755
Copy link

aa755 commented Jul 13, 2020

It should be possible to write an equivalent model, say machine-word-based-model, where only machine words are used.
The equivalence can be proved by proving functional equivalence of the decode64 functions generated in Coq/isabelle by translating the official model (uses unbounded integers and bitvectors) and the machine-word-based-model model.
How hard would it be to do this? Would the say machine-word-based-model be much more complex?
Doing all this would also provide better C emulators: currently the C translation tries replace unbounded data by machine words, but does not always succeed.

@Alasdair
Copy link
Contributor

Alasdair commented Jul 28, 2020

Proving equivalence might be quite tricky. Although I do have some symbolic execution infrastructure that could maybe be used to do that if there was a version with only machine words and one without. I haven't thought about it too much, but I guess the way to go would be to use some kind of abstract-interpretation like approach to infer the maximum width for all integer variables working down starting with the decode functions. It'd probably be quite a lot of work to set that up, and we don't have anyone working on it.

The ARM ASL specification is itself written in terms of unbounded-precision integers and variable-width bitvectors, and we've mostly tried to do a fairly one-to-one translation from their specification - that's where all the unbounded-precision parts come from. The current approach is to just try to optimize where possible, we have some peephole style optimizations for the common cases and primitives, and there's also an additional monomorphization step that will turn length-polymorphic functions into multiple functions that then allows more of those optimizations to take place (but I don't think that's enabled by default as it's very slow). I also had an option to use clang and gcc's 128-bit integers rather than GMP integers which was a pretty big performance win, although it might be unsound in general if anything actually requires more bits than that.

@bacam
Copy link
Contributor

bacam commented Jul 29, 2020

We might be able to get upper bounds on bitvector widths from Z3's optimization facilities, and if so it would fit in much more nicely with the current Sail tooling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants