Struct cranelift_codegen::flowgraph::BlockPredecessor
source · Expand description
A basic block denoted by its enclosing Block and last instruction.
Fields§
§block: BlockEnclosing Block key.
inst: InstLast instruction in the basic block.
Implementations§
source§impl BlockPredecessor
impl BlockPredecessor
sourcepub fn new(block: Block, inst: Inst) -> Self
pub fn new(block: Block, inst: Inst) -> Self
Convenient method to construct new BlockPredecessor.
Examples found in repository?
More examples
src/dominator_tree.rs (lines 186-189)
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
pub fn common_dominator(
&self,
mut a: BlockPredecessor,
mut b: BlockPredecessor,
layout: &Layout,
) -> BlockPredecessor {
loop {
match self.rpo_cmp_block(a.block, b.block) {
Ordering::Less => {
// `a` comes before `b` in the RPO. Move `b` up.
let idom = self.nodes[b.block].idom.expect("Unreachable basic block?");
b = BlockPredecessor::new(
layout.inst_block(idom).expect("Dangling idom instruction"),
idom,
);
}
Ordering::Greater => {
// `b` comes before `a` in the RPO. Move `a` up.
let idom = self.nodes[a.block].idom.expect("Unreachable basic block?");
a = BlockPredecessor::new(
layout.inst_block(idom).expect("Dangling idom instruction"),
idom,
);
}
Ordering::Equal => break,
}
}
debug_assert_eq!(
a.block, b.block,
"Unreachable block passed to common_dominator?"
);
// We're in the same block. The common dominator is the earlier instruction.
if layout.cmp(a.inst, b.inst) == Ordering::Less {
a
} else {
b
}
}Trait Implementations§
source§impl Debug for BlockPredecessor
impl Debug for BlockPredecessor
source§impl PartialEq<BlockPredecessor> for BlockPredecessor
impl PartialEq<BlockPredecessor> for BlockPredecessor
source§fn eq(&self, other: &BlockPredecessor) -> bool
fn eq(&self, other: &BlockPredecessor) -> bool
This method tests for
self and other values to be equal, and is used
by ==.impl Eq for BlockPredecessor
impl StructuralEq for BlockPredecessor
impl StructuralPartialEq for BlockPredecessor
Auto Trait Implementations§
impl RefUnwindSafe for BlockPredecessor
impl Send for BlockPredecessor
impl Sync for BlockPredecessor
impl Unpin for BlockPredecessor
impl UnwindSafe for BlockPredecessor
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.