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.
17 lines
309 B
Rust
17 lines
309 B
Rust
mod iflets;
|
|
|
|
struct Context;
|
|
impl iflets::Context for Context {
|
|
fn A(&mut self, a: u32, b: u32) -> Option<u32> {
|
|
Some(a + b)
|
|
}
|
|
|
|
fn B(&mut self, value: u32) -> Option<(u32, u32)> {
|
|
Some((value, value + 1))
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
iflets::constructor_C(&mut Context, 1, 2, 3, 4);
|
|
}
|