Struct cranelift_object::ObjectModule

source ·
pub struct ObjectModule { /* private fields */ }
Expand description

An ObjectModule implements Module and emits “.o” files using the object library.

See the ObjectBuilder for a convenient way to construct ObjectModule instances.

Implementations§

source§

impl ObjectModule

source

pub fn new(builder: ObjectBuilder) -> Self

Create a new ObjectModule using the given Cranelift target.

source§

impl ObjectModule

source

pub fn finish(self) -> ObjectProduct

Finalize all relocations and output an object.

Trait Implementations§

source§

impl Module for ObjectModule

source§

fn isa(&self) -> &dyn TargetIsa

Return the TargetIsa to compile for.
source§

fn declarations(&self) -> &ModuleDeclarations

Get all declarations in this module.
source§

fn declare_function( &mut self, name: &str, linkage: Linkage, signature: &Signature ) -> ModuleResult<FuncId>

Declare a function in this module.
source§

fn declare_anonymous_function( &mut self, signature: &Signature ) -> ModuleResult<FuncId>

Declare an anonymous function in this module.
source§

fn declare_data( &mut self, name: &str, linkage: Linkage, writable: bool, tls: bool ) -> ModuleResult<DataId>

Declare a data object in this module.
source§

fn declare_anonymous_data( &mut self, writable: bool, tls: bool ) -> ModuleResult<DataId>

Declare an anonymous data object in this module.
source§

fn define_function_with_control_plane( &mut self, func_id: FuncId, ctx: &mut Context, ctrl_plane: &mut ControlPlane ) -> ModuleResult<()>

Define a function, producing the function body from the given Context. Read more
source§

fn define_function_bytes( &mut self, func_id: FuncId, func: &Function, alignment: u64, bytes: &[u8], relocs: &[FinalizedMachReloc] ) -> ModuleResult<()>

Define a function, taking the function body from the given bytes. Read more
source§

fn define_data( &mut self, data_id: DataId, data: &DataDescription ) -> ModuleResult<()>

Define a data object, producing the data contents from the given DataContext.
source§

fn get_name(&self, name: &str) -> Option<FuncOrDataId>

Get the module identifier for a given name, if that name has been declared.
source§

fn target_config(&self) -> TargetFrontendConfig

Return the target information needed by frontends to produce Cranelift IR for the current target.
source§

fn make_context(&self) -> Context

Create a new Context initialized for use with this Module. Read more
source§

fn clear_context(&self, ctx: &mut Context)

Clear the given Context and reset it for use with a new function. Read more
source§

fn make_signature(&self) -> Signature

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.
source§

fn clear_signature(&self, sig: &mut Signature)

Clear the given Signature and reset for use with a new function. Read more
source§

fn declare_func_in_func( &mut self, func_id: FuncId, func: &mut Function ) -> FuncRef

Use this when you’re building the IR of a function to reference a function. Read more
source§

fn declare_data_in_func(&self, data: DataId, func: &mut Function) -> GlobalValue

Use this when you’re building the IR of a function to reference a data object. Read more
source§

fn declare_func_in_data( &self, func_id: FuncId, data: &mut DataDescription ) -> FuncRef

TODO: Same as above.
source§

fn declare_data_in_data( &self, data_id: DataId, data: &mut DataDescription ) -> GlobalValue

TODO: Same as above.
source§

fn define_function( &mut self, func: FuncId, ctx: &mut Context ) -> Result<(), ModuleError>

Define a function, producing the function body from the given Context. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.