Skip to main content

EvmLlvmBackend

Struct EvmLlvmBackend 

Source
pub struct EvmLlvmBackend {
Show 20 fields pub(crate) cx: &'static Context, pub(crate) _dh: DiagnosticHandlerGuard, pub(crate) bcx: Builder<'static>, pub(crate) module: Module<'static>, pub(crate) exec_engine: Option<ExecutionEngine<'static>>, pub(crate) machine: TargetMachine, pub(crate) ty_void: VoidType<'static>, pub(crate) ty_ptr: PointerType<'static>, pub(crate) ty_i1: IntType<'static>, pub(crate) ty_i8: IntType<'static>, pub(crate) ty_i32: IntType<'static>, pub(crate) ty_i64: IntType<'static>, pub(crate) ty_i256: IntType<'static>, pub(crate) ty_isize: IntType<'static>, pub(crate) aot: bool, pub(crate) debug_assertions: bool, pub(crate) opt_level: OptimizationLevel, pub(crate) function_counter: u32, pub(crate) functions: FxHashMap<u32, (String, FunctionValue<'static>)>, pub(crate) mapped_symbols: FxHashSet<String>,
}
Expand description

The LLVM-based EVM bytecode compiler backend.

Fields§

§cx: &'static Context§_dh: DiagnosticHandlerGuard§bcx: Builder<'static>§module: Module<'static>§exec_engine: Option<ExecutionEngine<'static>>§machine: TargetMachine§ty_void: VoidType<'static>§ty_ptr: PointerType<'static>§ty_i1: IntType<'static>§ty_i8: IntType<'static>§ty_i32: IntType<'static>§ty_i64: IntType<'static>§ty_i256: IntType<'static>§ty_isize: IntType<'static>§aot: bool§debug_assertions: bool§opt_level: OptimizationLevel§function_counter: u32

Separate from functions to have always increasing IDs.

§functions: FxHashMap<u32, (String, FunctionValue<'static>)>§mapped_symbols: FxHashSet<String>

Symbol names that have been registered via add_global_mapping in the MCJIT engine. Used to avoid re-registering builtins when a new module is created after clear_ir.

Implementations§

Source§

impl EvmLlvmBackend

Source

pub fn new(aot: bool, opt_level: OptimizationLevel) -> Result<Self>

Creates a new LLVM backend for the host machine.

Use new_for_target to create a backend for a specific target.

Source

pub fn new_for_target( aot: bool, opt_level: OptimizationLevel, target: &Target, ) -> Result<Self>

Creates a new LLVM backend for the given target.

Source

pub fn cx(&self) -> &Context

Returns the LLVM context.

Source

pub(crate) fn exec_engine(&self) -> &ExecutionEngine<'static>

Source

pub(crate) fn fn_type( &self, ret: Option<BasicTypeEnum<'static>>, params: &[BasicTypeEnum<'static>], ) -> FunctionType<'static>

Source

pub(crate) fn id_to_name(&self, id: u32) -> &str

Source

pub(crate) fn clear_module(&mut self) -> Result<()>

Trait Implementations§

Source§

impl Backend for EvmLlvmBackend

Source§

type Builder<'a> = EvmLlvmBuilder<'a> where Self: 'a

Source§

type FuncId = u32

Source§

fn ir_extension(&self) -> &'static str

Source§

fn set_module_name(&mut self, name: &str)

Source§

fn set_is_dumping(&mut self, yes: bool)

Source§

fn set_debug_assertions(&mut self, yes: bool)

Source§

fn opt_level(&self) -> OptimizationLevel

Source§

fn set_opt_level(&mut self, level: OptimizationLevel)

Source§

fn is_aot(&self) -> bool

Source§

fn function_name_is_unique(&self, name: &str) -> bool

Source§

fn dump_ir(&mut self, path: &Path) -> Result<()>

Source§

fn dump_disasm(&mut self, path: &Path) -> Result<()>

Source§

fn build_function( &mut self, name: &str, ret: Option<Self::Type>, params: &[Self::Type], param_names: &[&str], linkage: Linkage, ) -> Result<(Self::Builder<'_>, Self::FuncId)>

Source§

fn verify_module(&mut self) -> Result<()>

Source§

fn optimize_module(&mut self) -> Result<()>

Source§

fn write_object<W: Write>(&mut self, w: W) -> Result<()>

Source§

fn jit_function(&mut self, id: Self::FuncId) -> Result<usize>

Source§

fn clear_ir(&mut self) -> Result<()>

Clears the IR module, freeing memory used by IR representations. Read more
Source§

unsafe fn free_function(&mut self, id: Self::FuncId) -> Result<()>

Source§

unsafe fn free_all_functions(&mut self) -> Result<()>

Source§

impl BackendTypes for EvmLlvmBackend

Source§

type Type = BasicTypeEnum<'static>

Source§

type Value = BasicValueEnum<'static>

Source§

type StackSlot = PointerValue<'static>

Source§

type BasicBlock = BasicBlock<'static>

Source§

type Function = FunctionValue<'static>

Source§

impl Debug for EvmLlvmBackend

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for EvmLlvmBackend

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl TypeMethods for EvmLlvmBackend

Source§

fn type_ptr(&self) -> Self::Type

Source§

fn type_ptr_sized_int(&self) -> Self::Type

Source§

fn type_int(&self, bits: u32) -> Self::Type

Source§

fn type_array(&self, ty: Self::Type, size: u32) -> Self::Type

Source§

fn type_bit_width(&self, ty: Self::Type) -> u32

Source§

impl Send for EvmLlvmBackend

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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>,

Source§

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>,

Source§

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

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 304 bytes