Context

Struct Context 

Source
pub struct Context { /* private fields */ }
Expand description

A context of IR, dialects, and passes.

Contexts own various objects, such as types, locations, and dialect instances.

Implementations§

Source§

impl Context

Source

pub fn new() -> Self

Creates a context.

Source

pub fn new_with_threading(threading_enabled: bool) -> Self

Creates a context with multithreading set explicitly.

Source

pub fn new_with_registry( registry: &DialectRegistry, threading_enabled: bool, ) -> Self

Creates a context with a pre-loaded dialect registry and explicit threading setting.

Source

pub fn registered_dialect_count(&self) -> usize

Returns a number of registered dialects.

Source

pub fn loaded_dialect_count(&self) -> usize

Returns a number of loaded dialects.

Source

pub fn get_or_load_dialect<'c>(&'c self, name: &str) -> Dialect<'c>

Returns or loads a dialect.

Source

pub fn append_dialect_registry(&self, registry: &DialectRegistry)

Appends a dialect registry.

Source

pub fn load_all_available_dialects(&self)

Loads all available dialects.

Source

pub fn enable_multi_threading(&self, enabled: bool)

Enables multi-threading.

Source

pub fn allow_unregistered_dialects(&self) -> bool

Returns true if unregistered dialects are allowed.

Source

pub fn set_allow_unregistered_dialects(&self, allowed: bool)

Sets if unregistered dialects are allowed.

Source

pub fn is_registered_operation(&self, name: &str) -> bool

Returns true if a given operation is registered in a context.

Source

pub const fn to_raw(&self) -> MlirContext

Converts a context into a raw object.

Source

pub fn attach_diagnostic_handler<F: FnMut(Diagnostic<'_>) -> bool>( &self, handler: F, ) -> DiagnosticHandlerId

Attaches a diagnostic handler.

Source

pub fn detach_diagnostic_handler(&self, id: DiagnosticHandlerId)

Detaches a diagnostic handler.

Source

pub unsafe fn set_thread_pool(&self, pool: &ThreadPool)

Sets the thread pool used by the context.

§Safety

The thread pool must outlive the context.

Source

pub fn thread_count(&self) -> usize

Returns the number of threads used by the context.

Trait Implementations§

Source§

impl Debug for Context

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Context

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for Context

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl PartialEq<Context> for ContextRef<'_>

Source§

fn eq(&self, other: &Context) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> PartialEq<ContextRef<'a>> for Context

Source§

fn eq(&self, other: &ContextRef<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for Context

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Context

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.