pub struct Block(/* private fields */);Expand description
A handle to a basic block inside a Function.
A block is a straight-line run of instructions with one entry and one
terminator. This handle names a block so a terminator can branch to it and so a
pass can walk the control-flow graph. Like Value, it is Copy, stable for
the life of its function, and dense from zero.
§Examples
use ir_lang::{Builder, Type};
let mut b = Builder::new("f", &[], Type::Unit);
let entry = b.entry();
let exit = b.create_block(&[]);
assert_eq!(entry.to_string(), "b0");
assert_eq!(exit.to_string(), "b1");
assert_eq!(exit.index(), 1);Implementations§
Source§impl Block
impl Block
Sourcepub const fn index(self) -> usize
pub const fn index(self) -> usize
Returns the zero-based index of this block, for use as a key into a side table a pass keeps alongside the function.
Blocks are numbered densely from zero in creation order; the entry block is always block zero.
§Examples
use ir_lang::{Builder, Type};
let b = Builder::new("f", &[], Type::Unit);
assert_eq!(b.entry().index(), 0);Trait Implementations§
impl Copy for Block
Source§impl<'de> Deserialize<'de> for Block
impl<'de> Deserialize<'de> for Block
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Block
Source§impl Ord for Block
impl Ord for Block
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for Block
impl PartialOrd for Block
impl StructuralPartialEq for Block
Auto Trait Implementations§
impl Freeze for Block
impl RefUnwindSafe for Block
impl Send for Block
impl Sync for Block
impl Unpin for Block
impl UnsafeUnpin for Block
impl UnwindSafe for Block
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
Mutably borrows from an owned value. Read more