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.
22 lines
385 B
Rust
22 lines
385 B
Rust
mod borrows;
|
|
|
|
#[derive(Clone)]
|
|
pub enum A {
|
|
B { x: u32, y: u32 },
|
|
}
|
|
|
|
struct Context(A);
|
|
impl borrows::Context for Context {
|
|
fn get_a(&mut self, _: u32) -> Option<A> {
|
|
Some(self.0.clone())
|
|
}
|
|
|
|
fn u32_pure(&mut self, value: u32) -> Option<u32> {
|
|
Some(value + 1)
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
borrows::constructor_entry(&mut Context(A::B { x: 1, y: 2 }), 42);
|
|
}
|