Operation

Struct Operation 

Source
pub struct Operation {
    pub attributes: AttributeDict,
    /* private fields */
}
Expand description

Basic unit of execution. May or may not be in a BasicBlock.

Fields§

§attributes: AttributeDict

A dictionary of attributes.

Implementations§

Source§

impl Operation

Source

pub fn new( ctx: &mut Context, concrete_op: (fn(Ptr<Operation>) -> OpObj, TypeId), result_types: Vec<Ptr<TypeObj>>, operands: Vec<Value>, successors: Vec<Ptr<BasicBlock>>, num_regions: usize, ) -> Ptr<Operation>

Create a new, unlinked (i.e., not in a basic block) operation.

Source

pub fn get_parent_block(&self) -> Option<Ptr<BasicBlock>>

Get parent block.

Source

pub fn get_parent_region(&self, ctx: &Context) -> Option<Ptr<Region>>

Get parent region.

Source

pub fn get_parent_op(&self, ctx: &Context) -> Option<Ptr<Operation>>

Get parent operation.

Source

pub fn get_num_results(&self) -> usize

Number of results this operation has.

Source

pub fn get_result(&self, idx: usize) -> Value

Get idx’th result as a Value.

Source

pub fn results(&self) -> impl Iterator<Item = Value> + Clone + '_

Get an iterator over the results of this operation.

Source

pub fn has_use(&self) -> bool

Does any result of this operation have a use?

Source

pub fn num_uses(&self) -> usize

Total number of uses (across all results).

Source

pub fn get_type(&self, idx: usize) -> Ptr<TypeObj>

Get type of the idx’th result.

Source

pub fn result_types(&self) -> impl Iterator<Item = Ptr<TypeObj>> + Clone + '_

Get an iterator over the result types of this operation.

Source

pub fn get_num_operands(&self) -> usize

Get number of operands.

Source

pub fn get_operand(&self, opd_idx: usize) -> Value

Get opd_idx’th operand of this Operation

Source

pub fn get_operand_as_use(&self, opd_idx: usize) -> Use<Value>

Get opd_idx’th operand as a Use<Value>.

Source

pub fn operands(&self) -> impl Iterator<Item = Value> + Clone + '_

Get an iterator over the results of this operation.

Source

pub fn replace_operand( this: Ptr<Operation>, ctx: &Context, opd_idx: usize, other: Value, )

Replace opd_idx’th operand of this with other.

Source

pub fn get_num_successors(&self) -> usize

Get number of successors

Source

pub fn get_successor(&self, succ_idx: usize) -> Ptr<BasicBlock>

Get the opd_idx’th successor of this Operation

Source

pub fn get_successor_as_use(&self, succ_idx: usize) -> Use<Ptr<BasicBlock>>

Get the opd_idx’th successor as a Use<Ptr<BasicBlock>>.

Source

pub fn replace_successor( this: Ptr<Operation>, ctx: &Context, succ_idx: usize, other: Ptr<BasicBlock>, )

Replace opd_idx’th successor of this with other.

Source

pub fn successors(&self) -> impl Iterator<Item = Ptr<BasicBlock>> + Clone + '_

Get an iterator on the successors.

Source

pub fn get_op_dyn(ptr: Ptr<Self>, ctx: &Context) -> OpObj

Create an OpObj corresponding to self. get_op is more efficient if the concrete type is known.

Source

pub fn get_op<T: Op>(ptr: Ptr<Self>, ctx: &Context) -> Option<T>

Creates the concrete Op corresponding to self.

Source

pub fn get_opid(ptr: Ptr<Self>, ctx: &Context) -> OpId

Get the OpId this Operation. Builds an intermediate OpObj.

Source

pub fn get_region(&self, reg_idx: usize) -> Ptr<Region>

Get a Ptr to the reg_idxth region.

Source

pub fn num_regions(&self) -> usize

Number of regions.

Source

pub fn add_region(ptr: Ptr<Self>, ctx: &mut Context) -> Ptr<Region>

Add a new empty region to the operation and return its Ptr.

Source

pub fn erase_region(ptr: Ptr<Self>, ctx: &mut Context, reg_idx: usize)

Erase reg_idx’th region. Affects the index of all regions after it.

Source

pub fn regions(&self) -> impl Iterator<Item = Ptr<Region>> + Clone + '_

Get an iterator on the regions.

Source

pub fn drop_all_uses(ptr: Ptr<Self>, ctx: &Context)

Drop all uses that this operation holds.

Source

pub fn erase(ptr: Ptr<Self>, ctx: &mut Context)

Unlink and deallocate this operation and everything that it contains. There must not be any uses.

Source

pub fn top_level_parse<'a>( state_stream: &mut StateStream<'a>, ) -> ParseResult<'a, Ptr<Self>>

Parse a top level operation from a StateStream. Top level parser looks for outlined attributes.

Source

pub fn top_level_parser<'a>() -> impl Parser<StateStream<'a>, Output = Ptr<Self>, PartialState = ()> + 'a

A parser combinator to parse a top level operation. Top level parser looks for outlined attributes.

Trait Implementations§

Source§

impl ContainsLinkedList<Operation> for BasicBlock

Source§

fn get_head(&self) -> Option<Ptr<Operation>>

Simply get the head of the list.
Source§

fn get_tail(&self) -> Option<Ptr<Operation>>

Simply get the tail of the list.
Source§

fn iter<'a>(&self, ctx: &'a Context) -> Iter<'a, T>

Get an iterator over the items. Context is borrowed throughout.
Source§

impl LinkedList for Operation

Source§

fn get_next(&self) -> Option<Ptr<Self>>

Simple getter for the item previous to this in the list.
Source§

fn get_prev(&self) -> Option<Ptr<Self>>

Simple getter for the item previous to this in the list.
Source§

fn get_container(&self) -> Option<Ptr<BasicBlock>>

Get a reference to the object that contains this linked list.
Source§

impl Located for Operation

Source§

fn loc(&self) -> Location

Source§

fn set_loc(&mut self, loc: Location)

Source§

impl Parsable for Operation

Source§

type Arg = OperationParserConfig

Type of the argument that must be passed to the parser.
Source§

type Parsed = Ptr<Operation>

The type of the parsed entity.
Source§

fn parse<'a>( state_stream: &mut StateStream<'a>, arg: Self::Arg, ) -> ParseResult<'a, Self::Parsed>

Define a parser using existing combinators and call into on Parser::parse_stream to get the final ParseResult. Use state_stream.state as necessary.
Source§

fn parser<'a>( arg: Self::Arg, ) -> Box<dyn Parser<StateStream<'a>, Output = Self::Parsed, PartialState = ()> + 'a>

Get a parser combinator that can work on StateStream as its input.
Source§

fn parser_fn<'a>( _: &'a (), arg: Self::Arg, ) -> Box<dyn Parser<StateStream<'a>, Output = Self::Parsed, PartialState = ()> + 'a>

Same as Self::parser but takes a unit reference for use as ParserFn
Source§

impl PartialEq for Operation

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 Printable for Operation

Source§

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

Source§

fn disp<'t, 'c>(&'t self, ctx: &'c Context) -> Box<dyn Display + 'c>
where 't: 'c,

Get a Display’able object from the given Context and default State.
Source§

fn print<'t, 'c>( &'t self, ctx: &'c Context, state: &State, ) -> Box<dyn Display + 'c>
where 't: 'c,

Get a Display’able object from the given Context and State.
Source§

impl Verify for Operation

Source§

fn verify(&self, ctx: &Context) -> Result<()>

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> 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 + Sync + Send>

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 + Sync + Send>

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, 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.