MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / is_block_basic

Method is_block_basic

cranelift/codegen/src/ir/function.rs:310–324  ·  view source on GitHub ↗

Checks that the specified block can be encoded as a basic block. On error, returns the first invalid instruction and an error message.

(&self, block: Block)

Source from the content-addressed store, hash-verified

308 ///
309 /// On error, returns the first invalid instruction and an error message.
310 pub fn is_block_basic(&self, block: Block) -> Result<(), (Inst, &'static str)> {
311 let dfg = &self.dfg;
312 let inst_iter = self.layout.block_insts(block);
313
314 // Ignore all instructions prior to the first branch.
315 let mut inst_iter = inst_iter.skip_while(|&inst| !dfg.insts[inst].opcode().is_branch());
316
317 if let Some(_branch) = inst_iter.next() {
318 if let Some(next) = inst_iter.next() {
319 return Err((next, "post-terminator instruction"));
320 }
321 }
322
323 Ok(())
324 }
325
326 /// Returns an iterator over the blocks succeeding the given block.
327 pub fn block_successors(&self, block: Block) -> impl DoubleEndedIterator<Item = Block> + '_ {

Callers 2

finalizeMethod · 0.80
encodable_as_bbMethod · 0.80

Calls 5

OkFunction · 0.85
block_instsMethod · 0.80
is_branchMethod · 0.80
opcodeMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected