8000 Frontend for bitvectors by jad-hamza · Pull Request #879 · epfl-lara/stainless · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Frontend for bitvectors #879

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

Merged
merged 4 commits into from
Dec 21, 2020
Merged

Frontend for bitvectors #879

merged 4 commits into from
Dec 21, 2020

Conversation

jad-hamza
Copy link
Contributor

@vkuncak @gsps @samarion Any comment in addition to what we discussed?

case TypeRef(_, sym, FrontendBVKind(signed, size) :: Nil) if isBVSym(sym) =>
Some((signed, size))
case TypeRef(_, sym, Nil) if isBVSym(sym) =>
val R = """type (UInt|Int)(\d+)""".r
Copy link
Contributor

Choose a reason for hiding this comment

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

You could avoid recreating this regex on every unapply call.

Copy link
Contributor

Choose a reason for hiding this comment

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

This will probably be called quite often from extractType, since the vast majority of types will be TypeRefs, I think. Not sure if it actually makes a difference, but for TupleSymbol we have a dedicated cache. That being said, I'm not sure the way we're caching there is ideal either. We also store all the negative results, which means that map is going to be very large with a super low hit rate. Ideally we'd actually enumerate all relevant symbols upfront and put them in the map, then only check for membership during CodeExtraction.

object FrontendBVKind {
def unapply(tpe: Type): Option[(Boolean, Int)] = tpe match {
case SingleType(_, sym) =>
val R = """object ([ui])(\d+)""".r
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

Copy link
Contributor
@gsps gsps left a comment

Choose a reason for hiding this comment

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

A few notes on the BVType extractors.

@jad-hamza
Copy link
Contributor Author

Thanks, I've moved the regular expressions outside the unapply calls.

@jad-hamza
Copy link
Contributor Author

I've added widen and narrow operations, and some more examples. There's still no implementation (for Scala compilation), but verification seems to work fine. I'll merge if there is no objection (and if bot is happy)!

case (StrictBVType(_, _), "<<", Seq(rhs)) => xt.BVShiftLeft(extractTree(lhs), extractTree(rhs))
case (StrictBVType(_, _), ">>", Seq(rhs)) => xt.BVAShiftRight(extractTree(lhs), extractTree(rhs))
case (StrictBVType(_, _), ">>>", Seq(rhs)) => xt.BVLShiftRight(extractTree(lhs), extractTree(rhs))
case (StrictBVType(_, _), "unary_-", Seq()) => xt.UMinus(extractTree(lhs))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to des 8000 cribe this comment to others. Learn more.

Not sure this new case is actually reachable. Might be caught here before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No it was missed, but perhaps I could adjust the extractor so that it can catch it.

@gsps
Copy link
Contributor
gsps commented Dec 21, 2020

👍 apart from the small comment

@jad-hamza jad-hamza merged commit 0ebb001 into epfl-lara:master Dec 21, 2020
@jad-hamza jad-hamza deleted the more-bv branch December 21, 2020 14:37
@jad-hamza
Copy link
Contributor Author

Merged, thanks!

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

Successfully merging this pull request may close these issues.

2 participants
0