Merge remote-tracking branch 'origin/master' into no_std
This commit is contained in:
@@ -14,6 +14,9 @@ pub trait Backend
|
||||
where
|
||||
Self: marker::Sized,
|
||||
{
|
||||
/// A builder for constructing `Backend` instances.
|
||||
type Builder;
|
||||
|
||||
/// The results of compiling a function.
|
||||
type CompiledFunction;
|
||||
|
||||
@@ -21,13 +24,21 @@ where
|
||||
type CompiledData;
|
||||
|
||||
/// The completed output artifact for a function, if this is meaningful for
|
||||
/// the Backend.
|
||||
/// the `Backend`.
|
||||
type FinalizedFunction;
|
||||
|
||||
/// The completed output artifact for a data object, if this is meaningful for
|
||||
/// the Backend.
|
||||
/// 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.
|
||||
type Product;
|
||||
|
||||
/// Create a new `Backend` instance.
|
||||
fn new(Self::Builder) -> Self;
|
||||
|
||||
/// Return the `TargetIsa` to compile for.
|
||||
fn isa(&self) -> &TargetIsa;
|
||||
|
||||
@@ -94,4 +105,8 @@ where
|
||||
data: &Self::CompiledData,
|
||||
namespace: &ModuleNamespace<Self>,
|
||||
) -> Self::FinalizedData;
|
||||
|
||||
/// Consume this `Backend` and return a result. Some implementations may
|
||||
/// provide additional functionality through this result.
|
||||
fn finish(self) -> Self::Product;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ mod tests {
|
||||
fn basic_data_context() {
|
||||
let mut data_ctx = DataContext::new();
|
||||
{
|
||||
let description = data_ctx.description();
|
||||
let description = &data_ctx.description;
|
||||
assert_eq!(description.writable, Writability::Readonly);
|
||||
assert_eq!(description.init, Init::Uninitialized);
|
||||
assert!(description.function_decls.is_empty());
|
||||
@@ -177,7 +177,7 @@ mod tests {
|
||||
|
||||
data_ctx.clear();
|
||||
{
|
||||
let description = data_ctx.description();
|
||||
let description = &data_ctx.description;
|
||||
assert_eq!(description.writable, Writability::Readonly);
|
||||
assert_eq!(description.init, Init::Uninitialized);
|
||||
assert!(description.function_decls.is_empty());
|
||||
|
||||
@@ -236,14 +236,14 @@ where
|
||||
B: Backend,
|
||||
{
|
||||
/// Create a new `Module`.
|
||||
pub fn new(backend: B) -> Self {
|
||||
pub fn new(backend_builder: B::Builder) -> Self {
|
||||
Self {
|
||||
names: HashMap::new(),
|
||||
contents: ModuleContents {
|
||||
functions: PrimaryMap::new(),
|
||||
data_objects: PrimaryMap::new(),
|
||||
},
|
||||
backend,
|
||||
backend: B::new(backend_builder),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -532,10 +532,10 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
/// Consume the module and return its contained `Backend`. Some `Backend`
|
||||
/// implementations have additional features not available through the
|
||||
/// `Module` interface.
|
||||
pub fn consume(self) -> B {
|
||||
self.backend
|
||||
/// Consume the module and return the resulting `Product`. Some `Backend`
|
||||
/// implementations may provide additional functionality available after
|
||||
/// a `Module` is complete.
|
||||
pub fn finish(self) -> B::Product {
|
||||
self.backend.finish()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user