Skip to main content

IRRewriter

Struct IRRewriter 

Source
pub struct IRRewriter<L>
where L: RewriteListener,
{ /* private fields */ }
Expand description

An implementation of the rewriter trait. Use DummyListener if no listener is needed.

Implementations§

Source§

impl<L> IRRewriter<L>
where L: RewriteListener,

Source

pub fn set_listener(&mut self, listener: L)

Sets the listener for insertion events.

Source

pub fn get_listener(&self) -> &L

Gets a reference to the listener for insertion events.

Source

pub fn get_listener_mut(&mut self) -> &mut L

Gets a mutable reference to the listener for insertion events.

Trait Implementations§

Source§

impl<L> Default for IRRewriter<L>

Source§

fn default() -> IRRewriter<L>

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

impl<L> Inserter for IRRewriter<L>
where L: RewriteListener,

Source§

fn append_operation(&mut self, ctx: &Context, operation: Ptr<Operation>)

Appends an Operation at the current insertion point. The insertion point is updated to be after this newly inserted Operation.
Source§

fn append_op(&mut self, ctx: &Context, op: &(dyn Op + 'static))

Appends an Op at the current insertion point. The insertion point is updated to be after this newly inserted Op.
Source§

fn insert_operation(&mut self, ctx: &Context, operation: Ptr<Operation>)

Inserts an Operation at the current insertion point. To insert a sequence in-order, use append_operation.
Source§

fn insert_op(&mut self, ctx: &Context, op: &(dyn Op + 'static))

Inserts an Op at the current insertion point. To insert a sequence in-order, use append_op.
Source§

fn insert_block( &mut self, ctx: &Context, insertion_point: BlockInsertionPoint, block: Ptr<BasicBlock>, )

Insert BasicBlock at the provided insertion point.
Source§

fn create_block( &mut self, ctx: &mut Context, insertion_point: BlockInsertionPoint, label: Option<Identifier>, arg_types: Vec<TypeHandle>, ) -> Ptr<BasicBlock>

Create a new BasicBlock and insert it at the provided insertion point. The internal OpInsertionPoint is updated to be at the end of the newly created block.
Source§

fn get_insertion_point(&self) -> OpInsertionPoint

Gets the current insertion point.
Source§

fn get_insertion_block(&self, ctx: &Context) -> Option<Ptr<BasicBlock>>

Get the BasicBlock, if known, in which the next Op insertion will occur.
Source§

fn set_insertion_point(&mut self, point: OpInsertionPoint)

Set the insertion point.
Source§

fn is_insertion_point_set(&self) -> bool

Is insertion point set?
Source§

fn set_insertion_point_to_block_start(&mut self, block: Ptr<BasicBlock>)

Sets the insertion point to the start of the given block.
Source§

fn set_insertion_point_to_block_end(&mut self, block: Ptr<BasicBlock>)

Sets the insertion point to the end of the given block.
Source§

fn set_insertion_point_after_operation(&mut self, op: Ptr<Operation>)

Sets the insertion point to after the given operation.
Source§

fn set_insertion_point_before_operation(&mut self, op: Ptr<Operation>)

Sets the insertion point to before the given operation.
Source§

impl<L> Rewriter for IRRewriter<L>
where L: RewriteListener,

Source§

fn get_config(&self) -> &RewriterConfig

Get the configuration for this rewriter.
Source§

fn get_config_mut(&mut self) -> &mut RewriterConfig

Get a mutable reference to the configuration for this rewriter.
Source§

fn replace_operation( &mut self, ctx: &mut Context, op: Ptr<Operation>, new_op: Ptr<Operation>, )

Replace an Operation (and delete it) with another operation. Results of the new operation must match the results of the old operation.
Source§

fn replace_operation_with_values( &mut self, ctx: &mut Context, op: Ptr<Operation>, new_values: Vec<Value>, )

Replace an Operation (and delete it) with a list of values. Results of the new operation must match the list of values.
Source§

fn replace_value_uses_with( &mut self, ctx: &Context, old_value: Value, new_value: Value, )

Replace all uses of a Value with another value.
Source§

fn erase_operation(&mut self, ctx: &mut Context, op: Ptr<Operation>)

Erase an Operation. The operation must have no uses.
Source§

fn erase_block(&mut self, ctx: &mut Context, block: Ptr<BasicBlock>)

Erase a BasicBlock. The block must have no uses.
Source§

fn erase_region(&mut self, ctx: &mut Context, region: Ptr<Region>)

Erase a Region. Affects the index of all regions after it.
Unlink an Operation from its current position
Unlink a BasicBlock from its current position
Source§

fn move_operation( &mut self, ctx: &Context, op: Ptr<Operation>, new_point: OpInsertionPoint, )

Move an Operation to a new insertion point.
Source§

fn move_block( &mut self, ctx: &Context, block: Ptr<BasicBlock>, new_point: BlockInsertionPoint, )

Move a BasicBlock to a new insertion point.
Source§

fn split_block( &mut self, ctx: &mut Context, block: Ptr<BasicBlock>, position: OpInsertionPoint, new_block_label: Option<Identifier>, ) -> Ptr<BasicBlock>

Split a BasicBlock at the given position.
Source§

fn inline_region( &mut self, ctx: &Context, src_region: Ptr<Region>, dest_insertion_point: BlockInsertionPoint, )

Inline a Region into another Region at the given insertion point. The source region will be empty after this operation. The caller must take care of transferring control flow and arguments as necessary.
Source§

fn set_value_type(&mut self, ctx: &Context, value: Value, new_type: TypeHandle)

Change the type of a Value.
Source§

fn is_modified(&self) -> bool

Has the IR been modified via this rewriter?
Source§

fn mark_modified(&mut self)

Mark that the IR has been modified via this rewriter.

Auto Trait Implementations§

§

impl<L> !RefUnwindSafe for IRRewriter<L>

§

impl<L> !UnwindSafe for IRRewriter<L>

§

impl<L> Freeze for IRRewriter<L>

§

impl<L> Send for IRRewriter<L>

§

impl<L> Sync for IRRewriter<L>

§

impl<L> Unpin for IRRewriter<L>

§

impl<L> UnsafeUnpin for IRRewriter<L>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<R> RewriterExt for R
where R: Rewriter,

Source§

fn replace_op_with( &mut self, ctx: &mut Context, op: Ptr<Operation>, new_op: Ptr<Operation>, )

Source§

fn append_op_with_result( &mut self, ctx: &mut Context, op: &impl OneResultInterface, ) -> Value

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.