Struct llvm_rs::Module

source ·
pub struct Module(_);
Expand description

Represents a single compilation unit of code.

This is attached to the lifetime of the context that constructs it, but is owned by the CSemiBox.

Implementations§

Create a new module in the context given with the name given.

The lifetime of the module will match the lifetime of the context you instance it in because the context contains it.

use llvm_rs::*;
let context = Context::new();
let context = context.as_semi();
let module = Module::new("name", &context);
println!("{:?}", module)

Add a global to the module with the given type and name.

Add a global variable to the module with the given type, name and initial value.

Add a global variable to the module with the given type, name and initial value.

Add a global to the module with the given type and name.

Get the global with the name given, or None if no global with that name exists.

Parse this bitcode file into a module, or return an error string.

Write this module’s bitcode to the path given.

Parse IR assembly unto a module, or return an error string.

Add a function to the module with the name given.

Returns the function with the name given, or None if no function with that name exists.

Returns the type with the name given, or `None`` if no type with that name exists.

Clone this module.

Optimize this module with the given optimization level and size level.

This runs passes depending on the levels given.

Returns the target data of this module represented as a string

Set the target data of this module to the target data string given.

Verify that the module is safe to run, returning a string detailing the error when an error occurs.

Compile the module into an object file at the given location.

Note that this uses the LLVM tool llc to do this, which may or may not be installed on the user’s machine.

Link a module into this module, returning an error string if an error occurs.

This does not destroy the source module.

Trait Implementations§

Formats the value using the given formatter. Read more
What a reference to this type represents as a C pointer.
Destroy the contents at the pointer’s location. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Returns a reference to the context that owns this value. Read more

Iterate through the functions in the module

The type of the elements being iterated over.
Which kind of iterator are we turning this into?
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.