Skip to main content

RunExternalPass

Trait 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§

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)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

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