mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-08-08 05:55:42 +00:00
@@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "revive-compilation-target"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
inkwell = { workspace = true }
|
||||
@@ -0,0 +1,15 @@
|
||||
use inkwell::{builder::Builder, module::Module, values::FunctionValue};
|
||||
|
||||
/// [Environment] describes EVM runtime functionality.
|
||||
pub trait Environment<'ctx> {
|
||||
const STACK_SIZE: u32 = 1024 * 32;
|
||||
const CALLDATA_SIZE: u32 = 0x10000;
|
||||
const RETURNDATA_SIZE: u32 = 0x10000;
|
||||
const MEMORY_SIZE: u32 = 0x100000;
|
||||
|
||||
/// Build a module containing all required runtime exports and imports.
|
||||
///
|
||||
/// The `start` function is the entrypoint to the contract logic.
|
||||
/// The returned `Module` is expected to call `start` somewhere.
|
||||
fn call_start(&'ctx self, builder: &Builder<'ctx>, start: FunctionValue<'ctx>) -> Module<'ctx>;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
pub mod environment;
|
||||
pub mod target;
|
||||
@@ -0,0 +1,27 @@
|
||||
use inkwell::{
|
||||
context::Context,
|
||||
module::Module,
|
||||
targets::{CodeModel, RelocMode},
|
||||
OptimizationLevel,
|
||||
};
|
||||
|
||||
pub trait Target<'ctx> {
|
||||
const TARGET_NAME: &'ctx str;
|
||||
const TARGET_TRIPLE: &'ctx str;
|
||||
const TARGET_FEATURES: &'ctx str;
|
||||
const CPU: &'ctx str;
|
||||
const RELOC_MODE: RelocMode = RelocMode::Default;
|
||||
const CODE_MODEL: CodeModel = CodeModel::Default;
|
||||
|
||||
fn initialize_llvm() {
|
||||
inkwell::targets::Target::initialize_riscv(&Default::default());
|
||||
}
|
||||
|
||||
fn context(&self) -> &Context;
|
||||
|
||||
fn libraries(&'ctx self) -> Vec<Module<'ctx>>;
|
||||
|
||||
fn link(&self, blob: &[u8]) -> Vec<u8>;
|
||||
|
||||
fn optimization_level(&self) -> OptimizationLevel;
|
||||
}
|
||||
Reference in New Issue
Block a user