Remove define_function_peek_compiled
This commit is contained in:
@@ -505,49 +505,44 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Define a function, producing the function body from the given `Context`.
|
/// Define a function, producing the function body from the given `Context`.
|
||||||
pub fn define_function(&mut self, func: FuncId, ctx: &mut Context) -> ModuleResult<()> {
|
///
|
||||||
self.define_function_peek_compiled(func, ctx, |_, _, _| ())
|
/// Returns the size of the function's code.
|
||||||
}
|
///
|
||||||
|
/// Note: After calling this function the given `Context` will contain the compiled function.
|
||||||
/// Define a function, allowing to peek at the compiled function and producing the
|
pub fn define_function(
|
||||||
/// function body from the given `Context`.
|
|
||||||
pub fn define_function_peek_compiled<T>(
|
|
||||||
&mut self,
|
&mut self,
|
||||||
func: FuncId,
|
func: FuncId,
|
||||||
ctx: &mut Context,
|
ctx: &mut Context,
|
||||||
peek_compiled: impl FnOnce(u32, &Context, &isa::TargetIsa) -> T,
|
) -> ModuleResult<binemit::CodeOffset> {
|
||||||
) -> ModuleResult<T> {
|
let code_size = ctx.compile(self.backend.isa()).map_err(|e| {
|
||||||
let code_size;
|
info!(
|
||||||
let compiled = {
|
"defining function {}: {}",
|
||||||
code_size = ctx.compile(self.backend.isa()).map_err(|e| {
|
func,
|
||||||
info!(
|
ctx.func.display(self.backend.isa())
|
||||||
"defining function {}: {}",
|
);
|
||||||
func,
|
ModuleError::Compilation(e)
|
||||||
ctx.func.display(self.backend.isa())
|
})?;
|
||||||
);
|
|
||||||
ModuleError::Compilation(e)
|
|
||||||
})?;
|
|
||||||
|
|
||||||
let info = &self.contents.functions[func];
|
let info = &self.contents.functions[func];
|
||||||
if info.compiled.is_some() {
|
if info.compiled.is_some() {
|
||||||
return Err(ModuleError::DuplicateDefinition(info.decl.name.clone()));
|
return Err(ModuleError::DuplicateDefinition(info.decl.name.clone()));
|
||||||
}
|
}
|
||||||
if !info.decl.linkage.is_definable() {
|
if !info.decl.linkage.is_definable() {
|
||||||
return Err(ModuleError::InvalidImportDefinition(info.decl.name.clone()));
|
return Err(ModuleError::InvalidImportDefinition(info.decl.name.clone()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let compiled = Some(self.backend.define_function(
|
||||||
|
&info.decl.name,
|
||||||
|
ctx,
|
||||||
|
&ModuleNamespace::<B> {
|
||||||
|
contents: &self.contents,
|
||||||
|
},
|
||||||
|
code_size,
|
||||||
|
)?);
|
||||||
|
|
||||||
Some(self.backend.define_function(
|
|
||||||
&info.decl.name,
|
|
||||||
ctx,
|
|
||||||
&ModuleNamespace::<B> {
|
|
||||||
contents: &self.contents,
|
|
||||||
},
|
|
||||||
code_size,
|
|
||||||
)?)
|
|
||||||
};
|
|
||||||
self.contents.functions[func].compiled = compiled;
|
self.contents.functions[func].compiled = compiled;
|
||||||
self.functions_to_finalize.push(func);
|
self.functions_to_finalize.push(func);
|
||||||
Ok(peek_compiled(code_size, &ctx, self.backend.isa()))
|
Ok(code_size)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Define a function, producing the data contents from the given `DataContext`.
|
/// Define a function, producing the data contents from the given `DataContext`.
|
||||||
@@ -679,6 +674,11 @@ where
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return the target isa
|
||||||
|
pub fn isa(&self) -> &isa::TargetIsa {
|
||||||
|
self.backend.isa()
|
||||||
|
}
|
||||||
|
|
||||||
/// Consume the module and return the resulting `Product`. Some `Backend`
|
/// Consume the module and return the resulting `Product`. Some `Backend`
|
||||||
/// implementations may provide additional functionality available after
|
/// implementations may provide additional functionality available after
|
||||||
/// a `Module` is complete.
|
/// a `Module` is complete.
|
||||||
|
|||||||
Reference in New Issue
Block a user