Trait cranelift_module::Module [−][src]
pub trait Module {}Show methods
fn isa(&self) -> &dyn TargetIsa; fn declarations(&self) -> &ModuleDeclarations; fn declare_function(
&mut self,
name: &str,
linkage: Linkage,
signature: &Signature
) -> ModuleResult<FuncId>; fn declare_anonymous_function(
&mut self,
signature: &Signature
) -> ModuleResult<FuncId>; fn declare_data(
&mut self,
name: &str,
linkage: Linkage,
writable: bool,
tls: bool
) -> ModuleResult<DataId>; fn declare_anonymous_data(
&mut self,
writable: bool,
tls: bool
) -> ModuleResult<DataId>; fn define_function(
&mut self,
func: FuncId,
ctx: &mut Context,
trap_sink: &mut dyn TrapSink,
stack_map_sink: &mut dyn StackMapSink
) -> ModuleResult<ModuleCompiledFunction>; fn define_function_bytes(
&mut self,
func: FuncId,
bytes: &[u8],
relocs: &[RelocRecord]
) -> ModuleResult<ModuleCompiledFunction>; fn define_data(
&mut self,
data: DataId,
data_ctx: &DataContext
) -> ModuleResult<()>; fn get_name(&self, name: &str) -> Option<FuncOrDataId> { ... } fn target_config(&self) -> TargetFrontendConfig { ... } fn make_context(&self) -> Context { ... } fn clear_context(&self, ctx: &mut Context) { ... } fn make_signature(&self) -> Signature { ... } fn clear_signature(&self, sig: &mut Signature) { ... } fn declare_func_in_func(
&self,
func: FuncId,
in_func: &mut Function
) -> FuncRef { ... } fn declare_data_in_func(
&self,
data: DataId,
func: &mut Function
) -> GlobalValue { ... } fn declare_func_in_data(
&self,
func: FuncId,
ctx: &mut DataContext
) -> FuncRef { ... } fn declare_data_in_data(
&self,
data: DataId,
ctx: &mut DataContext
) -> GlobalValue { ... }
Expand description
A Module
is a utility for collecting functions and data objects, and linking them together.
Required methods
fn declarations(&self) -> &ModuleDeclarations
[src]
fn declarations(&self) -> &ModuleDeclarations
[src]Get all declarations in this module.
fn declare_function(
&mut self,
name: &str,
linkage: Linkage,
signature: &Signature
) -> ModuleResult<FuncId>
[src]
fn declare_function(
&mut self,
name: &str,
linkage: Linkage,
signature: &Signature
) -> ModuleResult<FuncId>
[src]Declare a function in this module.
fn declare_anonymous_function(
&mut self,
signature: &Signature
) -> ModuleResult<FuncId>
[src]
fn declare_anonymous_function(
&mut self,
signature: &Signature
) -> ModuleResult<FuncId>
[src]Declare an anonymous function in this module.
fn declare_data(
&mut self,
name: &str,
linkage: Linkage,
writable: bool,
tls: bool
) -> ModuleResult<DataId>
[src]
fn declare_data(
&mut self,
name: &str,
linkage: Linkage,
writable: bool,
tls: bool
) -> ModuleResult<DataId>
[src]Declare a data object in this module.
fn declare_anonymous_data(
&mut self,
writable: bool,
tls: bool
) -> ModuleResult<DataId>
[src]
fn declare_anonymous_data(
&mut self,
writable: bool,
tls: bool
) -> ModuleResult<DataId>
[src]Declare an anonymous data object in this module.
fn define_function(
&mut self,
func: FuncId,
ctx: &mut Context,
trap_sink: &mut dyn TrapSink,
stack_map_sink: &mut dyn StackMapSink
) -> ModuleResult<ModuleCompiledFunction>
[src]
fn define_function(
&mut self,
func: FuncId,
ctx: &mut Context,
trap_sink: &mut dyn TrapSink,
stack_map_sink: &mut dyn StackMapSink
) -> ModuleResult<ModuleCompiledFunction>
[src]Define a function, producing the function body from the given Context
.
Returns the size of the function’s code and constant data.
Note: After calling this function the given Context
will contain the compiled function.
fn define_function_bytes(
&mut self,
func: FuncId,
bytes: &[u8],
relocs: &[RelocRecord]
) -> ModuleResult<ModuleCompiledFunction>
[src]
fn define_function_bytes(
&mut self,
func: FuncId,
bytes: &[u8],
relocs: &[RelocRecord]
) -> ModuleResult<ModuleCompiledFunction>
[src]Define a function, taking the function body from the given bytes
.
This function is generally only useful if you need to precisely specify
the emitted instructions for some reason; otherwise, you should use
define_function
.
Returns the size of the function’s code.
fn define_data(
&mut self,
data: DataId,
data_ctx: &DataContext
) -> ModuleResult<()>
[src]
fn define_data(
&mut self,
data: DataId,
data_ctx: &DataContext
) -> ModuleResult<()>
[src]Define a data object, producing the data contents from the given DataContext
.
Provided methods
fn get_name(&self, name: &str) -> Option<FuncOrDataId>
[src]
fn get_name(&self, name: &str) -> Option<FuncOrDataId>
[src]Get the module identifier for a given name, if that name has been declared.
fn target_config(&self) -> TargetFrontendConfig
[src]
fn target_config(&self) -> TargetFrontendConfig
[src]Return the target information needed by frontends to produce Cranelift IR for the current target.
fn make_context(&self) -> Context
[src]
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
.
fn clear_context(&self, ctx: &mut Context)
[src]
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
.
fn make_signature(&self) -> Signature
[src]
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
.
fn clear_signature(&self, sig: &mut Signature)
[src]
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
.
fn declare_func_in_func(&self, func: FuncId, in_func: &mut Function) -> FuncRef
[src]
fn declare_func_in_func(&self, func: FuncId, in_func: &mut Function) -> FuncRef
[src]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.
fn declare_data_in_func(&self, data: DataId, func: &mut Function) -> GlobalValue
[src]
fn declare_data_in_func(&self, data: DataId, func: &mut Function) -> GlobalValue
[src]Use this when you’re building the IR of a function to reference a data object.
TODO: Same as above.
fn declare_func_in_data(&self, func: FuncId, ctx: &mut DataContext) -> FuncRef
[src]
fn declare_func_in_data(&self, func: FuncId, ctx: &mut DataContext) -> FuncRef
[src]TODO: Same as above.
fn declare_data_in_data(
&self,
data: DataId,
ctx: &mut DataContext
) -> GlobalValue
[src]
fn declare_data_in_data(
&self,
data: DataId,
ctx: &mut DataContext
) -> GlobalValue
[src]TODO: Same as above.
Implementations on Foreign Types
fn declare_function(
&mut self,
name: &str,
linkage: Linkage,
signature: &Signature
) -> ModuleResult<FuncId>
[src]fn declare_data(
&mut self,
name: &str,
linkage: Linkage,
writable: bool,
tls: bool
) -> ModuleResult<DataId>
[src]fn define_function(
&mut self,
func: FuncId,
ctx: &mut Context,
trap_sink: &mut dyn TrapSink,
stack_map_sink: &mut dyn StackMapSink
) -> ModuleResult<ModuleCompiledFunction>
[src]fn define_function_bytes(
&mut self,
func: FuncId,
bytes: &[u8],
relocs: &[RelocRecord]
) -> ModuleResult<ModuleCompiledFunction>
[src]