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

saw-core-sbv: Handle zero-width bitvectors properly in counterexamples. #1278

Merged
merged 1 commit into from
May 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion saw-core-sbv/src/Verifier/SAW/Simulator/SBV.hs
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ data Labeler
= BoolLabel String
| IntegerLabel String
| WordLabel String
| ZeroWidthWordLabel
| VecLabel (Vector Labeler)
| TupleLabel (Vector Labeler)
| RecLabel (Map FieldName Labeler)
Expand All @@ -684,7 +685,7 @@ newVars FOTInt = nextId <&> \s-> (IntegerLabel s, vInteger <$> existsSInteger s)
newVars (FOTIntMod n) = nextId <&> \s-> (IntegerLabel s, VIntMod n <$> existsSInteger s)
newVars (FOTVec n FOTBit) =
if n == 0
then nextId <&> \s-> (WordLabel s, return (vWord (literalSWord 0 0)))
then pure (ZeroWidthWordLabel, pure (vWord (literalSWord 0 0)))
else nextId <&> \s-> (WordLabel s, vWord <$> existsSWord s (fromIntegral n))
newVars (FOTVec n tp) = do
(labels, vals) <- V.unzip <$> V.replicateM (fromIntegral n) (newVars tp)
Expand Down Expand Up @@ -718,6 +719,8 @@ getLabels ls d args
getLabel (WordLabel s) = FOVWord (cvKind cv) (cvToInteger cv)
where cv = d Map.! s

getLabel ZeroWidthWordLabel = FOVWord 0 0

getLabel (VecLabel ns)
| V.null ns = error "getLabel of empty vector"
| otherwise = fovVec t vs
Expand Down