-
Notifications
You must be signed in to change notification settings - Fork 62
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
mir_array_value
#1925
mir_array_value
#1925
Conversation
-- match arrays point-wise | ||
(MIRVal (ArrayShape _ _ elemShp) xs, Mir.TyArray y _len, MS.SetupArray _elemTy zs) | ||
| Mir.MirVector_Vector xs' <- xs | ||
, V.length xs' == length zs -> | ||
sequence_ | ||
[ matchArg opts sc cc cs prepost md (MIRVal elemShp x) y z | ||
| (x, z) <- zip (V.toList xs') zs ] | ||
|
||
| Mir.MirVector_PartialVector xs' <- xs | ||
, V.length xs' == length zs -> | ||
do xs'' <- liftIO $ | ||
traverse (readMaybeType sym "vector element" (shapeType elemShp)) xs' | ||
sequence_ | ||
[ matchArg opts sc cc cs prepost md (MIRVal elemShp x) y z | ||
| (x, z) <- zip (V.toList xs'') zs ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is how SAW matches array arguments in specifications. Note that MirVector_Array
(for symbolic, SMT-based arrays) aren't supported.
MS.SetupArray elemTy vs -> | ||
pure $ Mir.TyArray elemTy (length vs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is where the type of mir_array_value
s are computed.
In the experimental MIR verification implementation, the following functions | ||
construct compound values: | ||
|
||
* `mir_array_value : MIRType -> [SetupValue] -> SetupValue` constructs an array | ||
of the given type whose elements consist of the given values. Supplying the | ||
element type is necessary to support length-0 arrays. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation
7761c9b
to
f12cdf4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I only looked at the most recent commit because the rest seemed covered by #1919. Let me know if that's not true and I'll go back and review some of the other commits.
f12cdf4
to
9d74cbd
Compare
This adds support for a `mir_array_value` function in the MIR backend, which allows constructing array `SetupValue`s. This largely behaves like `llvm_array_value`s in the LLVM backend, but with the following differences: * Unlike in the LLVM backend, MIR arrays can have length 0. To account for this possibility, `mir_array_value` has a `MIRType` argument to ensure that SAW can always infer the type of the array, even if there are no element values from which to infer the type. Similarly, the SAW remote API's `array()` function now has an optional `element_type` kwarg that can be used to specify the element type in the event that there are no element values. * Because only the MIR backend makes use of the element type, this is encoded in the `XSetupArray` extension field. This checks off one box in #1859.
9d74cbd
to
ca34dbe
Compare
This adds support for a
mir_array_value
function in the MIR backend, which allows constructing arraySetupValue
s. This largely behaves likellvm_array_value
s in the LLVM backend, but with the following differences:Unlike in the LLVM backend, MIR arrays can have length 0. To account for this possibility,
mir_array_value
has aMIRType
argument to ensure that SAW can always infer the type of the array, even if there are no element values from which to infer the type.Similarly, the SAW remote API's
array()
function now has an optionalelement_type
kwarg that can be used to specify the element type in the event that there are no element values.Because only the MIR backend makes use of the element type, this is encoded in the
XSetupArray
extension field.This checks off one box in #1859.