pub struct Operation {
pub attributes: AttributeDict,
/* private fields */
}Expand description
Basic unit of execution. May or may not be in a BasicBlock.
Fields§
§attributes: AttributeDictA dictionary of attributes.
Implementations§
Source§impl Operation
impl Operation
Sourcepub 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>
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.
Sourcepub fn get_parent_block(&self) -> Option<Ptr<BasicBlock>>
pub fn get_parent_block(&self) -> Option<Ptr<BasicBlock>>
Get parent block.
Sourcepub fn get_num_results(&self) -> usize
pub fn get_num_results(&self) -> usize
Number of results this operation has.
Sourcepub fn get_result(&self, idx: usize) -> Value
pub fn get_result(&self, idx: usize) -> Value
Get idx’th result as a Value.
Sourcepub fn results(&self) -> impl Iterator<Item = Value> + Clone + '_
pub fn results(&self) -> impl Iterator<Item = Value> + Clone + '_
Get an iterator over the results of this operation.
Sourcepub fn result_types(&self) -> impl Iterator<Item = Ptr<TypeObj>> + Clone + '_
pub fn result_types(&self) -> impl Iterator<Item = Ptr<TypeObj>> + Clone + '_
Get an iterator over the result types of this operation.
Sourcepub fn get_num_operands(&self) -> usize
pub fn get_num_operands(&self) -> usize
Get number of operands.
Sourcepub fn get_operand(&self, opd_idx: usize) -> Value
pub fn get_operand(&self, opd_idx: usize) -> Value
Get opd_idx’th operand of this Operation
Sourcepub fn get_operand_as_use(&self, opd_idx: usize) -> Use<Value>
pub fn get_operand_as_use(&self, opd_idx: usize) -> Use<Value>
Get opd_idx’th operand as a Use<Value>.
Sourcepub fn operands(&self) -> impl Iterator<Item = Value> + Clone + '_
pub fn operands(&self) -> impl Iterator<Item = Value> + Clone + '_
Get an iterator over the results of this operation.
Sourcepub fn replace_operand(
this: Ptr<Operation>,
ctx: &Context,
opd_idx: usize,
other: Value,
)
pub fn replace_operand( this: Ptr<Operation>, ctx: &Context, opd_idx: usize, other: Value, )
Replace opd_idx’th operand of this with other.
Sourcepub fn get_num_successors(&self) -> usize
pub fn get_num_successors(&self) -> usize
Get number of successors
Sourcepub fn get_successor(&self, succ_idx: usize) -> Ptr<BasicBlock>
pub fn get_successor(&self, succ_idx: usize) -> Ptr<BasicBlock>
Get the opd_idx’th successor of this Operation
Sourcepub fn get_successor_as_use(&self, succ_idx: usize) -> Use<Ptr<BasicBlock>>
pub fn get_successor_as_use(&self, succ_idx: usize) -> Use<Ptr<BasicBlock>>
Get the opd_idx’th successor as a Use<Ptr<BasicBlock>>.
Sourcepub fn replace_successor(
this: Ptr<Operation>,
ctx: &Context,
succ_idx: usize,
other: Ptr<BasicBlock>,
)
pub fn replace_successor( this: Ptr<Operation>, ctx: &Context, succ_idx: usize, other: Ptr<BasicBlock>, )
Replace opd_idx’th successor of this with other.
Sourcepub fn successors(&self) -> impl Iterator<Item = Ptr<BasicBlock>> + Clone + '_
pub fn successors(&self) -> impl Iterator<Item = Ptr<BasicBlock>> + Clone + '_
Get an iterator on the successors.
Sourcepub fn get_op_dyn(ptr: Ptr<Self>, ctx: &Context) -> OpObj
pub fn get_op_dyn(ptr: Ptr<Self>, ctx: &Context) -> OpObj
Sourcepub fn get_op<T: Op>(ptr: Ptr<Self>, ctx: &Context) -> Option<T>
pub fn get_op<T: Op>(ptr: Ptr<Self>, ctx: &Context) -> Option<T>
Creates the concrete Op corresponding to self.
Sourcepub fn num_regions(&self) -> usize
pub fn num_regions(&self) -> usize
Number of regions.
Sourcepub fn add_region(ptr: Ptr<Self>, ctx: &mut Context) -> Ptr<Region>
pub fn add_region(ptr: Ptr<Self>, ctx: &mut Context) -> Ptr<Region>
Add a new empty region to the operation and return its Ptr.
Sourcepub fn erase_region(ptr: Ptr<Self>, ctx: &mut Context, reg_idx: usize)
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.
Sourcepub fn regions(&self) -> impl Iterator<Item = Ptr<Region>> + Clone + '_
pub fn regions(&self) -> impl Iterator<Item = Ptr<Region>> + Clone + '_
Get an iterator on the regions.
Sourcepub fn drop_all_uses(ptr: Ptr<Self>, ctx: &Context)
pub fn drop_all_uses(ptr: Ptr<Self>, ctx: &Context)
Drop all uses that this operation holds.
Sourcepub fn erase(ptr: Ptr<Self>, ctx: &mut Context)
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.
Sourcepub fn top_level_parse<'a>(
state_stream: &mut StateStream<'a>,
) -> ParseResult<'a, Ptr<Self>>
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.
Sourcepub fn top_level_parser<'a>() -> impl Parser<StateStream<'a>, Output = Ptr<Self>, PartialState = ()> + 'a
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
impl ContainsLinkedList<Operation> for BasicBlock
Source§impl LinkedList for Operation
impl LinkedList for Operation
Source§fn get_next(&self) -> Option<Ptr<Self>>
fn get_next(&self) -> Option<Ptr<Self>>
Source§fn get_prev(&self) -> Option<Ptr<Self>>
fn get_prev(&self) -> Option<Ptr<Self>>
Source§fn get_container(&self) -> Option<Ptr<BasicBlock>>
fn get_container(&self) -> Option<Ptr<BasicBlock>>
Source§impl Parsable for Operation
impl Parsable for Operation
Source§type Arg = OperationParserConfig
type Arg = OperationParserConfig
Source§fn parse<'a>(
state_stream: &mut StateStream<'a>,
arg: Self::Arg,
) -> ParseResult<'a, Self::Parsed>
fn parse<'a>( state_stream: &mut StateStream<'a>, arg: Self::Arg, ) -> ParseResult<'a, Self::Parsed>
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>
fn parser<'a>( arg: Self::Arg, ) -> Box<dyn Parser<StateStream<'a>, Output = Self::Parsed, PartialState = ()> + 'a>
Auto Trait Implementations§
impl Freeze for Operation
impl !RefUnwindSafe for Operation
impl Send for Operation
impl Sync for Operation
impl Unpin for Operation
impl !UnwindSafe for Operation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.