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§

source

fn initialize(&mut self, context: ContextRef<'c>)

source

fn run(&mut self, operation: OperationRef<'c, '_>, pass: ExternalPass<'_>)

Provided Methods§

source

fn construct(&mut self)

source

fn destruct(&mut self)

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<'c, F: FnMut(OperationRef<'c, '_>, ExternalPass<'_>) + Clone> RunExternalPass<'c> for F