mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-12 10:31:04 +00:00
@@ -2,12 +2,12 @@
|
||||
|
||||
/// Translates the contract hash copying.
|
||||
pub fn contract_hash<'ctx, D>(
|
||||
context: &mut revive_llvm_context::EraVMContext<'ctx, D>,
|
||||
context: &mut revive_llvm_context::PolkaVMContext<'ctx, D>,
|
||||
offset: inkwell::values::IntValue<'ctx>,
|
||||
value: inkwell::values::IntValue<'ctx>,
|
||||
) -> anyhow::Result<()>
|
||||
where
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
let offset = context.builder().build_int_add(
|
||||
offset,
|
||||
@@ -17,21 +17,21 @@ where
|
||||
"datacopy_contract_hash_offset",
|
||||
)?;
|
||||
|
||||
revive_llvm_context::eravm_evm_memory::store(context, offset, value)?;
|
||||
revive_llvm_context::polkavm_evm_memory::store(context, offset, value)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Translates the library marker copying.
|
||||
pub fn library_marker<D>(
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
context: &mut revive_llvm_context::PolkaVMContext<D>,
|
||||
offset: u64,
|
||||
value: u64,
|
||||
) -> anyhow::Result<()>
|
||||
where
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
revive_llvm_context::eravm_evm_memory::store_byte(
|
||||
revive_llvm_context::polkavm_evm_memory::store_byte(
|
||||
context,
|
||||
context.field_const(offset),
|
||||
context.field_const(value),
|
||||
@@ -42,12 +42,12 @@ where
|
||||
|
||||
/// Translates the static data copying.
|
||||
pub fn static_data<'ctx, D>(
|
||||
context: &mut revive_llvm_context::EraVMContext<'ctx, D>,
|
||||
context: &mut revive_llvm_context::PolkaVMContext<'ctx, D>,
|
||||
destination: inkwell::values::IntValue<'ctx>,
|
||||
source: &str,
|
||||
) -> anyhow::Result<()>
|
||||
where
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
let mut offset = 0;
|
||||
for (index, chunk) in source
|
||||
@@ -68,7 +68,7 @@ where
|
||||
format!("datacopy_destination_index_{index}").as_str(),
|
||||
)?;
|
||||
let datacopy_value = context.field_const_str_hex(value_string.as_str());
|
||||
revive_llvm_context::eravm_evm_memory::store(
|
||||
revive_llvm_context::polkavm_evm_memory::store(
|
||||
context,
|
||||
datacopy_destination,
|
||||
datacopy_value,
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
|
||||
/// Translates the unconditional jump.
|
||||
pub fn unconditional<D>(
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
context: &mut revive_llvm_context::PolkaVMContext<D>,
|
||||
destination: num::BigUint,
|
||||
stack_hash: md5::Digest,
|
||||
) -> anyhow::Result<()>
|
||||
where
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
let code_type = context
|
||||
.code_type()
|
||||
.ok_or_else(|| anyhow::anyhow!("The contract code part type is undefined"))?;
|
||||
let block_key = revive_llvm_context::EraVMFunctionBlockKey::new(code_type, destination);
|
||||
let block_key = revive_llvm_context::PolkaVMFunctionBlockKey::new(code_type, destination);
|
||||
|
||||
let block = context
|
||||
.current_function()
|
||||
@@ -26,24 +26,24 @@ where
|
||||
|
||||
/// Translates the conditional jump.
|
||||
pub fn conditional<D>(
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
context: &mut revive_llvm_context::PolkaVMContext<D>,
|
||||
destination: num::BigUint,
|
||||
stack_hash: md5::Digest,
|
||||
stack_height: usize,
|
||||
) -> anyhow::Result<()>
|
||||
where
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
let code_type = context
|
||||
.code_type()
|
||||
.ok_or_else(|| anyhow::anyhow!("The contract code part type is undefined"))?;
|
||||
let block_key = revive_llvm_context::EraVMFunctionBlockKey::new(code_type, destination);
|
||||
let block_key = revive_llvm_context::PolkaVMFunctionBlockKey::new(code_type, destination);
|
||||
|
||||
let condition_pointer = context.evmla().stack[stack_height]
|
||||
.to_llvm()
|
||||
.into_pointer_value();
|
||||
let condition = context.build_load(
|
||||
revive_llvm_context::EraVMPointer::new_stack_field(context, condition_pointer),
|
||||
revive_llvm_context::PolkaVMPointer::new_stack_field(context, condition_pointer),
|
||||
format!("conditional_{block_key}_condition").as_str(),
|
||||
)?;
|
||||
let condition = context.builder().build_int_compare(
|
||||
|
||||
@@ -328,11 +328,11 @@ impl Instruction {
|
||||
/// Initializes a recursive function `Call` instruction.
|
||||
pub fn recursive_call(
|
||||
name: String,
|
||||
entry_key: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
entry_key: revive_llvm_context::PolkaVMFunctionBlockKey,
|
||||
stack_hash: md5::Digest,
|
||||
input_size: usize,
|
||||
output_size: usize,
|
||||
return_address: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
return_address: revive_llvm_context::PolkaVMFunctionBlockKey,
|
||||
previous: &Self,
|
||||
) -> Self {
|
||||
Self {
|
||||
|
||||
@@ -300,10 +300,10 @@ pub enum Name {
|
||||
/// The eponymous EVM instruction.
|
||||
CREATE2,
|
||||
|
||||
/// The eponymous EraVM instruction.
|
||||
/// The eponymous PolkaVM instruction.
|
||||
#[serde(rename = "$ZK_CREATE")]
|
||||
ZK_CREATE,
|
||||
/// The eponymous EraVM instruction.
|
||||
/// The eponymous PolkaVM instruction.
|
||||
#[serde(rename = "$ZK_CREATE2")]
|
||||
ZK_CREATE2,
|
||||
|
||||
@@ -370,7 +370,7 @@ pub enum Name {
|
||||
/// The called function name.
|
||||
name: String,
|
||||
/// The called function key.
|
||||
entry_key: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
entry_key: revive_llvm_context::PolkaVMFunctionBlockKey,
|
||||
/// The stack state hash after return.
|
||||
stack_hash: md5::Digest,
|
||||
/// The input size.
|
||||
@@ -378,7 +378,7 @@ pub enum Name {
|
||||
/// The output size.
|
||||
output_size: usize,
|
||||
/// The return address.
|
||||
return_address: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
return_address: revive_llvm_context::PolkaVMFunctionBlockKey,
|
||||
},
|
||||
/// The recursive function return instruction.
|
||||
#[serde(skip)]
|
||||
|
||||
@@ -4,11 +4,11 @@ use inkwell::values::BasicValue;
|
||||
|
||||
/// Translates the ordinar value push.
|
||||
pub fn push<'ctx, D>(
|
||||
context: &mut revive_llvm_context::EraVMContext<'ctx, D>,
|
||||
context: &mut revive_llvm_context::PolkaVMContext<'ctx, D>,
|
||||
value: String,
|
||||
) -> anyhow::Result<inkwell::values::BasicValueEnum<'ctx>>
|
||||
where
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
let result = context
|
||||
.field_type()
|
||||
@@ -23,11 +23,11 @@ where
|
||||
|
||||
/// Translates the block tag label push.
|
||||
pub fn push_tag<'ctx, D>(
|
||||
context: &mut revive_llvm_context::EraVMContext<'ctx, D>,
|
||||
context: &mut revive_llvm_context::PolkaVMContext<'ctx, D>,
|
||||
value: String,
|
||||
) -> anyhow::Result<inkwell::values::BasicValueEnum<'ctx>>
|
||||
where
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
let result = context
|
||||
.field_type()
|
||||
@@ -38,17 +38,17 @@ where
|
||||
|
||||
/// Translates the stack memory duplicate.
|
||||
pub fn dup<'ctx, D>(
|
||||
context: &mut revive_llvm_context::EraVMContext<'ctx, D>,
|
||||
context: &mut revive_llvm_context::PolkaVMContext<'ctx, D>,
|
||||
offset: usize,
|
||||
height: usize,
|
||||
original: &mut Option<String>,
|
||||
) -> anyhow::Result<inkwell::values::BasicValueEnum<'ctx>>
|
||||
where
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
let element = &context.evmla().stack[height - offset - 1];
|
||||
let value = context.build_load(
|
||||
revive_llvm_context::EraVMPointer::new_stack_field(
|
||||
revive_llvm_context::PolkaVMPointer::new_stack_field(
|
||||
context,
|
||||
element.to_llvm().into_pointer_value(),
|
||||
),
|
||||
@@ -62,22 +62,22 @@ where
|
||||
|
||||
/// Translates the stack memory swap.
|
||||
pub fn swap<D>(
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
context: &mut revive_llvm_context::PolkaVMContext<D>,
|
||||
offset: usize,
|
||||
height: usize,
|
||||
) -> anyhow::Result<()>
|
||||
where
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
let top_element = context.evmla().stack[height - 1].to_owned();
|
||||
let top_pointer = revive_llvm_context::EraVMPointer::new_stack_field(
|
||||
let top_pointer = revive_llvm_context::PolkaVMPointer::new_stack_field(
|
||||
context,
|
||||
top_element.to_llvm().into_pointer_value(),
|
||||
);
|
||||
let top_value = context.build_load(top_pointer, format!("swap{offset}_top_value").as_str())?;
|
||||
|
||||
let swap_element = context.evmla().stack[height - offset - 1].to_owned();
|
||||
let swap_pointer = revive_llvm_context::EraVMPointer::new_stack_field(
|
||||
let swap_pointer = revive_llvm_context::PolkaVMPointer::new_stack_field(
|
||||
context,
|
||||
swap_element.to_llvm().into_pointer_value(),
|
||||
);
|
||||
@@ -94,9 +94,9 @@ where
|
||||
}
|
||||
|
||||
/// Translates the stack memory pop.
|
||||
pub fn pop<D>(_context: &mut revive_llvm_context::EraVMContext<D>) -> anyhow::Result<()>
|
||||
pub fn pop<D>(_context: &mut revive_llvm_context::PolkaVMContext<D>) -> anyhow::Result<()>
|
||||
where
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ impl Assembly {
|
||||
/// Gets the contract `keccak256` hash.
|
||||
pub fn keccak256(&self) -> String {
|
||||
let json = serde_json::to_vec(self).expect("Always valid");
|
||||
revive_llvm_context::eravm_utils::keccak256(json.as_slice())
|
||||
revive_llvm_context::polkavm_utils::keccak256(json.as_slice())
|
||||
}
|
||||
|
||||
/// Sets the full contract path.
|
||||
@@ -180,28 +180,28 @@ impl Assembly {
|
||||
}
|
||||
}
|
||||
|
||||
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for Assembly
|
||||
impl<D> revive_llvm_context::PolkaVMWriteLLVM<D> for Assembly
|
||||
where
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
fn declare(
|
||||
&mut self,
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
context: &mut revive_llvm_context::PolkaVMContext<D>,
|
||||
) -> anyhow::Result<()> {
|
||||
let mut entry = revive_llvm_context::EraVMEntryFunction::default();
|
||||
let mut entry = revive_llvm_context::PolkaVMEntryFunction::default();
|
||||
entry.declare(context)?;
|
||||
|
||||
let mut runtime = revive_llvm_context::EraVMRuntime::new(
|
||||
revive_llvm_context::EraVMAddressSpace::Heap,
|
||||
let mut runtime = revive_llvm_context::PolkaVMRuntime::new(
|
||||
revive_llvm_context::PolkaVMAddressSpace::Heap,
|
||||
);
|
||||
runtime.declare(context)?;
|
||||
|
||||
revive_llvm_context::EraVMDeployCodeFunction::new(
|
||||
revive_llvm_context::EraVMDummyLLVMWritable::default(),
|
||||
revive_llvm_context::PolkaVMDeployCodeFunction::new(
|
||||
revive_llvm_context::PolkaVMDummyLLVMWritable::default(),
|
||||
)
|
||||
.declare(context)?;
|
||||
revive_llvm_context::EraVMRuntimeCodeFunction::new(
|
||||
revive_llvm_context::EraVMDummyLLVMWritable::default(),
|
||||
revive_llvm_context::PolkaVMRuntimeCodeFunction::new(
|
||||
revive_llvm_context::PolkaVMDummyLLVMWritable::default(),
|
||||
)
|
||||
.declare(context)?;
|
||||
|
||||
@@ -214,7 +214,7 @@ where
|
||||
|
||||
fn into_llvm(
|
||||
mut self,
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
context: &mut revive_llvm_context::PolkaVMContext<D>,
|
||||
) -> anyhow::Result<()> {
|
||||
let full_path = self.full_path().to_owned();
|
||||
|
||||
@@ -223,7 +223,7 @@ where
|
||||
}
|
||||
let deploy_code_blocks = EtherealIR::get_blocks(
|
||||
context.evmla().version.to_owned(),
|
||||
revive_llvm_context::EraVMCodeType::Deploy,
|
||||
revive_llvm_context::PolkaVMCodeType::Deploy,
|
||||
self.code
|
||||
.as_deref()
|
||||
.ok_or_else(|| anyhow::anyhow!("Deploy code instructions not found"))?,
|
||||
@@ -250,7 +250,7 @@ where
|
||||
};
|
||||
let runtime_code_blocks = EtherealIR::get_blocks(
|
||||
context.evmla().version.to_owned(),
|
||||
revive_llvm_context::EraVMCodeType::Runtime,
|
||||
revive_llvm_context::PolkaVMCodeType::Runtime,
|
||||
runtime_code_instructions.as_slice(),
|
||||
)?;
|
||||
|
||||
@@ -265,12 +265,12 @@ where
|
||||
ethereal_ir.declare(context)?;
|
||||
ethereal_ir.into_llvm(context)?;
|
||||
|
||||
revive_llvm_context::EraVMDeployCodeFunction::new(EntryLink::new(
|
||||
revive_llvm_context::EraVMCodeType::Deploy,
|
||||
revive_llvm_context::PolkaVMDeployCodeFunction::new(EntryLink::new(
|
||||
revive_llvm_context::PolkaVMCodeType::Deploy,
|
||||
))
|
||||
.into_llvm(context)?;
|
||||
revive_llvm_context::EraVMRuntimeCodeFunction::new(EntryLink::new(
|
||||
revive_llvm_context::EraVMCodeType::Runtime,
|
||||
revive_llvm_context::PolkaVMRuntimeCodeFunction::new(EntryLink::new(
|
||||
revive_llvm_context::PolkaVMCodeType::Runtime,
|
||||
))
|
||||
.into_llvm(context)?;
|
||||
|
||||
|
||||
@@ -9,23 +9,23 @@ use crate::evmla::ethereal_ir::EtherealIR;
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct EntryLink {
|
||||
/// The code part type.
|
||||
pub code_type: revive_llvm_context::EraVMCodeType,
|
||||
pub code_type: revive_llvm_context::PolkaVMCodeType,
|
||||
}
|
||||
|
||||
impl EntryLink {
|
||||
/// A shortcut constructor.
|
||||
pub fn new(code_type: revive_llvm_context::EraVMCodeType) -> Self {
|
||||
pub fn new(code_type: revive_llvm_context::PolkaVMCodeType) -> Self {
|
||||
Self { code_type }
|
||||
}
|
||||
}
|
||||
|
||||
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for EntryLink
|
||||
impl<D> revive_llvm_context::PolkaVMWriteLLVM<D> for EntryLink
|
||||
where
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
fn into_llvm(
|
||||
self,
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
context: &mut revive_llvm_context::PolkaVMContext<D>,
|
||||
) -> anyhow::Result<()> {
|
||||
let target = context
|
||||
.get_function(EtherealIR::DEFAULT_ENTRY_FUNCTION_NAME)
|
||||
@@ -33,10 +33,10 @@ where
|
||||
.borrow()
|
||||
.declaration();
|
||||
let is_deploy_code = match self.code_type {
|
||||
revive_llvm_context::EraVMCodeType::Deploy => context
|
||||
revive_llvm_context::PolkaVMCodeType::Deploy => context
|
||||
.integer_type(revive_common::BIT_LENGTH_BOOLEAN)
|
||||
.const_int(1, false),
|
||||
revive_llvm_context::EraVMCodeType::Runtime => context
|
||||
revive_llvm_context::PolkaVMCodeType::Runtime => context
|
||||
.integer_type(revive_common::BIT_LENGTH_BOOLEAN)
|
||||
.const_int(0, false),
|
||||
};
|
||||
|
||||
@@ -44,10 +44,10 @@ impl Element {
|
||||
/// Pops the specified number of arguments, converted into their LLVM values.
|
||||
fn pop_arguments_llvm<'ctx, D>(
|
||||
&mut self,
|
||||
context: &mut revive_llvm_context::EraVMContext<'ctx, D>,
|
||||
context: &mut revive_llvm_context::PolkaVMContext<'ctx, D>,
|
||||
) -> Vec<inkwell::values::BasicValueEnum<'ctx>>
|
||||
where
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
let input_size = self.instruction.input_size(&context.evmla().version);
|
||||
let output_size = self.instruction.output_size();
|
||||
@@ -59,7 +59,7 @@ impl Element {
|
||||
.into_pointer_value();
|
||||
let value = context
|
||||
.build_load(
|
||||
revive_llvm_context::EraVMPointer::new_stack_field(context, pointer),
|
||||
revive_llvm_context::PolkaVMPointer::new_stack_field(context, pointer),
|
||||
format!("argument_{index}").as_str(),
|
||||
)
|
||||
.unwrap();
|
||||
@@ -69,13 +69,13 @@ impl Element {
|
||||
}
|
||||
}
|
||||
|
||||
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for Element
|
||||
impl<D> revive_llvm_context::PolkaVMWriteLLVM<D> for Element
|
||||
where
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
fn into_llvm(
|
||||
mut self,
|
||||
context: &mut revive_llvm_context::EraVMContext<'_, D>,
|
||||
context: &mut revive_llvm_context::PolkaVMContext<'_, D>,
|
||||
) -> anyhow::Result<()> {
|
||||
let mut original = self.instruction.value.clone();
|
||||
|
||||
@@ -127,7 +127,7 @@ where
|
||||
)
|
||||
.map(Some),
|
||||
InstructionName::PUSH_ContractHash => {
|
||||
revive_llvm_context::eravm_evm_create::contract_hash(
|
||||
revive_llvm_context::polkavm_evm_create::contract_hash(
|
||||
context,
|
||||
self.instruction
|
||||
.value
|
||||
@@ -136,7 +136,7 @@ where
|
||||
.map(|argument| Some(argument.value))
|
||||
}
|
||||
InstructionName::PUSH_ContractHashSize => {
|
||||
revive_llvm_context::eravm_evm_create::header_size(
|
||||
revive_llvm_context::polkavm_evm_create::header_size(
|
||||
context,
|
||||
self.instruction
|
||||
.value
|
||||
@@ -425,7 +425,7 @@ where
|
||||
|
||||
InstructionName::ADD => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_arithmetic::addition(
|
||||
revive_llvm_context::polkavm_evm_arithmetic::addition(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -434,7 +434,7 @@ where
|
||||
}
|
||||
InstructionName::SUB => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_arithmetic::subtraction(
|
||||
revive_llvm_context::polkavm_evm_arithmetic::subtraction(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -443,7 +443,7 @@ where
|
||||
}
|
||||
InstructionName::MUL => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_arithmetic::multiplication(
|
||||
revive_llvm_context::polkavm_evm_arithmetic::multiplication(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -452,7 +452,7 @@ where
|
||||
}
|
||||
InstructionName::DIV => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_arithmetic::division(
|
||||
revive_llvm_context::polkavm_evm_arithmetic::division(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -461,7 +461,7 @@ where
|
||||
}
|
||||
InstructionName::MOD => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_arithmetic::remainder(
|
||||
revive_llvm_context::polkavm_evm_arithmetic::remainder(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -470,7 +470,7 @@ where
|
||||
}
|
||||
InstructionName::SDIV => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_arithmetic::division_signed(
|
||||
revive_llvm_context::polkavm_evm_arithmetic::division_signed(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -479,7 +479,7 @@ where
|
||||
}
|
||||
InstructionName::SMOD => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_arithmetic::remainder_signed(
|
||||
revive_llvm_context::polkavm_evm_arithmetic::remainder_signed(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -489,7 +489,7 @@ where
|
||||
|
||||
InstructionName::LT => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_comparison::compare(
|
||||
revive_llvm_context::polkavm_evm_comparison::compare(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -499,7 +499,7 @@ where
|
||||
}
|
||||
InstructionName::GT => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_comparison::compare(
|
||||
revive_llvm_context::polkavm_evm_comparison::compare(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -509,7 +509,7 @@ where
|
||||
}
|
||||
InstructionName::EQ => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_comparison::compare(
|
||||
revive_llvm_context::polkavm_evm_comparison::compare(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -519,7 +519,7 @@ where
|
||||
}
|
||||
InstructionName::ISZERO => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_comparison::compare(
|
||||
revive_llvm_context::polkavm_evm_comparison::compare(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
context.field_const(0),
|
||||
@@ -529,7 +529,7 @@ where
|
||||
}
|
||||
InstructionName::SLT => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_comparison::compare(
|
||||
revive_llvm_context::polkavm_evm_comparison::compare(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -539,7 +539,7 @@ where
|
||||
}
|
||||
InstructionName::SGT => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_comparison::compare(
|
||||
revive_llvm_context::polkavm_evm_comparison::compare(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -550,7 +550,7 @@ where
|
||||
|
||||
InstructionName::OR => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_bitwise::or(
|
||||
revive_llvm_context::polkavm_evm_bitwise::or(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -559,7 +559,7 @@ where
|
||||
}
|
||||
InstructionName::XOR => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_bitwise::xor(
|
||||
revive_llvm_context::polkavm_evm_bitwise::xor(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -568,7 +568,7 @@ where
|
||||
}
|
||||
InstructionName::NOT => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_bitwise::xor(
|
||||
revive_llvm_context::polkavm_evm_bitwise::xor(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
context.field_type().const_all_ones(),
|
||||
@@ -577,7 +577,7 @@ where
|
||||
}
|
||||
InstructionName::AND => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_bitwise::and(
|
||||
revive_llvm_context::polkavm_evm_bitwise::and(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -586,7 +586,7 @@ where
|
||||
}
|
||||
InstructionName::SHL => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_bitwise::shift_left(
|
||||
revive_llvm_context::polkavm_evm_bitwise::shift_left(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -595,7 +595,7 @@ where
|
||||
}
|
||||
InstructionName::SHR => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_bitwise::shift_right(
|
||||
revive_llvm_context::polkavm_evm_bitwise::shift_right(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -604,7 +604,7 @@ where
|
||||
}
|
||||
InstructionName::SAR => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_bitwise::shift_right_arithmetic(
|
||||
revive_llvm_context::polkavm_evm_bitwise::shift_right_arithmetic(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -613,7 +613,7 @@ where
|
||||
}
|
||||
InstructionName::BYTE => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_bitwise::byte(
|
||||
revive_llvm_context::polkavm_evm_bitwise::byte(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -623,7 +623,7 @@ where
|
||||
|
||||
InstructionName::ADDMOD => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_math::add_mod(
|
||||
revive_llvm_context::polkavm_evm_math::add_mod(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -633,7 +633,7 @@ where
|
||||
}
|
||||
InstructionName::MULMOD => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_math::mul_mod(
|
||||
revive_llvm_context::polkavm_evm_math::mul_mod(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -643,7 +643,7 @@ where
|
||||
}
|
||||
InstructionName::EXP => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_math::exponent(
|
||||
revive_llvm_context::polkavm_evm_math::exponent(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -652,7 +652,7 @@ where
|
||||
}
|
||||
InstructionName::SIGNEXTEND => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_math::sign_extend(
|
||||
revive_llvm_context::polkavm_evm_math::sign_extend(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -662,7 +662,7 @@ where
|
||||
|
||||
InstructionName::SHA3 | InstructionName::KECCAK256 => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_crypto::sha3(
|
||||
revive_llvm_context::polkavm_evm_crypto::sha3(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -672,7 +672,7 @@ where
|
||||
|
||||
InstructionName::MLOAD => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_memory::load(
|
||||
revive_llvm_context::polkavm_evm_memory::load(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
)
|
||||
@@ -680,7 +680,7 @@ where
|
||||
}
|
||||
InstructionName::MSTORE => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_memory::store(
|
||||
revive_llvm_context::polkavm_evm_memory::store(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -689,7 +689,7 @@ where
|
||||
}
|
||||
InstructionName::MSTORE8 => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_memory::store_byte(
|
||||
revive_llvm_context::polkavm_evm_memory::store_byte(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -698,16 +698,16 @@ where
|
||||
}
|
||||
InstructionName::MCOPY => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
let destination = revive_llvm_context::EraVMPointer::new_with_offset(
|
||||
let destination = revive_llvm_context::PolkaVMPointer::new_with_offset(
|
||||
context,
|
||||
revive_llvm_context::EraVMAddressSpace::Heap,
|
||||
revive_llvm_context::PolkaVMAddressSpace::Heap,
|
||||
context.byte_type(),
|
||||
arguments[0].into_int_value(),
|
||||
"mcopy_destination",
|
||||
);
|
||||
let source = revive_llvm_context::EraVMPointer::new_with_offset(
|
||||
let source = revive_llvm_context::PolkaVMPointer::new_with_offset(
|
||||
context,
|
||||
revive_llvm_context::EraVMAddressSpace::Heap,
|
||||
revive_llvm_context::PolkaVMAddressSpace::Heap,
|
||||
context.byte_type(),
|
||||
arguments[1].into_int_value(),
|
||||
"mcopy_source",
|
||||
@@ -725,7 +725,7 @@ where
|
||||
|
||||
InstructionName::SLOAD => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_storage::load(
|
||||
revive_llvm_context::polkavm_evm_storage::load(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
)
|
||||
@@ -733,7 +733,7 @@ where
|
||||
}
|
||||
InstructionName::SSTORE => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_storage::store(
|
||||
revive_llvm_context::polkavm_evm_storage::store(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -759,7 +759,7 @@ where
|
||||
.get_or_allocate_immutable(key.as_str());
|
||||
|
||||
let index = context.field_const(offset as u64);
|
||||
revive_llvm_context::eravm_evm_immutable::load(context, index).map(Some)
|
||||
revive_llvm_context::polkavm_evm_immutable::load(context, index).map(Some)
|
||||
}
|
||||
InstructionName::ASSIGNIMMUTABLE => {
|
||||
let mut arguments = self.pop_arguments_llvm(context);
|
||||
@@ -773,7 +773,7 @@ where
|
||||
|
||||
let index = context.field_const(offset as u64);
|
||||
let value = arguments.pop().expect("Always exists").into_int_value();
|
||||
revive_llvm_context::eravm_evm_immutable::store(context, index, value)
|
||||
revive_llvm_context::polkavm_evm_immutable::store(context, index, value)
|
||||
.map(|_| None)
|
||||
}
|
||||
|
||||
@@ -782,12 +782,12 @@ where
|
||||
.code_type()
|
||||
.ok_or_else(|| anyhow::anyhow!("The contract code part type is undefined"))?
|
||||
{
|
||||
revive_llvm_context::EraVMCodeType::Deploy => {
|
||||
revive_llvm_context::PolkaVMCodeType::Deploy => {
|
||||
Ok(Some(context.field_const(0).as_basic_value_enum()))
|
||||
}
|
||||
revive_llvm_context::EraVMCodeType::Runtime => {
|
||||
revive_llvm_context::PolkaVMCodeType::Runtime => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_calldata::load(
|
||||
revive_llvm_context::polkavm_evm_calldata::load(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
)
|
||||
@@ -800,11 +800,11 @@ where
|
||||
.code_type()
|
||||
.ok_or_else(|| anyhow::anyhow!("The contract code part type is undefined"))?
|
||||
{
|
||||
revive_llvm_context::EraVMCodeType::Deploy => {
|
||||
revive_llvm_context::PolkaVMCodeType::Deploy => {
|
||||
Ok(Some(context.field_const(0).as_basic_value_enum()))
|
||||
}
|
||||
revive_llvm_context::EraVMCodeType::Runtime => {
|
||||
revive_llvm_context::eravm_evm_calldata::size(context).map(Some)
|
||||
revive_llvm_context::PolkaVMCodeType::Runtime => {
|
||||
revive_llvm_context::polkavm_evm_calldata::size(context).map(Some)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -815,11 +815,11 @@ where
|
||||
.code_type()
|
||||
.ok_or_else(|| anyhow::anyhow!("The contract code part type is undefined"))?
|
||||
{
|
||||
revive_llvm_context::EraVMCodeType::Deploy => {
|
||||
revive_llvm_context::PolkaVMCodeType::Deploy => {
|
||||
let calldata_size =
|
||||
revive_llvm_context::eravm_evm_calldata::size(context)?;
|
||||
revive_llvm_context::polkavm_evm_calldata::size(context)?;
|
||||
|
||||
revive_llvm_context::eravm_evm_calldata::copy(
|
||||
revive_llvm_context::polkavm_evm_calldata::copy(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
calldata_size.into_int_value(),
|
||||
@@ -827,8 +827,8 @@ where
|
||||
)
|
||||
.map(|_| None)
|
||||
}
|
||||
revive_llvm_context::EraVMCodeType::Runtime => {
|
||||
revive_llvm_context::eravm_evm_calldata::copy(
|
||||
revive_llvm_context::PolkaVMCodeType::Runtime => {
|
||||
revive_llvm_context::polkavm_evm_calldata::copy(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -843,10 +843,10 @@ where
|
||||
.code_type()
|
||||
.ok_or_else(|| anyhow::anyhow!("The contract code part type is undefined"))?
|
||||
{
|
||||
revive_llvm_context::EraVMCodeType::Deploy => {
|
||||
revive_llvm_context::eravm_evm_calldata::size(context).map(Some)
|
||||
revive_llvm_context::PolkaVMCodeType::Deploy => {
|
||||
revive_llvm_context::polkavm_evm_calldata::size(context).map(Some)
|
||||
}
|
||||
revive_llvm_context::EraVMCodeType::Runtime => {
|
||||
revive_llvm_context::PolkaVMCodeType::Runtime => {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
@@ -879,18 +879,18 @@ where
|
||||
match context.code_type().ok_or_else(|| {
|
||||
anyhow::anyhow!("The contract code part type is undefined")
|
||||
})? {
|
||||
revive_llvm_context::EraVMCodeType::Deploy => {
|
||||
revive_llvm_context::eravm_evm_calldata::copy(
|
||||
revive_llvm_context::PolkaVMCodeType::Deploy => {
|
||||
revive_llvm_context::polkavm_evm_calldata::copy(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
arguments[2].into_int_value(),
|
||||
)
|
||||
}
|
||||
revive_llvm_context::EraVMCodeType::Runtime => {
|
||||
revive_llvm_context::PolkaVMCodeType::Runtime => {
|
||||
let calldata_size =
|
||||
revive_llvm_context::eravm_evm_calldata::size(context)?;
|
||||
revive_llvm_context::eravm_evm_calldata::copy(
|
||||
revive_llvm_context::polkavm_evm_calldata::size(context)?;
|
||||
revive_llvm_context::polkavm_evm_calldata::copy(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
calldata_size.into_int_value(),
|
||||
@@ -904,11 +904,11 @@ where
|
||||
}
|
||||
InstructionName::PUSHSIZE => Ok(Some(context.field_const(0).as_basic_value_enum())),
|
||||
InstructionName::RETURNDATASIZE => {
|
||||
revive_llvm_context::eravm_evm_return_data::size(context).map(Some)
|
||||
revive_llvm_context::polkavm_evm_return_data::size(context).map(Some)
|
||||
}
|
||||
InstructionName::RETURNDATACOPY => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_return_data::copy(
|
||||
revive_llvm_context::polkavm_evm_return_data::copy(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -918,7 +918,7 @@ where
|
||||
}
|
||||
InstructionName::EXTCODESIZE => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_ext_code::size(
|
||||
revive_llvm_context::polkavm_evm_ext_code::size(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
)
|
||||
@@ -926,7 +926,7 @@ where
|
||||
}
|
||||
InstructionName::EXTCODEHASH => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_ext_code::hash(
|
||||
revive_llvm_context::polkavm_evm_ext_code::hash(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
)
|
||||
@@ -935,7 +935,7 @@ where
|
||||
|
||||
InstructionName::RETURN => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_return::r#return(
|
||||
revive_llvm_context::polkavm_evm_return::r#return(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -944,7 +944,7 @@ where
|
||||
}
|
||||
InstructionName::REVERT => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_return::revert(
|
||||
revive_llvm_context::polkavm_evm_return::revert(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
@@ -952,15 +952,15 @@ where
|
||||
.map(|_| None)
|
||||
}
|
||||
InstructionName::STOP => {
|
||||
revive_llvm_context::eravm_evm_return::stop(context).map(|_| None)
|
||||
revive_llvm_context::polkavm_evm_return::stop(context).map(|_| None)
|
||||
}
|
||||
InstructionName::INVALID => {
|
||||
revive_llvm_context::eravm_evm_return::invalid(context).map(|_| None)
|
||||
revive_llvm_context::polkavm_evm_return::invalid(context).map(|_| None)
|
||||
}
|
||||
|
||||
InstructionName::LOG0 => {
|
||||
let mut arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_event::log(
|
||||
revive_llvm_context::polkavm_evm_event::log(
|
||||
context,
|
||||
arguments.remove(0).into_int_value(),
|
||||
arguments.remove(0).into_int_value(),
|
||||
@@ -973,7 +973,7 @@ where
|
||||
}
|
||||
InstructionName::LOG1 => {
|
||||
let mut arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_event::log(
|
||||
revive_llvm_context::polkavm_evm_event::log(
|
||||
context,
|
||||
arguments.remove(0).into_int_value(),
|
||||
arguments.remove(0).into_int_value(),
|
||||
@@ -986,7 +986,7 @@ where
|
||||
}
|
||||
InstructionName::LOG2 => {
|
||||
let mut arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_event::log(
|
||||
revive_llvm_context::polkavm_evm_event::log(
|
||||
context,
|
||||
arguments.remove(0).into_int_value(),
|
||||
arguments.remove(0).into_int_value(),
|
||||
@@ -999,7 +999,7 @@ where
|
||||
}
|
||||
InstructionName::LOG3 => {
|
||||
let mut arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_event::log(
|
||||
revive_llvm_context::polkavm_evm_event::log(
|
||||
context,
|
||||
arguments.remove(0).into_int_value(),
|
||||
arguments.remove(0).into_int_value(),
|
||||
@@ -1012,7 +1012,7 @@ where
|
||||
}
|
||||
InstructionName::LOG4 => {
|
||||
let mut arguments = self.pop_arguments_llvm(context);
|
||||
revive_llvm_context::eravm_evm_event::log(
|
||||
revive_llvm_context::polkavm_evm_event::log(
|
||||
context,
|
||||
arguments.remove(0).into_int_value(),
|
||||
arguments.remove(0).into_int_value(),
|
||||
@@ -1037,7 +1037,7 @@ where
|
||||
|
||||
todo!()
|
||||
/*
|
||||
revive_llvm_context::eravm_evm_call::default(
|
||||
revive_llvm_context::polkavm_evm_call::default(
|
||||
context,
|
||||
context.llvm_runtime().far_call,
|
||||
gas,
|
||||
@@ -1062,7 +1062,7 @@ where
|
||||
let output_offset = arguments.remove(0).into_int_value();
|
||||
let output_size = arguments.remove(0).into_int_value();
|
||||
|
||||
revive_llvm_context::eravm_evm_call::default(
|
||||
revive_llvm_context::polkavm_evm_call::default(
|
||||
context,
|
||||
context.llvm_runtime().static_call,
|
||||
gas,
|
||||
@@ -1086,7 +1086,7 @@ where
|
||||
let output_offset = arguments.remove(0).into_int_value();
|
||||
let output_size = arguments.remove(0).into_int_value();
|
||||
|
||||
revive_llvm_context::eravm_evm_call::default(
|
||||
revive_llvm_context::polkavm_evm_call::default(
|
||||
context,
|
||||
context.llvm_runtime().delegate_call,
|
||||
gas,
|
||||
@@ -1108,7 +1108,7 @@ where
|
||||
let input_offset = arguments[1].into_int_value();
|
||||
let input_length = arguments[2].into_int_value();
|
||||
|
||||
revive_llvm_context::eravm_evm_create::create(
|
||||
revive_llvm_context::polkavm_evm_create::create(
|
||||
context,
|
||||
value,
|
||||
input_offset,
|
||||
@@ -1124,7 +1124,7 @@ where
|
||||
let input_length = arguments[2].into_int_value();
|
||||
let salt = arguments[3].into_int_value();
|
||||
|
||||
revive_llvm_context::eravm_evm_create::create2(
|
||||
revive_llvm_context::polkavm_evm_create::create2(
|
||||
context,
|
||||
value,
|
||||
input_offset,
|
||||
@@ -1138,44 +1138,44 @@ where
|
||||
InstructionName::CALLER => todo!(),
|
||||
|
||||
InstructionName::CALLVALUE => {
|
||||
revive_llvm_context::eravm_evm_ether_gas::value(context).map(Some)
|
||||
revive_llvm_context::polkavm_evm_ether_gas::value(context).map(Some)
|
||||
}
|
||||
InstructionName::GAS => {
|
||||
revive_llvm_context::eravm_evm_ether_gas::gas(context).map(Some)
|
||||
revive_llvm_context::polkavm_evm_ether_gas::gas(context).map(Some)
|
||||
}
|
||||
InstructionName::BALANCE => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
|
||||
let address = arguments[0].into_int_value();
|
||||
revive_llvm_context::eravm_evm_ether_gas::balance(context, address).map(Some)
|
||||
revive_llvm_context::polkavm_evm_ether_gas::balance(context, address).map(Some)
|
||||
}
|
||||
InstructionName::SELFBALANCE => todo!(),
|
||||
|
||||
InstructionName::GASLIMIT => {
|
||||
revive_llvm_context::eravm_evm_contract_context::gas_limit(context).map(Some)
|
||||
revive_llvm_context::polkavm_evm_contract_context::gas_limit(context).map(Some)
|
||||
}
|
||||
InstructionName::GASPRICE => {
|
||||
revive_llvm_context::eravm_evm_contract_context::gas_price(context).map(Some)
|
||||
revive_llvm_context::polkavm_evm_contract_context::gas_price(context).map(Some)
|
||||
}
|
||||
InstructionName::ORIGIN => {
|
||||
revive_llvm_context::eravm_evm_contract_context::origin(context).map(Some)
|
||||
revive_llvm_context::polkavm_evm_contract_context::origin(context).map(Some)
|
||||
}
|
||||
InstructionName::CHAINID => {
|
||||
revive_llvm_context::eravm_evm_contract_context::chain_id(context).map(Some)
|
||||
revive_llvm_context::polkavm_evm_contract_context::chain_id(context).map(Some)
|
||||
}
|
||||
InstructionName::TIMESTAMP => {
|
||||
revive_llvm_context::eravm_evm_contract_context::block_timestamp(context)
|
||||
revive_llvm_context::polkavm_evm_contract_context::block_timestamp(context)
|
||||
.map(Some)
|
||||
}
|
||||
InstructionName::NUMBER => {
|
||||
revive_llvm_context::eravm_evm_contract_context::block_number(context)
|
||||
revive_llvm_context::polkavm_evm_contract_context::block_number(context)
|
||||
.map(Some)
|
||||
}
|
||||
InstructionName::BLOCKHASH => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
let index = arguments[0].into_int_value();
|
||||
|
||||
revive_llvm_context::eravm_evm_contract_context::block_hash(context, index)
|
||||
revive_llvm_context::polkavm_evm_contract_context::block_hash(context, index)
|
||||
.map(Some)
|
||||
}
|
||||
InstructionName::BLOBHASH => {
|
||||
@@ -1183,19 +1183,19 @@ where
|
||||
anyhow::bail!("The `BLOBHASH` instruction is not supported until zkVM v1.5.0");
|
||||
}
|
||||
InstructionName::DIFFICULTY | InstructionName::PREVRANDAO => {
|
||||
revive_llvm_context::eravm_evm_contract_context::difficulty(context).map(Some)
|
||||
revive_llvm_context::polkavm_evm_contract_context::difficulty(context).map(Some)
|
||||
}
|
||||
InstructionName::COINBASE => {
|
||||
revive_llvm_context::eravm_evm_contract_context::coinbase(context).map(Some)
|
||||
revive_llvm_context::polkavm_evm_contract_context::coinbase(context).map(Some)
|
||||
}
|
||||
InstructionName::BASEFEE => {
|
||||
revive_llvm_context::eravm_evm_contract_context::basefee(context).map(Some)
|
||||
revive_llvm_context::polkavm_evm_contract_context::basefee(context).map(Some)
|
||||
}
|
||||
InstructionName::BLOBBASEFEE => {
|
||||
anyhow::bail!("The `BLOBBASEFEE` instruction is not supported until zkVM v1.5.0");
|
||||
}
|
||||
InstructionName::MSIZE => {
|
||||
revive_llvm_context::eravm_evm_contract_context::msize(context).map(Some)
|
||||
revive_llvm_context::polkavm_evm_contract_context::msize(context).map(Some)
|
||||
}
|
||||
|
||||
InstructionName::CALLCODE => {
|
||||
@@ -1244,7 +1244,7 @@ where
|
||||
.to_llvm()
|
||||
.into_pointer_value();
|
||||
context.build_store(
|
||||
revive_llvm_context::EraVMPointer::new_stack_field(
|
||||
revive_llvm_context::PolkaVMPointer::new_stack_field(
|
||||
context, pointer,
|
||||
),
|
||||
value,
|
||||
@@ -1261,9 +1261,9 @@ where
|
||||
format!("return_value_element_{}", index).as_str(),
|
||||
)
|
||||
.expect("Always exists");
|
||||
let pointer = revive_llvm_context::EraVMPointer::new(
|
||||
let pointer = revive_llvm_context::PolkaVMPointer::new(
|
||||
context.field_type(),
|
||||
revive_llvm_context::EraVMAddressSpace::Stack,
|
||||
revive_llvm_context::PolkaVMAddressSpace::Stack,
|
||||
context.evmla().stack
|
||||
[self.stack.elements.len() - output_size + index]
|
||||
.to_llvm()
|
||||
@@ -1292,12 +1292,12 @@ where
|
||||
arguments.pop();
|
||||
|
||||
match context.current_function().borrow().r#return() {
|
||||
revive_llvm_context::EraVMFunctionReturn::None => {}
|
||||
revive_llvm_context::EraVMFunctionReturn::Primitive { pointer } => {
|
||||
revive_llvm_context::PolkaVMFunctionReturn::None => {}
|
||||
revive_llvm_context::PolkaVMFunctionReturn::Primitive { pointer } => {
|
||||
assert_eq!(arguments.len(), 1);
|
||||
context.build_store(pointer, arguments.remove(0))?;
|
||||
}
|
||||
revive_llvm_context::EraVMFunctionReturn::Compound {
|
||||
revive_llvm_context::PolkaVMFunctionReturn::Compound {
|
||||
pointer, ..
|
||||
} => {
|
||||
for (index, argument) in arguments.into_iter().enumerate() {
|
||||
@@ -1327,7 +1327,7 @@ where
|
||||
.to_llvm()
|
||||
.into_pointer_value();
|
||||
context.build_store(
|
||||
revive_llvm_context::EraVMPointer::new_stack_field(context, pointer),
|
||||
revive_llvm_context::PolkaVMPointer::new_stack_field(context, pointer),
|
||||
result,
|
||||
)?;
|
||||
context.evmla_mut().stack[self.stack.elements.len() - 1].original = original;
|
||||
|
||||
@@ -18,13 +18,13 @@ pub struct Block {
|
||||
/// The Solidity compiler version.
|
||||
pub solc_version: semver::Version,
|
||||
/// The block key.
|
||||
pub key: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
pub key: revive_llvm_context::PolkaVMFunctionBlockKey,
|
||||
/// The block instance.
|
||||
pub instance: Option<usize>,
|
||||
/// The block elements relevant to the stack consistency.
|
||||
pub elements: Vec<Element>,
|
||||
/// The block predecessors.
|
||||
pub predecessors: HashSet<(revive_llvm_context::EraVMFunctionBlockKey, usize)>,
|
||||
pub predecessors: HashSet<(revive_llvm_context::PolkaVMFunctionBlockKey, usize)>,
|
||||
/// The initial stack state.
|
||||
pub initial_stack: ElementStack,
|
||||
/// The stack.
|
||||
@@ -42,7 +42,7 @@ impl Block {
|
||||
/// Assembles a block from the sequence of instructions.
|
||||
pub fn try_from_instructions(
|
||||
solc_version: semver::Version,
|
||||
code_type: revive_llvm_context::EraVMCodeType,
|
||||
code_type: revive_llvm_context::PolkaVMCodeType,
|
||||
slice: &[Instruction],
|
||||
) -> anyhow::Result<(Self, usize)> {
|
||||
let mut cursor = 0;
|
||||
@@ -63,7 +63,7 @@ impl Block {
|
||||
|
||||
let mut block = Self {
|
||||
solc_version: solc_version.clone(),
|
||||
key: revive_llvm_context::EraVMFunctionBlockKey::new(code_type, tag),
|
||||
key: revive_llvm_context::PolkaVMFunctionBlockKey::new(code_type, tag),
|
||||
instance: None,
|
||||
elements: Vec::with_capacity(Self::ELEMENTS_VECTOR_DEFAULT_CAPACITY),
|
||||
predecessors: HashSet::with_capacity(Self::PREDECESSORS_HASHSET_DEFAULT_CAPACITY),
|
||||
@@ -106,20 +106,20 @@ impl Block {
|
||||
/// Inserts a predecessor tag.
|
||||
pub fn insert_predecessor(
|
||||
&mut self,
|
||||
key: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
key: revive_llvm_context::PolkaVMFunctionBlockKey,
|
||||
instance: usize,
|
||||
) {
|
||||
self.predecessors.insert((key, instance));
|
||||
}
|
||||
}
|
||||
|
||||
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for Block
|
||||
impl<D> revive_llvm_context::PolkaVMWriteLLVM<D> for Block
|
||||
where
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
fn into_llvm(
|
||||
self,
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
context: &mut revive_llvm_context::PolkaVMContext<D>,
|
||||
) -> anyhow::Result<()> {
|
||||
context.set_code_type(self.key.code_type);
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ pub struct Function {
|
||||
/// The function name.
|
||||
pub name: String,
|
||||
/// The separately labelled blocks.
|
||||
pub blocks: BTreeMap<revive_llvm_context::EraVMFunctionBlockKey, Vec<Block>>,
|
||||
pub blocks: BTreeMap<revive_llvm_context::PolkaVMFunctionBlockKey, Vec<Block>>,
|
||||
/// The function type.
|
||||
pub r#type: Type,
|
||||
/// The function stack size.
|
||||
@@ -74,8 +74,8 @@ impl Function {
|
||||
/// Runs the function block traversal.
|
||||
pub fn traverse(
|
||||
&mut self,
|
||||
blocks: &HashMap<revive_llvm_context::EraVMFunctionBlockKey, Block>,
|
||||
functions: &mut BTreeMap<revive_llvm_context::EraVMFunctionBlockKey, Self>,
|
||||
blocks: &HashMap<revive_llvm_context::PolkaVMFunctionBlockKey, Block>,
|
||||
functions: &mut BTreeMap<revive_llvm_context::PolkaVMFunctionBlockKey, Self>,
|
||||
extra_metadata: &ExtraMetadata,
|
||||
visited_functions: &mut BTreeSet<VisitedElement>,
|
||||
) -> anyhow::Result<()> {
|
||||
@@ -84,8 +84,8 @@ impl Function {
|
||||
match self.r#type {
|
||||
Type::Initial => {
|
||||
for code_type in [
|
||||
revive_llvm_context::EraVMCodeType::Deploy,
|
||||
revive_llvm_context::EraVMCodeType::Runtime,
|
||||
revive_llvm_context::PolkaVMCodeType::Deploy,
|
||||
revive_llvm_context::PolkaVMCodeType::Runtime,
|
||||
] {
|
||||
self.consume_block(
|
||||
blocks,
|
||||
@@ -94,7 +94,7 @@ impl Function {
|
||||
visited_functions,
|
||||
&mut visited_blocks,
|
||||
QueueElement::new(
|
||||
revive_llvm_context::EraVMFunctionBlockKey::new(
|
||||
revive_llvm_context::PolkaVMFunctionBlockKey::new(
|
||||
code_type,
|
||||
num::BigUint::zero(),
|
||||
),
|
||||
@@ -138,8 +138,8 @@ impl Function {
|
||||
/// Consumes the entry or a conditional block attached to another one.
|
||||
fn consume_block(
|
||||
&mut self,
|
||||
blocks: &HashMap<revive_llvm_context::EraVMFunctionBlockKey, Block>,
|
||||
functions: &mut BTreeMap<revive_llvm_context::EraVMFunctionBlockKey, Self>,
|
||||
blocks: &HashMap<revive_llvm_context::PolkaVMFunctionBlockKey, Block>,
|
||||
functions: &mut BTreeMap<revive_llvm_context::PolkaVMFunctionBlockKey, Self>,
|
||||
extra_metadata: &ExtraMetadata,
|
||||
visited_functions: &mut BTreeSet<VisitedElement>,
|
||||
visited_blocks: &mut BTreeSet<VisitedElement>,
|
||||
@@ -214,11 +214,11 @@ impl Function {
|
||||
/// the invalid part is truncated after terminating with an `INVALID` instruction.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn handle_instruction(
|
||||
blocks: &HashMap<revive_llvm_context::EraVMFunctionBlockKey, Block>,
|
||||
functions: &mut BTreeMap<revive_llvm_context::EraVMFunctionBlockKey, Self>,
|
||||
blocks: &HashMap<revive_llvm_context::PolkaVMFunctionBlockKey, Block>,
|
||||
functions: &mut BTreeMap<revive_llvm_context::PolkaVMFunctionBlockKey, Self>,
|
||||
extra_metadata: &ExtraMetadata,
|
||||
visited_functions: &mut BTreeSet<VisitedElement>,
|
||||
code_type: revive_llvm_context::EraVMCodeType,
|
||||
code_type: revive_llvm_context::PolkaVMCodeType,
|
||||
instance: usize,
|
||||
block_stack: &mut Stack,
|
||||
block_element: &mut BlockElement,
|
||||
@@ -247,13 +247,13 @@ impl Function {
|
||||
.ok_or_else(|| anyhow::anyhow!("Destination tag is missing"))?
|
||||
{
|
||||
Element::Tag(destination) if destination > &num::BigUint::from(u32::MAX) => {
|
||||
revive_llvm_context::EraVMFunctionBlockKey::new(
|
||||
revive_llvm_context::EraVMCodeType::Runtime,
|
||||
revive_llvm_context::PolkaVMFunctionBlockKey::new(
|
||||
revive_llvm_context::PolkaVMCodeType::Runtime,
|
||||
destination.to_owned() - num::BigUint::from(1u64 << 32),
|
||||
)
|
||||
}
|
||||
Element::Tag(destination) => {
|
||||
revive_llvm_context::EraVMFunctionBlockKey::new(
|
||||
revive_llvm_context::PolkaVMFunctionBlockKey::new(
|
||||
code_type,
|
||||
destination.to_owned(),
|
||||
)
|
||||
@@ -311,13 +311,13 @@ impl Function {
|
||||
.ok_or_else(|| anyhow::anyhow!("Destination tag is missing"))?
|
||||
{
|
||||
Element::Tag(destination) if destination > &num::BigUint::from(u32::MAX) => {
|
||||
revive_llvm_context::EraVMFunctionBlockKey::new(
|
||||
revive_llvm_context::EraVMCodeType::Runtime,
|
||||
revive_llvm_context::PolkaVMFunctionBlockKey::new(
|
||||
revive_llvm_context::PolkaVMCodeType::Runtime,
|
||||
destination.to_owned() - num::BigUint::from(1u64 << 32),
|
||||
)
|
||||
}
|
||||
Element::Tag(destination) => {
|
||||
revive_llvm_context::EraVMFunctionBlockKey::new(
|
||||
revive_llvm_context::PolkaVMFunctionBlockKey::new(
|
||||
code_type,
|
||||
destination.to_owned(),
|
||||
)
|
||||
@@ -347,7 +347,7 @@ impl Function {
|
||||
} => {
|
||||
let tag: num::BigUint = tag.parse().expect("Always valid");
|
||||
let block_key =
|
||||
revive_llvm_context::EraVMFunctionBlockKey::new(code_type, tag);
|
||||
revive_llvm_context::PolkaVMFunctionBlockKey::new(code_type, tag);
|
||||
|
||||
queue_element.predecessor = Some((queue_element.block_key.clone(), instance));
|
||||
queue_element.block_key = block_key.clone();
|
||||
@@ -1006,16 +1006,16 @@ impl Function {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn handle_recursive_function_call(
|
||||
recursive_function: &RecursiveFunction,
|
||||
blocks: &HashMap<revive_llvm_context::EraVMFunctionBlockKey, Block>,
|
||||
functions: &mut BTreeMap<revive_llvm_context::EraVMFunctionBlockKey, Self>,
|
||||
blocks: &HashMap<revive_llvm_context::PolkaVMFunctionBlockKey, Block>,
|
||||
functions: &mut BTreeMap<revive_llvm_context::PolkaVMFunctionBlockKey, Self>,
|
||||
extra_metadata: &ExtraMetadata,
|
||||
visited_functions: &mut BTreeSet<VisitedElement>,
|
||||
block_key: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
block_key: revive_llvm_context::PolkaVMFunctionBlockKey,
|
||||
block_stack: &mut Stack,
|
||||
block_element: &mut BlockElement,
|
||||
version: &semver::Version,
|
||||
) -> anyhow::Result<(
|
||||
revive_llvm_context::EraVMFunctionBlockKey,
|
||||
revive_llvm_context::PolkaVMFunctionBlockKey,
|
||||
Vec<Element>,
|
||||
)> {
|
||||
let return_address_offset = block_stack.elements.len() - 2 - recursive_function.input_size;
|
||||
@@ -1024,7 +1024,7 @@ impl Function {
|
||||
|
||||
let return_address = match block_stack.elements[return_address_offset] {
|
||||
Element::Tag(ref return_address) => {
|
||||
revive_llvm_context::EraVMFunctionBlockKey::new(
|
||||
revive_llvm_context::PolkaVMFunctionBlockKey::new(
|
||||
block_key.code_type,
|
||||
return_address.to_owned(),
|
||||
)
|
||||
@@ -1104,14 +1104,14 @@ impl Function {
|
||||
/// Checks whether the tag value actually references an existing block.
|
||||
/// Checks both deploy and runtime code.
|
||||
fn is_tag_value_valid(
|
||||
blocks: &HashMap<revive_llvm_context::EraVMFunctionBlockKey, Block>,
|
||||
blocks: &HashMap<revive_llvm_context::PolkaVMFunctionBlockKey, Block>,
|
||||
tag: &num::BigUint,
|
||||
) -> bool {
|
||||
blocks.contains_key(&revive_llvm_context::EraVMFunctionBlockKey::new(
|
||||
revive_llvm_context::EraVMCodeType::Deploy,
|
||||
blocks.contains_key(&revive_llvm_context::PolkaVMFunctionBlockKey::new(
|
||||
revive_llvm_context::PolkaVMCodeType::Deploy,
|
||||
tag & num::BigUint::from(u32::MAX),
|
||||
)) || blocks.contains_key(&revive_llvm_context::EraVMFunctionBlockKey::new(
|
||||
revive_llvm_context::EraVMCodeType::Runtime,
|
||||
)) || blocks.contains_key(&revive_llvm_context::PolkaVMFunctionBlockKey::new(
|
||||
revive_llvm_context::PolkaVMCodeType::Runtime,
|
||||
tag & num::BigUint::from(u32::MAX),
|
||||
))
|
||||
}
|
||||
@@ -1133,13 +1133,13 @@ impl Function {
|
||||
}
|
||||
}
|
||||
|
||||
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for Function
|
||||
impl<D> revive_llvm_context::PolkaVMWriteLLVM<D> for Function
|
||||
where
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
fn declare(
|
||||
&mut self,
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
context: &mut revive_llvm_context::PolkaVMContext<D>,
|
||||
) -> anyhow::Result<()> {
|
||||
let (function_type, output_size) = match self.r#type {
|
||||
Type::Initial => {
|
||||
@@ -1178,7 +1178,7 @@ where
|
||||
Some(inkwell::module::Linkage::Private),
|
||||
)?;
|
||||
function.borrow_mut().set_evmla_data(
|
||||
revive_llvm_context::EraVMFunctionEVMLAData::new(self.stack_size),
|
||||
revive_llvm_context::PolkaVMFunctionEVMLAData::new(self.stack_size),
|
||||
);
|
||||
|
||||
Ok(())
|
||||
@@ -1186,7 +1186,7 @@ where
|
||||
|
||||
fn into_llvm(
|
||||
self,
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
context: &mut revive_llvm_context::PolkaVMContext<D>,
|
||||
) -> anyhow::Result<()> {
|
||||
context.set_current_function(self.name.as_str())?;
|
||||
|
||||
@@ -1196,8 +1196,8 @@ where
|
||||
let mut stack_hashes = vec![block.initial_stack.hash()];
|
||||
stack_hashes.extend_from_slice(block.extra_hashes.as_slice());
|
||||
let evmla_data =
|
||||
revive_llvm_context::EraVMFunctionBlockEVMLAData::new(stack_hashes);
|
||||
let mut block = revive_llvm_context::EraVMFunctionBlock::new(inner);
|
||||
revive_llvm_context::PolkaVMFunctionBlockEVMLAData::new(stack_hashes);
|
||||
let mut block = revive_llvm_context::PolkaVMFunctionBlock::new(inner);
|
||||
block.set_evmla_data(evmla_data);
|
||||
context
|
||||
.current_function()
|
||||
@@ -1229,7 +1229,7 @@ where
|
||||
_ => context.field_const(0).as_basic_value_enum(),
|
||||
};
|
||||
context.build_store(pointer, value)?;
|
||||
stack_variables.push(revive_llvm_context::EraVMArgument::new(
|
||||
stack_variables.push(revive_llvm_context::PolkaVMArgument::new(
|
||||
pointer.value.as_basic_value_enum(),
|
||||
));
|
||||
}
|
||||
@@ -1243,15 +1243,15 @@ where
|
||||
.get_nth_param(0)
|
||||
.into_int_value();
|
||||
let deploy_code_block = context.current_function().borrow().evmla().find_block(
|
||||
&revive_llvm_context::EraVMFunctionBlockKey::new(
|
||||
revive_llvm_context::EraVMCodeType::Deploy,
|
||||
&revive_llvm_context::PolkaVMFunctionBlockKey::new(
|
||||
revive_llvm_context::PolkaVMCodeType::Deploy,
|
||||
num::BigUint::zero(),
|
||||
),
|
||||
&Stack::default().hash(),
|
||||
)?;
|
||||
let runtime_code_block = context.current_function().borrow().evmla().find_block(
|
||||
&revive_llvm_context::EraVMFunctionBlockKey::new(
|
||||
revive_llvm_context::EraVMCodeType::Runtime,
|
||||
&revive_llvm_context::PolkaVMFunctionBlockKey::new(
|
||||
revive_llvm_context::PolkaVMCodeType::Runtime,
|
||||
num::BigUint::zero(),
|
||||
),
|
||||
&Stack::default().hash(),
|
||||
@@ -1297,14 +1297,14 @@ where
|
||||
|
||||
context.set_basic_block(context.current_function().borrow().return_block());
|
||||
match context.current_function().borrow().r#return() {
|
||||
revive_llvm_context::EraVMFunctionReturn::None => {
|
||||
revive_llvm_context::PolkaVMFunctionReturn::None => {
|
||||
context.build_return(None);
|
||||
}
|
||||
revive_llvm_context::EraVMFunctionReturn::Primitive { pointer } => {
|
||||
revive_llvm_context::PolkaVMFunctionReturn::Primitive { pointer } => {
|
||||
let return_value = context.build_load(pointer, "return_value")?;
|
||||
context.build_return(Some(&return_value));
|
||||
}
|
||||
revive_llvm_context::EraVMFunctionReturn::Compound { pointer, .. } => {
|
||||
revive_llvm_context::PolkaVMFunctionReturn::Compound { pointer, .. } => {
|
||||
let return_value = context.build_load(pointer, "return_value")?;
|
||||
context.build_return(Some(&return_value));
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ use crate::evmla::ethereal_ir::function::block::element::stack::Stack;
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct QueueElement {
|
||||
/// The block key.
|
||||
pub block_key: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
pub block_key: revive_llvm_context::PolkaVMFunctionBlockKey,
|
||||
/// The block predecessor.
|
||||
pub predecessor: Option<(revive_llvm_context::EraVMFunctionBlockKey, usize)>,
|
||||
pub predecessor: Option<(revive_llvm_context::PolkaVMFunctionBlockKey, usize)>,
|
||||
/// The predecessor's last stack state.
|
||||
pub stack: Stack,
|
||||
}
|
||||
@@ -16,8 +16,8 @@ pub struct QueueElement {
|
||||
impl QueueElement {
|
||||
/// A shortcut constructor.
|
||||
pub fn new(
|
||||
block_key: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
predecessor: Option<(revive_llvm_context::EraVMFunctionBlockKey, usize)>,
|
||||
block_key: revive_llvm_context::PolkaVMFunctionBlockKey,
|
||||
predecessor: Option<(revive_llvm_context::PolkaVMFunctionBlockKey, usize)>,
|
||||
stack: Stack,
|
||||
) -> Self {
|
||||
Self {
|
||||
|
||||
@@ -10,7 +10,7 @@ pub enum Type {
|
||||
/// The function name.
|
||||
name: String,
|
||||
/// The function initial block key.
|
||||
block_key: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
block_key: revive_llvm_context::PolkaVMFunctionBlockKey,
|
||||
/// The size of stack input (in cells or 256-bit words).
|
||||
input_size: usize,
|
||||
/// The size of stack output (in cells or 256-bit words).
|
||||
@@ -27,7 +27,7 @@ impl Type {
|
||||
/// A shortcut constructor.
|
||||
pub fn new_recursive(
|
||||
name: String,
|
||||
block_key: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
block_key: revive_llvm_context::PolkaVMFunctionBlockKey,
|
||||
input_size: usize,
|
||||
output_size: usize,
|
||||
) -> Self {
|
||||
|
||||
@@ -6,7 +6,7 @@ use std::cmp::Ordering;
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct VisitedElement {
|
||||
/// The block key.
|
||||
pub block_key: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
pub block_key: revive_llvm_context::PolkaVMFunctionBlockKey,
|
||||
/// The initial stack state hash.
|
||||
pub stack_hash: md5::Digest,
|
||||
}
|
||||
@@ -14,7 +14,7 @@ pub struct VisitedElement {
|
||||
impl VisitedElement {
|
||||
/// A shortcut constructor.
|
||||
pub fn new(
|
||||
block_key: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
block_key: revive_llvm_context::PolkaVMFunctionBlockKey,
|
||||
stack_hash: md5::Digest,
|
||||
) -> Self {
|
||||
Self {
|
||||
@@ -34,20 +34,20 @@ impl Ord for VisitedElement {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
match (self.block_key.code_type, other.block_key.code_type) {
|
||||
(
|
||||
revive_llvm_context::EraVMCodeType::Deploy,
|
||||
revive_llvm_context::EraVMCodeType::Runtime,
|
||||
revive_llvm_context::PolkaVMCodeType::Deploy,
|
||||
revive_llvm_context::PolkaVMCodeType::Runtime,
|
||||
) => Ordering::Less,
|
||||
(
|
||||
revive_llvm_context::EraVMCodeType::Runtime,
|
||||
revive_llvm_context::EraVMCodeType::Deploy,
|
||||
revive_llvm_context::PolkaVMCodeType::Runtime,
|
||||
revive_llvm_context::PolkaVMCodeType::Deploy,
|
||||
) => Ordering::Greater,
|
||||
(
|
||||
revive_llvm_context::EraVMCodeType::Deploy,
|
||||
revive_llvm_context::EraVMCodeType::Deploy,
|
||||
revive_llvm_context::PolkaVMCodeType::Deploy,
|
||||
revive_llvm_context::PolkaVMCodeType::Deploy,
|
||||
)
|
||||
| (
|
||||
revive_llvm_context::EraVMCodeType::Runtime,
|
||||
revive_llvm_context::EraVMCodeType::Runtime,
|
||||
revive_llvm_context::PolkaVMCodeType::Runtime,
|
||||
revive_llvm_context::PolkaVMCodeType::Runtime,
|
||||
) => {
|
||||
let tag_comparison = self.block_key.tag.cmp(&other.block_key.tag);
|
||||
if tag_comparison == Ordering::Equal {
|
||||
|
||||
@@ -31,7 +31,7 @@ pub struct EtherealIR {
|
||||
/// The all-inlined function.
|
||||
pub entry_function: Function,
|
||||
/// The recursive functions.
|
||||
pub recursive_functions: BTreeMap<revive_llvm_context::EraVMFunctionBlockKey, Function>,
|
||||
pub recursive_functions: BTreeMap<revive_llvm_context::PolkaVMFunctionBlockKey, Function>,
|
||||
}
|
||||
|
||||
impl EtherealIR {
|
||||
@@ -45,7 +45,7 @@ impl EtherealIR {
|
||||
pub fn new(
|
||||
solc_version: semver::Version,
|
||||
extra_metadata: ExtraMetadata,
|
||||
blocks: HashMap<revive_llvm_context::EraVMFunctionBlockKey, Block>,
|
||||
blocks: HashMap<revive_llvm_context::PolkaVMFunctionBlockKey, Block>,
|
||||
) -> anyhow::Result<Self> {
|
||||
let mut entry_function = Function::new(solc_version.clone(), FunctionType::new_initial());
|
||||
let mut recursive_functions = BTreeMap::new();
|
||||
@@ -68,9 +68,9 @@ impl EtherealIR {
|
||||
/// Gets blocks for the specified type of the contract code.
|
||||
pub fn get_blocks(
|
||||
solc_version: semver::Version,
|
||||
code_type: revive_llvm_context::EraVMCodeType,
|
||||
code_type: revive_llvm_context::PolkaVMCodeType,
|
||||
instructions: &[Instruction],
|
||||
) -> anyhow::Result<HashMap<revive_llvm_context::EraVMFunctionBlockKey, Block>> {
|
||||
) -> anyhow::Result<HashMap<revive_llvm_context::PolkaVMFunctionBlockKey, Block>> {
|
||||
let mut blocks = HashMap::with_capacity(Self::BLOCKS_HASHMAP_DEFAULT_CAPACITY);
|
||||
let mut offset = 0;
|
||||
|
||||
@@ -81,7 +81,7 @@ impl EtherealIR {
|
||||
&instructions[offset..],
|
||||
)?;
|
||||
blocks.insert(
|
||||
revive_llvm_context::EraVMFunctionBlockKey::new(
|
||||
revive_llvm_context::PolkaVMFunctionBlockKey::new(
|
||||
code_type,
|
||||
block.key.tag.clone(),
|
||||
),
|
||||
@@ -94,13 +94,13 @@ impl EtherealIR {
|
||||
}
|
||||
}
|
||||
|
||||
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for EtherealIR
|
||||
impl<D> revive_llvm_context::PolkaVMWriteLLVM<D> for EtherealIR
|
||||
where
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
fn declare(
|
||||
&mut self,
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
context: &mut revive_llvm_context::PolkaVMContext<D>,
|
||||
) -> anyhow::Result<()> {
|
||||
self.entry_function.declare(context)?;
|
||||
|
||||
@@ -113,7 +113,7 @@ where
|
||||
|
||||
fn into_llvm(
|
||||
self,
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
context: &mut revive_llvm_context::PolkaVMContext<D>,
|
||||
) -> anyhow::Result<()> {
|
||||
context.evmla_mut().stack = vec![];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user