Macro match_instr
match_instr!() { /* proc-macro */ }
Expand description
match
style pattern matching and destructuring of instructions and their expressions.
Provides pattern matching with support for nested expressions, variable bindings with @
,
OR patterns, and guard conditions.
ยงExamples
match_instr!{
instr,
// Basic patterns
CallSsa(ConstPtr(address), _) => println!("Direct call to {:#x}", address),
// Variable bindings and guards
instr @ SetRegSsa(dest, add @ Add(RegSsa(src), Const(value))) if value > 10 => {
println!(
"Increment of {src:?} by {value} > 10 at {:#x} (dest={dest:?}, add={add:?})",
instr.address(),
);
},
// OR patterns
CallSsa(_, _) | TailCallSsa(_, _) => println!("Function call"),
_ => {}
};