Trait cretonne_module::Backend
[−]
[src]
pub trait Backend where
Self: Sized, { type CompiledFunction; type CompiledData; type FinalizedFunction; type FinalizedData; fn isa(&self) -> &TargetIsa; fn declare_function(&mut self, name: &str, linkage: Linkage); fn declare_data(&mut self, name: &str, linkage: Linkage, writable: bool); fn define_function(
&mut self,
name: &str,
ctx: &Context,
namespace: &ModuleNamespace<Self>,
code_size: u32
) -> Result<Self::CompiledFunction, CtonError>; fn define_data(
&mut self,
name: &str,
data_ctx: &DataContext,
namespace: &ModuleNamespace<Self>
) -> Result<Self::CompiledData, CtonError>; fn write_data_funcaddr(
&mut self,
data: &mut Self::CompiledData,
offset: usize,
what: FuncRef
); fn write_data_dataaddr(
&mut self,
data: &mut Self::CompiledData,
offset: usize,
what: GlobalVar,
addend: Addend
); fn finalize_function(
&mut self,
func: &Self::CompiledFunction,
namespace: &ModuleNamespace<Self>
) -> Self::FinalizedFunction; fn finalize_data(
&mut self,
data: &Self::CompiledData,
namespace: &ModuleNamespace<Self>
) -> Self::FinalizedData; }
A Backend
implements the functionality needed to support a Module
.
Associated Types
type CompiledFunction
The results of compiling a function.
type CompiledData
The results of "compiling" a data object.
type FinalizedFunction
The completed output artifact for a function, if this is meaningful for the Backend.
type FinalizedData
The completed output artifact for a data object, if this is meaningful for the Backend.
Required Methods
fn isa(&self) -> &TargetIsa
Return the TargetIsa
to compile for.
fn declare_function(&mut self, name: &str, linkage: Linkage)
Declare a function.
fn declare_data(&mut self, name: &str, linkage: Linkage, writable: bool)
Declare a data object.
fn define_function(
&mut self,
name: &str,
ctx: &Context,
namespace: &ModuleNamespace<Self>,
code_size: u32
) -> Result<Self::CompiledFunction, CtonError>
&mut self,
name: &str,
ctx: &Context,
namespace: &ModuleNamespace<Self>,
code_size: u32
) -> Result<Self::CompiledFunction, CtonError>
Define a function, producing the function body from the given Context
.
Functions must be declared before being defined.
fn define_data(
&mut self,
name: &str,
data_ctx: &DataContext,
namespace: &ModuleNamespace<Self>
) -> Result<Self::CompiledData, CtonError>
&mut self,
name: &str,
data_ctx: &DataContext,
namespace: &ModuleNamespace<Self>
) -> Result<Self::CompiledData, CtonError>
Define a zero-initialized data object of the given size.
Data objects must be declared before being defined.
TODO: Is CtonError the right error code here?
fn write_data_funcaddr(
&mut self,
data: &mut Self::CompiledData,
offset: usize,
what: FuncRef
)
&mut self,
data: &mut Self::CompiledData,
offset: usize,
what: FuncRef
)
Write the address of what
into the data for data
at offset
. data
must refer to a
defined data object.
fn write_data_dataaddr(
&mut self,
data: &mut Self::CompiledData,
offset: usize,
what: GlobalVar,
addend: Addend
)
&mut self,
data: &mut Self::CompiledData,
offset: usize,
what: GlobalVar,
addend: Addend
)
Write the address of what
plus addend
into the data for data
at offset
. data
must
refer to a defined data object.
fn finalize_function(
&mut self,
func: &Self::CompiledFunction,
namespace: &ModuleNamespace<Self>
) -> Self::FinalizedFunction
&mut self,
func: &Self::CompiledFunction,
namespace: &ModuleNamespace<Self>
) -> Self::FinalizedFunction
Perform all outstanding relocations on the given function. This requires all Local
and Export
entities referenced to be defined.
fn finalize_data(
&mut self,
data: &Self::CompiledData,
namespace: &ModuleNamespace<Self>
) -> Self::FinalizedData
&mut self,
data: &Self::CompiledData,
namespace: &ModuleNamespace<Self>
) -> Self::FinalizedData
Perform all outstanding relocations on the given data object. This requires all
Local
and Export
entities referenced to be defined.