[−][src]Struct llhd::ir::UnitBuilder
A mutable function, process, or entity.
Methods
impl<'a> UnitBuilder<'a>
[src]
pub fn new(unit: UnitId, data: &'a mut UnitData) -> Self
[src]
Create a new builder for a unit.
pub fn new_anonymous(data: &'a mut UnitData) -> Self
[src]
Create a new builder for a unit that has not yet been added to a module.
pub fn finish(self) -> Unit<'a>
[src]
Finish building and make the unit immutable again.
pub fn data(&mut self) -> &mut UnitData
[src]
Get the unit's mutable data.
pub fn unit(&'a self) -> Unit<'a>
[src]
Return the unit being built.
pub fn ins(&mut self) -> InstBuilder<'a, '_>
[src]
Add a new instruction using an InstBuilder
.
pub fn build_inst(&mut self, data: InstData, ty: Type) -> Inst
[src]
Add a new instruction.
pub fn delete_inst(&mut self, inst: Inst)
[src]
Delete an instruction.
Removes the instruction from the layout, data flwo graph, and control
flow graph, and deletes it. The Inst
is no longer valid afterwards.
pub fn block(&mut self) -> Block
[src]
pub fn named_block(&mut self, name: impl Into<String>) -> Block
[src]
Create a new named BB.
pub fn delete_block(&mut self, bb: Block)
[src]
Delete a block.
Removes the block, and all its instructions, from the layout and control
flow graph, deletes it. The Block
is no longer valid afterwards.
pub fn insert_at_end(&mut self)
[src]
Append all following instructions at the end of the unit.
pub fn insert_at_beginning(&mut self)
[src]
Prepend all following instructions at the beginning of the unit.
pub fn append_to(&mut self, bb: Block)
[src]
Append all following instructions to the end of bb
.
pub fn prepend_to(&mut self, bb: Block)
[src]
Prepend all following instructions to the beginning of bb
.
pub fn insert_after(&mut self, inst: Inst)
[src]
Insert all following instructions after inst
.
pub fn insert_before(&mut self, inst: Inst)
[src]
Insert all following instructions before inst
.
pub fn add_extern(&mut self, name: UnitName, sig: Signature) -> ExtUnit
[src]
Import an external unit for use within this unit.
pub fn prune_if_unused(&mut self, inst: Inst) -> bool
[src]
Remove an instruction if its value is not being read.
Returns true if the instruction was removed.
impl<'a> UnitBuilder<'a>
[src]
pub fn set_block_name(&mut self, bb: Block, name: String)
[src]
Set the name of a BB.
pub fn clear_block_name(&mut self, bb: Block) -> Option<String>
[src]
Clear the name of a BB.
pub fn set_anonymous_block_hint(&mut self, bb: Block, hint: u32)
[src]
Set the anonymous name hint of a BB.
pub fn clear_anonymous_block_hint(&mut self, bb: Block) -> Option<u32>
[src]
Clear the anonymous name hint of a BB.
impl<'a> UnitBuilder<'a>
[src]
pub fn add_placeholder(&mut self, ty: Type) -> Value
[src]
Add a placeholder value.
This function is intended to be used when constructing PHI nodes.
pub fn remove_placeholder(&mut self, value: Value)
[src]
Remove a placeholder value.
pub fn set_name(&mut self, value: Value, name: String)
[src]
Set the name of a value.
pub fn clear_name(&mut self, value: Value) -> Option<String>
[src]
Clear the name of a value.
pub fn set_anonymous_hint(&mut self, value: Value, hint: u32)
[src]
Set the anonymous name hint of a value.
pub fn clear_anonymous_hint(&mut self, value: Value) -> Option<u32>
[src]
Clear the anonymous name hint of a value.
pub fn replace_use(&mut self, from: Value, to: Value) -> usize
[src]
Replace all uses of a value with another.
Returns how many uses were replaced.
pub fn replace_value_within_inst(
&mut self,
from: Value,
to: Value,
inst: Inst
) -> usize
[src]
&mut self,
from: Value,
to: Value,
inst: Inst
) -> usize
Replace the uses of a value with another, in a single instruction.
Returns how many uses were replaced.
pub fn replace_block_use(&mut self, from: Block, to: Block) -> usize
[src]
Replace all uses of a block with another.
Returns how many blocks were replaced.
pub fn replace_block_within_inst(
&mut self,
from: Block,
to: Block,
inst: Inst
) -> usize
[src]
&mut self,
from: Block,
to: Block,
inst: Inst
) -> usize
Replace all uses of a block with another, in a single instruction.
Returns how many blocks were replaced.
pub fn remove_block_use(&mut self, block: Block) -> usize
[src]
Remove all uses of a block.
Replaces all uses of the block with an invalid block placeholder, and removes phi node entries for the block.
Returns how many blocks were removed.
pub fn remove_block_from_inst(&mut self, block: Block, inst: Inst) -> usize
[src]
Remove all uses of a block, from a single instruction.
Replaces all uses of the block with an invalid block placeholder, and removes phi node entries for the block.
Returns how many blocks were removed.
pub fn set_location_hint(&mut self, inst: Inst, loc: usize)
[src]
Add a location hint to an instruction.
Annotates the byte offset of an instruction in the input file.
impl<'a> UnitBuilder<'a>
[src]
Basic Block Layout
The following functions are used to modify the basic block layout.
pub fn append_block(&mut self, bb: Block)
[src]
Append a BB to the end of the function.
pub fn prepend_block(&mut self, bb: Block)
[src]
Prepend a BB to the beginning of a function.
This effectively makes bb
the new entry block.
pub fn insert_block_after(&mut self, bb: Block, after: Block)
[src]
Insert a BB after another BB.
pub fn insert_block_before(&mut self, bb: Block, before: Block)
[src]
Insert a BB before another BB.
pub fn remove_block(&mut self, bb: Block)
[src]
Remove a BB from the function.
pub fn swap_blocks(&mut self, bb0: Block, bb1: Block)
[src]
Swap the position of two BBs.
impl<'a> UnitBuilder<'a>
[src]
Instruction Layout
The following functions are used to modify the instruction layout within a block.
pub fn append_inst(&mut self, inst: Inst, bb: Block)
[src]
Append an instruction to the end of a BB.
pub fn prepend_inst(&mut self, inst: Inst, bb: Block)
[src]
Prepend an instruction to the beginning of a BB.
pub fn insert_inst_after(&mut self, inst: Inst, after: Inst)
[src]
Insert an instruction after another instruction.
pub fn insert_inst_before(&mut self, inst: Inst, before: Inst)
[src]
Insert an instruction before another instruction.
pub fn remove_inst(&mut self, inst: Inst)
[src]
Remove an instruction from the function.
Methods from Deref<Target = Unit<'a>>
Trait Implementations
impl<'a> Borrow<Unit<'a>> for UnitBuilder<'a>
[src]
impl<'a> Deref for UnitBuilder<'a>
[src]
impl<'_> Index<Block> for UnitBuilder<'_>
[src]
type Output = BlockData
The returned type after indexing.
fn index(&self, idx: Block) -> &BlockData
[src]
impl<'_> Index<ExtUnit> for UnitBuilder<'_>
[src]
type Output = ExtUnitData
The returned type after indexing.
fn index(&self, idx: ExtUnit) -> &ExtUnitData
[src]
impl<'_> Index<Inst> for UnitBuilder<'_>
[src]
type Output = InstData
The returned type after indexing.
fn index(&self, idx: Inst) -> &InstData
[src]
impl<'_> Index<Value> for UnitBuilder<'_>
[src]
type Output = ValueData
The returned type after indexing.
fn index(&self, idx: Value) -> &ValueData
[src]
impl<'_> IndexMut<Block> for UnitBuilder<'_>
[src]
impl<'_> IndexMut<ExtUnit> for UnitBuilder<'_>
[src]
fn index_mut(&mut self, idx: ExtUnit) -> &mut ExtUnitData
[src]
impl<'_> IndexMut<Inst> for UnitBuilder<'_>
[src]
impl<'_> IndexMut<Value> for UnitBuilder<'_>
[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for UnitBuilder<'a>
impl<'a> Send for UnitBuilder<'a>
impl<'a> Sync for UnitBuilder<'a>
impl<'a> Unpin for UnitBuilder<'a>
impl<'a> !UnwindSafe for UnitBuilder<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,