forked from avanhatt/wasmtime
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
spec: type qualifier expression (bytecodealliance#171)
Add a spec expression `(as <expr> <ty>)` to specify the type of a spec expression inline. The syntax is motivated by SMT-LIB qualified identifiers. The motivation for this is the need to express register width constraints in ASLp-derived specs.
- Loading branch information
1 parent
e6f9554
commit 74af086
Showing
9 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
cranelift/isle/veri/veri/filetests/pass/type_qualifier.isle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
; Test case that requires type qualifier to satisfy type inference. | ||
|
||
; Value type of unspecified bit-vector width. | ||
(type Value (primitive Value)) | ||
(model Value (type (bv))) | ||
|
||
; Top-level test term asserts equality | ||
(decl test (Value) Value) | ||
(spec (test arg) (provide (= result arg))) | ||
|
||
; Add then mask low byte. | ||
; | ||
; Note the (as ...) type qualifier. Without it, this test case would have | ||
; underconstrained type inference. | ||
(decl add_then_mask (Value Value) Value) | ||
(extern extractor add_then_mask add_then_mask) | ||
(spec (add_then_mask x y) (match (= result (extract 7 0 (bvadd x (as y (bv 16))))))) | ||
|
||
; Mask low byte then add. | ||
(decl mask_then_add (Value Value) Value) | ||
(extern constructor mask_then_add mask_then_add) | ||
(spec (mask_then_add x y) (provide (= result (bvadd (extract 7 0 x) (extract 7 0 y))))) | ||
|
||
; Test rule swaps mask order. | ||
(rule test (test (add_then_mask x y)) (mask_then_add x y)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters