This PR adds support for `if-let` clauses, as proposed in bytecodealliance/rfcs#21. These clauses augment the left-hand side (pattern-matching phase) of rules in the ISLE instruction-selection DSL with sub-patterns matching on sub-expressions. The ability to list additional match operations to perform, out-of-line from the original toplevel pattern, greatly simplifies some idioms. See the RFC for more details and examples of use.
30 lines
469 B
Common Lisp
30 lines
469 B
Common Lisp
(type u32 (primitive u32))
|
|
|
|
(decl pure A (u32 u32) u32)
|
|
(extern constructor A A)
|
|
|
|
(decl B (u32 u32) u32)
|
|
(extern extractor B B)
|
|
|
|
(decl C (u32 u32 u32 u32) u32)
|
|
|
|
(decl pure predicate () u32)
|
|
(rule (predicate) 1)
|
|
|
|
(rule (C a b c (B d e))
|
|
(if-let (B f g) d)
|
|
(if-let h (A a b))
|
|
(A h a))
|
|
|
|
(rule (C a b c d)
|
|
(if (predicate))
|
|
42)
|
|
|
|
(rule (C a b a b)
|
|
(if-let x (D a b))
|
|
x)
|
|
|
|
(decl pure D (u32 u32) u32)
|
|
(rule (D x 0) x)
|
|
(rule (D 0 x) x)
|