Move WasmRuntime::translate_call_indirect() into FuncEnvironment.
Add two new arguments: - table_index is the WebAssembly table referenced in the indirect call. - sig_index is the WebAssembly signature index. We still have the SigRef that was created by make_indirect_sig(), but the WebAssembly signature index may be needed for detecting type mismatches at runtime. Change the insertion location to a plain FuncCursor rather than a FunctionBuilder<Local>. The fact that cretonne-wasm uses FunctionBuilder should be an implementation detail, and the callbacks don't need to access WebAssembly locals, so they don't need the extended interface. Add a FunctionBuilder::cursor() method which creates a FuncCursor for inserting instructions in the current EBB. Also add a FuncEnvironment::translate_call() method which allows the environment to override direct calls the same way as indirect calls.
This commit is contained in:
@@ -19,6 +19,8 @@ pub use ir::layout::Cursor as LayoutCursor;
|
||||
/// encoding.
|
||||
pub struct FuncCursor<'f> {
|
||||
pos: CursorPosition,
|
||||
|
||||
/// The referenced function.
|
||||
pub func: &'f mut ir::Function,
|
||||
}
|
||||
|
||||
@@ -79,7 +81,11 @@ impl<'c, 'f> ir::InstInserterBase<'c> for &'c mut FuncCursor<'f> {
|
||||
pub struct EncCursor<'f> {
|
||||
pos: CursorPosition,
|
||||
built_inst: Option<ir::Inst>,
|
||||
|
||||
/// The referenced function.
|
||||
pub func: &'f mut ir::Function,
|
||||
|
||||
/// The target ISA that will be used to encode instructions.
|
||||
pub isa: &'f TargetIsa,
|
||||
}
|
||||
|
||||
|
||||
@@ -728,6 +728,27 @@ pub trait CursorBase {
|
||||
self
|
||||
}
|
||||
|
||||
/// Rebuild this cursor positioned at the bottom of `ebb`.
|
||||
///
|
||||
/// This is intended to be used as a builder method:
|
||||
///
|
||||
/// ```
|
||||
/// # use cretonne::ir::{Function, Ebb, Inst};
|
||||
/// # use cretonne::ir::layout::{Cursor, CursorBase};
|
||||
/// fn edit_func(func: &mut Function, ebb: Ebb) {
|
||||
/// let mut pos = Cursor::new(&mut func.layout).at_bottom(ebb);
|
||||
///
|
||||
/// // Use `pos`...
|
||||
/// }
|
||||
/// ```
|
||||
fn at_bottom(mut self, ebb: Ebb) -> Self
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
self.goto_bottom(ebb);
|
||||
self
|
||||
}
|
||||
|
||||
/// Get the EBB corresponding to the current position.
|
||||
fn current_ebb(&self) -> Option<Ebb> {
|
||||
use self::CursorPosition::*;
|
||||
|
||||
@@ -17,6 +17,7 @@ pub mod entity;
|
||||
|
||||
pub mod binemit;
|
||||
pub mod bitset;
|
||||
pub mod cursor;
|
||||
pub mod dominator_tree;
|
||||
pub mod flowgraph;
|
||||
pub mod ir;
|
||||
@@ -31,7 +32,6 @@ pub mod verifier;
|
||||
mod abi;
|
||||
mod constant_hash;
|
||||
mod context;
|
||||
mod cursor;
|
||||
mod iterators;
|
||||
mod legalizer;
|
||||
mod licm;
|
||||
|
||||
Reference in New Issue
Block a user