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. Panics on invalid index.
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 push_result(this: Ptr<Self>, ctx: &Context, ty: Ptr<TypeObj>) -> usize
pub fn push_result(this: Ptr<Self>, ctx: &Context, ty: Ptr<TypeObj>) -> usize
Add a result to the end of the result list, returning its index.
Sourcepub fn pop_result(this: Ptr<Self>, ctx: &Context)
pub fn pop_result(this: Ptr<Self>, ctx: &Context)
Remove the last result. Panics if there are no results or if the result has uses. Any Value referring to the removed result is invalidated.
Sourcepub fn insert_result(
this: Ptr<Self>,
ctx: &Context,
res_idx: usize,
ty: Ptr<TypeObj>,
)
pub fn insert_result( this: Ptr<Self>, ctx: &Context, res_idx: usize, ty: Ptr<TypeObj>, )
Insert a new result at res_idx, shifting existing results, from res_idx, to the right.
Panics on invalid index.
Sourcepub fn remove_result(this: Ptr<Self>, ctx: &Context, res_idx: usize)
pub fn remove_result(this: Ptr<Self>, ctx: &Context, res_idx: usize)
Remove the result at res_idx, shifting existing results, from res_idx + 1, to the left.
Panics on invalid index or if the removed result has uses.
Any Value referring to the removed result is invalidated.
Sourcepub fn uses(&self) -> impl Iterator<Item = Use<Value>> + '_
pub fn uses(&self) -> impl Iterator<Item = Use<Value>> + '_
Get all uses of all results of this operation.
Sourcepub fn get_type(&self, idx: usize) -> Ptr<TypeObj>
pub fn get_type(&self, idx: usize) -> Ptr<TypeObj>
Get type of the idx’th result. Panics on invalid index.
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. Panics on invalid index.
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>. Panics on invalid index.
Sourcepub fn operands(&self) -> impl Iterator<Item = Value> + Clone + '_
pub fn operands(&self) -> impl Iterator<Item = Value> + Clone + '_
Get an iterator over the operands of this operation.
Sourcepub fn operands_as_uses(&self) -> impl Iterator<Item = Use<Value>> + '_
pub fn operands_as_uses(&self) -> impl Iterator<Item = Use<Value>> + '_
Get an iterator over the operands of this operation as Use<Value>s.
Sourcepub fn push_operand(
this: Ptr<Operation>,
ctx: &Context,
new_opd: Value,
) -> usize
pub fn push_operand( this: Ptr<Operation>, ctx: &Context, new_opd: Value, ) -> usize
Add a new operand to the end of the operand list, returning its index.
Sourcepub fn pop_operand(this: Ptr<Operation>, ctx: &Context) -> Value
pub fn pop_operand(this: Ptr<Operation>, ctx: &Context) -> Value
Remove the last operand. Panics if there are no operands.
Any Use<Value> of the removed operand is invalidated.
The removed Value is returned for convenience.
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. Panics on invalid index.
Any Use<Value> of the replaced operand will be invalidated.
Sourcepub fn insert_operand(
this: Ptr<Operation>,
ctx: &Context,
opd_idx: usize,
new_opd: Value,
)
pub fn insert_operand( this: Ptr<Operation>, ctx: &Context, opd_idx: usize, new_opd: Value, )
Insert a new operand at opd_idx, shifting existing operands, from opd_idx,
to the right. Panics on invalid index (i.e., opd_idx > number of operands).
Sourcepub fn remove_operand(
this: Ptr<Operation>,
ctx: &Context,
opd_idx: usize,
) -> Value
pub fn remove_operand( this: Ptr<Operation>, ctx: &Context, opd_idx: usize, ) -> Value
Remove the operand at opd_idx, shifting existing operands, from opd_idx + 1,
to the left. Panics on invalid index (i.e., opd_idx >= number of operands).
Any Use<Value> of the removed operand is invalidated.
The removed Value is returned for convenience.
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. Panics on invalid index.
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>>. Panics on invalid index.
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. Panics on invalid index.
Any Use<Ptr<BasicBlock>> of the replaced successor will be invalidated.
Sourcepub fn push_successor(
this: Ptr<Operation>,
ctx: &Context,
new_succ: Ptr<BasicBlock>,
) -> usize
pub fn push_successor( this: Ptr<Operation>, ctx: &Context, new_succ: Ptr<BasicBlock>, ) -> usize
Add a new successor to the end of the successor list, returning its index.
Sourcepub fn pop_successor(this: Ptr<Operation>, ctx: &Context) -> Ptr<BasicBlock>
pub fn pop_successor(this: Ptr<Operation>, ctx: &Context) -> Ptr<BasicBlock>
Remove the last successor. Panics if there are no successors.
Any Use<Ptr<BasicBlock>> of the removed successor is invalidated.
The removed Ptr<BasicBlock> is returned for convenience.
Sourcepub fn insert_successor(
this: Ptr<Operation>,
ctx: &Context,
succ_idx: usize,
new_succ: Ptr<BasicBlock>,
)
pub fn insert_successor( this: Ptr<Operation>, ctx: &Context, succ_idx: usize, new_succ: Ptr<BasicBlock>, )
Insert a new successor at succ_idx, shifting existing successors, from succ_idx,
to the right. Panics on invalid index (i.e., succ_idx > number of successors).
Sourcepub fn remove_successor(
this: Ptr<Operation>,
ctx: &Context,
succ_idx: usize,
) -> Ptr<BasicBlock>
pub fn remove_successor( this: Ptr<Operation>, ctx: &Context, succ_idx: usize, ) -> Ptr<BasicBlock>
Remove the successor at succ_idx, shifting existing successors, from succ_idx + 1,
to the left. Panics on invalid index (i.e., succ_idx >= number of successors).
Any Use<Ptr<BasicBlock>> of the removed successor is invalidated.
The removed Ptr<BasicBlock> is returned for convenience.
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 successors_as_uses(
&self,
) -> impl Iterator<Item = Use<Ptr<BasicBlock>>> + '_
pub fn successors_as_uses( &self, ) -> impl Iterator<Item = Use<Ptr<BasicBlock>>> + '_
Get an iterator over the successors of this operation as Use<Ptr<BasicBlock>>s.
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 is_op<T: Op>(ptr: Ptr<Self>, ctx: &Context) -> bool
pub fn is_op<T: Op>(ptr: Ptr<Self>, ctx: &Context) -> bool
Is this operation an instance of the concrete Op T?
Sourcepub fn get_region(&self, reg_idx: usize) -> Ptr<Region>
pub fn get_region(&self, reg_idx: usize) -> Ptr<Region>
Get a Ptr to the reg_idxth region. Panics on invalid index.
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.
Panics on invalid index.
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 UnsafeUnpin 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.