macaw-x86-symbolic
: Fix idiv
/div
semantics
#394
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When converting a Macaw value with the Macaw type
TupleType [x_1, ..., x_n]
to Crucible, the resulting Crucible value will have the Crucible typeStructType (EmptyCtx ::> ToCrucibleType x_n ::> ... ::> ToCrucibleType x_1)
. (SeemacawListToCrucible(M)
inData.Macaw.Symbolic.PersistentState
for where this is implemented.) Note that the order of the tuple's fields is reversed in the process of converting it to a Crucible struct. This is a convention that one must keep in mind when dealing with Macaw tuples at the Crucible level.As it turns out, the part of
macaw-x86-symbolic
reponsible for interpreting the semantics of theidiv
instruction (for signed quotient/remainder) and thediv
instruction (for unsigned quotient/remainder) were not respecting this convention. This is because themacaw-x86-symbolic
semantics were returning a Crucible struct consisting ofEmpty :> quotient :> remainder)
, but at the Macaw level, this was interpreted as the tuple(remainder, quotient)
, which is the opposite of the intended order. This led to subtle bugs such as those observed in #393.The solution is straightforward: have the
macaw-x86-symbolic
semantics computeEmpty :> remainder :> quotient
instead. Somewhat counterintuitive, but it does work.Fixes #393.