Remove get_finalized_*
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
//! Defines the `Backend` trait.
|
||||
|
||||
use crate::DataContext;
|
||||
use crate::{DataContext, FuncOrDataId};
|
||||
use crate::DataId;
|
||||
use crate::FuncId;
|
||||
use crate::Linkage;
|
||||
@@ -11,7 +11,7 @@ use cranelift_codegen::isa::TargetIsa;
|
||||
use cranelift_codegen::Context;
|
||||
use cranelift_codegen::{binemit, ir};
|
||||
|
||||
use std::borrow::ToOwned;
|
||||
use std::{borrow::ToOwned, collections::HashMap};
|
||||
use std::boxed::Box;
|
||||
use std::string::String;
|
||||
|
||||
@@ -38,14 +38,6 @@ where
|
||||
/// The results of "compiling" a data object.
|
||||
type CompiledData;
|
||||
|
||||
/// The completed output artifact for a function, if this is meaningful for
|
||||
/// the `Backend`.
|
||||
type FinalizedFunction;
|
||||
|
||||
/// The completed output artifact for a data object, if this is meaningful for
|
||||
/// the `Backend`.
|
||||
type FinalizedData;
|
||||
|
||||
/// This is an object returned by `Module`'s
|
||||
/// [`finish`](struct.Module.html#method.finish) function,
|
||||
/// if the `Backend` has a purpose for this.
|
||||
@@ -140,10 +132,7 @@ where
|
||||
id: FuncId,
|
||||
func: &Self::CompiledFunction,
|
||||
contents: &ModuleContents<Self>,
|
||||
) -> Self::FinalizedFunction;
|
||||
|
||||
/// Return the finalized artifact from the backend, if relevant.
|
||||
fn get_finalized_function(&self, func: &Self::CompiledFunction) -> Self::FinalizedFunction;
|
||||
);
|
||||
|
||||
/// Perform all outstanding relocations on the given data object. This requires all
|
||||
/// `Local` and `Export` entities referenced to be defined.
|
||||
@@ -155,10 +144,7 @@ where
|
||||
id: DataId,
|
||||
data: &Self::CompiledData,
|
||||
contents: &ModuleContents<Self>,
|
||||
) -> Self::FinalizedData;
|
||||
|
||||
/// Return the finalized artifact from the backend, if relevant.
|
||||
fn get_finalized_data(&self, data: &Self::CompiledData) -> Self::FinalizedData;
|
||||
);
|
||||
|
||||
/// "Publish" all finalized functions and data objects to their ultimate destinations.
|
||||
///
|
||||
@@ -168,7 +154,11 @@ where
|
||||
|
||||
/// Consume this `Backend` and return a result. Some implementations may
|
||||
/// provide additional functionality through this result.
|
||||
fn finish(self, contents: &ModuleContents<Self>) -> Self::Product;
|
||||
fn finish(
|
||||
self,
|
||||
names: HashMap<String, FuncOrDataId>,
|
||||
contents: ModuleContents<Self>,
|
||||
) -> Self::Product;
|
||||
}
|
||||
|
||||
/// Default names for `ir::LibCall`s. A function by this name is imported into the object as
|
||||
|
||||
@@ -717,34 +717,6 @@ where
|
||||
self.backend.publish();
|
||||
}
|
||||
|
||||
/// Return the finalized artifact from the backend, if it provides one.
|
||||
pub fn get_finalized_function(&mut self, func: FuncId) -> B::FinalizedFunction {
|
||||
let info = &self.contents.functions[func];
|
||||
debug_assert!(
|
||||
!self.functions_to_finalize.iter().any(|x| *x == func),
|
||||
"function not yet finalized"
|
||||
);
|
||||
self.backend.get_finalized_function(
|
||||
info.compiled
|
||||
.as_ref()
|
||||
.expect("function must be compiled before it can be finalized"),
|
||||
)
|
||||
}
|
||||
|
||||
/// Return the finalized artifact from the backend, if it provides one.
|
||||
pub fn get_finalized_data(&mut self, data: DataId) -> B::FinalizedData {
|
||||
let info = &self.contents.data_objects[data];
|
||||
debug_assert!(
|
||||
!self.data_objects_to_finalize.iter().any(|x| *x == data),
|
||||
"data object not yet finalized"
|
||||
);
|
||||
self.backend.get_finalized_data(
|
||||
info.compiled
|
||||
.as_ref()
|
||||
.expect("data object must be compiled before it can be finalized"),
|
||||
)
|
||||
}
|
||||
|
||||
/// Return the target isa
|
||||
pub fn isa(&self) -> &dyn isa::TargetIsa {
|
||||
self.backend.isa()
|
||||
@@ -754,6 +726,6 @@ where
|
||||
/// implementations may provide additional functionality available after
|
||||
/// a `Module` is complete.
|
||||
pub fn finish(self) -> B::Product {
|
||||
self.backend.finish(&self.contents)
|
||||
self.backend.finish(self.names, self.contents)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user