Trait melior::pass::external::RunExternalPass
source · pub trait RunExternalPass<'c>: Sized + Clone {
// Required methods
fn initialize(&mut self, context: ContextRef<'c>);
fn run(&mut self, operation: OperationRef<'c, '_>, pass: ExternalPass<'_>);
// Provided methods
fn construct(&mut self) { ... }
fn destruct(&mut self) { ... }
}
Expand description
A trait for MLIR passes written in Rust.
This trait is implemented for any type that implements FnMut
,
but can be implemented for any struct that implements Clone
.
Examples
The following example pass dumps operations.
use melior::{
ir::OperationRef,
pass::{ExternalPass, RunExternalPass},
ContextRef,
};
#[derive(Clone, Debug)]
struct ExamplePass;
impl<'c> RunExternalPass<'c> for ExamplePass {
fn construct(&mut self) {
println!("Constructed pass!");
}
fn initialize(&mut self, context: ContextRef<'c>) {
println!("Initialize called!");
}
fn run(&mut self, operation: OperationRef<'c, '_>, _pass: ExternalPass<'_>) {
operation.dump();
}
}
Required Methods§
fn initialize(&mut self, context: ContextRef<'c>)
fn run(&mut self, operation: OperationRef<'c, '_>, pass: ExternalPass<'_>)
Provided Methods§
Object Safety§
This trait is not object safe.