[−][src]Struct cranelift_module::Module
A Module
is a utility for collecting functions and data objects, and linking them together.
Methods
impl<B> Module<B> where
B: Backend,
[src]
B: Backend,
pub fn new(backend_builder: B::Builder) -> Self
[src]
Create a new Module
.
pub fn get_name(&self, name: &str) -> Option<FuncOrDataId>
[src]
Get the module identifier for a given name, if that name has been declared.
pub fn target_config(&self) -> TargetFrontendConfig
[src]
Return the target information needed by frontends to produce Cranelift IR for the current target.
pub fn make_context(&self) -> Context
[src]
Create a new Context
initialized for use with this Module
.
This ensures that the Context
is initialized with the default calling
convention for the TargetIsa
.
pub fn clear_context(&self, ctx: &mut Context)
[src]
Clear the given Context
and reset it for use with a new function.
This ensures that the Context
is initialized with the default calling
convention for the TargetIsa
.
pub fn make_signature(&self) -> Signature
[src]
Create a new empty Signature
with the default calling convention for
the TargetIsa
, to which parameter and return types can be added for
declaring a function to be called by this Module
.
pub fn clear_signature(&self, sig: &mut Signature)
[src]
Clear the given Signature
and reset for use with a new function.
This ensures that the Signature
is initialized with the default
calling convention for the TargetIsa
.
pub fn declare_function(
&mut self,
name: &str,
linkage: Linkage,
signature: &Signature
) -> ModuleResult<FuncId>
[src]
&mut self,
name: &str,
linkage: Linkage,
signature: &Signature
) -> ModuleResult<FuncId>
Declare a function in this module.
pub fn declare_data(
&mut self,
name: &str,
linkage: Linkage,
writable: bool
) -> ModuleResult<DataId>
[src]
&mut self,
name: &str,
linkage: Linkage,
writable: bool
) -> ModuleResult<DataId>
Declare a data object in this module.
pub fn declare_func_in_func(
&self,
func: FuncId,
in_func: &mut Function
) -> FuncRef
[src]
&self,
func: FuncId,
in_func: &mut Function
) -> FuncRef
Use this when you're building the IR of a function to reference a function.
TODO: Coalesce redundant decls and signatures. TODO: Look into ways to reduce the risk of using a FuncRef in the wrong function.
pub fn declare_data_in_func(
&self,
data: DataId,
func: &mut Function
) -> GlobalValue
[src]
&self,
data: DataId,
func: &mut Function
) -> GlobalValue
Use this when you're building the IR of a function to reference a data object.
TODO: Same as above.
pub fn declare_func_in_data(
&self,
func: FuncId,
ctx: &mut DataContext
) -> FuncRef
[src]
&self,
func: FuncId,
ctx: &mut DataContext
) -> FuncRef
TODO: Same as above.
pub fn declare_data_in_data(
&self,
data: DataId,
ctx: &mut DataContext
) -> GlobalValue
[src]
&self,
data: DataId,
ctx: &mut DataContext
) -> GlobalValue
TODO: Same as above.
pub fn define_function(
&mut self,
func: FuncId,
ctx: &mut Context
) -> ModuleResult<CodeOffset>
[src]
&mut self,
func: FuncId,
ctx: &mut Context
) -> ModuleResult<CodeOffset>
Define a function, producing the function body from the given Context
.
Returns the size of the function's code.
Note: After calling this function the given Context
will contain the compiled function.
pub fn define_data(
&mut self,
data: DataId,
data_ctx: &DataContext
) -> ModuleResult<()>
[src]
&mut self,
data: DataId,
data_ctx: &DataContext
) -> ModuleResult<()>
Define a function, producing the data contents from the given DataContext
.
pub fn write_data_funcaddr(
&mut self,
data: DataId,
offset: usize,
what: FuncRef
)
[src]
&mut self,
data: DataId,
offset: usize,
what: FuncRef
)
Write the address of what
into the data for data
at offset
. data
must refer to a
defined data object.
pub fn write_data_dataaddr(
&mut self,
data: DataId,
offset: usize,
what: GlobalValue,
addend: Addend
)
[src]
&mut self,
data: DataId,
offset: usize,
what: GlobalValue,
addend: Addend
)
Write the address of what
plus addend
into the data for data
at offset
. data
must
refer to a defined data object.
pub fn finalize_definitions(&mut self)
[src]
Finalize all functions and data objects that are defined but not yet finalized. All symbols referenced in their bodies that are declared as needing a definition must be defined by this point.
Use get_finalized_function
and get_finalized_data
to obtain the final
artifacts.
pub fn get_finalized_function(&mut self, func: FuncId) -> B::FinalizedFunction
[src]
Return the finalized artifact from the backend, if it provides one.
pub fn get_finalized_data(&mut self, data: DataId) -> B::FinalizedData
[src]
Return the finalized artifact from the backend, if it provides one.
pub fn isa(&self) -> &dyn TargetIsa
[src]
Return the target isa
pub fn finish(self) -> B::Product
[src]
Consume the module and return the resulting Product
. Some Backend
implementations may provide additional functionality available after
a Module
is complete.
Auto Trait Implementations
impl<B> Send for Module<B> where
B: Send,
<B as Backend>::CompiledData: Send,
<B as Backend>::CompiledFunction: Send,
B: Send,
<B as Backend>::CompiledData: Send,
<B as Backend>::CompiledFunction: Send,
impl<B> Sync for Module<B> where
B: Sync,
<B as Backend>::CompiledData: Sync,
<B as Backend>::CompiledFunction: Sync,
B: Sync,
<B as Backend>::CompiledData: Sync,
<B as Backend>::CompiledFunction: Sync,
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,