add common crate

Signed-off-by: xermicus <cyrill@parity.io>
This commit is contained in:
xermicus
2024-03-22 16:19:18 +01:00
parent 50f2dd9b74
commit c52a8d0f20
65 changed files with 839 additions and 271 deletions
@@ -202,10 +202,10 @@ impl<'ctx> LLVMRuntime<'ctx> {
let div = Self::declare(
module,
Self::FUNCTION_DIV,
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.fn_type(
vec![
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.as_basic_type_enum()
.into();
2
@@ -221,10 +221,10 @@ impl<'ctx> LLVMRuntime<'ctx> {
let r#mod = Self::declare(
module,
Self::FUNCTION_MOD,
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.fn_type(
vec![
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.as_basic_type_enum()
.into();
2
@@ -240,10 +240,10 @@ impl<'ctx> LLVMRuntime<'ctx> {
let sdiv = Self::declare(
module,
Self::FUNCTION_SDIV,
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.fn_type(
vec![
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.as_basic_type_enum()
.into();
2
@@ -259,10 +259,10 @@ impl<'ctx> LLVMRuntime<'ctx> {
let smod = Self::declare(
module,
Self::FUNCTION_SMOD,
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.fn_type(
vec![
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.as_basic_type_enum()
.into();
2
@@ -278,10 +278,10 @@ impl<'ctx> LLVMRuntime<'ctx> {
let shl = Self::declare(
module,
Self::FUNCTION_SHL,
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.fn_type(
vec![
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.as_basic_type_enum()
.into();
2
@@ -297,10 +297,10 @@ impl<'ctx> LLVMRuntime<'ctx> {
let shr = Self::declare(
module,
Self::FUNCTION_SHR,
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.fn_type(
vec![
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.as_basic_type_enum()
.into();
2
@@ -316,10 +316,10 @@ impl<'ctx> LLVMRuntime<'ctx> {
let sar = Self::declare(
module,
Self::FUNCTION_SAR,
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.fn_type(
vec![
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.as_basic_type_enum()
.into();
2
@@ -335,10 +335,10 @@ impl<'ctx> LLVMRuntime<'ctx> {
let byte = Self::declare(
module,
Self::FUNCTION_BYTE,
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.fn_type(
vec![
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.as_basic_type_enum()
.into();
2
@@ -354,10 +354,10 @@ impl<'ctx> LLVMRuntime<'ctx> {
let add_mod = Self::declare(
module,
Self::FUNCTION_ADDMOD,
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.fn_type(
vec![
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.as_basic_type_enum()
.into();
3
@@ -373,10 +373,10 @@ impl<'ctx> LLVMRuntime<'ctx> {
let mul_mod = Self::declare(
module,
Self::FUNCTION_MULMOD,
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.fn_type(
vec![
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.as_basic_type_enum()
.into();
3
@@ -392,10 +392,10 @@ impl<'ctx> LLVMRuntime<'ctx> {
let exp = Self::declare(
module,
Self::FUNCTION_EXP,
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.fn_type(
vec![
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.as_basic_type_enum()
.into();
2
@@ -409,10 +409,10 @@ impl<'ctx> LLVMRuntime<'ctx> {
Function::set_pure_function_attributes(llvm, exp);
let sign_extend = FunctionDeclaration::new(
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.fn_type(
vec![
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.as_basic_type_enum()
.into();
2
@@ -432,11 +432,11 @@ impl<'ctx> LLVMRuntime<'ctx> {
Self::FUNCTION_MSTORE8,
llvm.void_type().fn_type(
vec![
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_BYTE as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_BYTE as u32)
.ptr_type(AddressSpace::Heap.into())
.as_basic_type_enum()
.into(),
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.as_basic_type_enum()
.into(),
]
@@ -460,17 +460,17 @@ impl<'ctx> LLVMRuntime<'ctx> {
let sha3 = Self::declare(
module,
Self::FUNCTION_SHA3,
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.fn_type(
vec![
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_BYTE as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_BYTE as u32)
.ptr_type(AddressSpace::Heap.into())
.as_basic_type_enum()
.into(),
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.as_basic_type_enum()
.into(),
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_BOOLEAN as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_BOOLEAN as u32)
.as_basic_type_enum()
.into(),
]
@@ -491,19 +491,19 @@ impl<'ctx> LLVMRuntime<'ctx> {
let system_request = Self::declare(
module,
Self::FUNCTION_SYSTEM_REQUEST,
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.fn_type(
vec![
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.as_basic_type_enum()
.into(),
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.as_basic_type_enum()
.into(),
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.as_basic_type_enum()
.into(),
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.ptr_type(AddressSpace::Stack.into())
.as_basic_type_enum()
.into(),
@@ -523,7 +523,7 @@ impl<'ctx> LLVMRuntime<'ctx> {
);
let external_call_arguments: Vec<inkwell::types::BasicMetadataTypeEnum> = vec![
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.as_basic_type_enum()
.into();
crate::eravm::context::function::runtime::entry::Entry::MANDATORY_ARGUMENTS_COUNT
@@ -531,23 +531,23 @@ impl<'ctx> LLVMRuntime<'ctx> {
];
let mut mimic_call_arguments = external_call_arguments.clone();
mimic_call_arguments.push(
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.as_basic_type_enum()
.into(),
);
let mut external_call_arguments_by_ref: Vec<inkwell::types::BasicMetadataTypeEnum> = vec![
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_BYTE as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_BYTE as u32)
.ptr_type(AddressSpace::Generic.into())
.as_basic_type_enum()
.into(),
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.as_basic_type_enum()
.into(),
];
external_call_arguments_by_ref.extend::<Vec<inkwell::types::BasicMetadataTypeEnum>>(vec![
llvm.custom_width_int_type(
era_compiler_common::BIT_LENGTH_FIELD as u32
revive_common::BIT_LENGTH_FIELD as u32
)
.as_basic_type_enum()
.into();
@@ -555,7 +555,7 @@ impl<'ctx> LLVMRuntime<'ctx> {
]);
let mut mimic_call_arguments_by_ref = external_call_arguments_by_ref.clone();
mimic_call_arguments_by_ref.push(
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.as_basic_type_enum()
.into(),
);
@@ -563,7 +563,7 @@ impl<'ctx> LLVMRuntime<'ctx> {
let external_call_result_type = llvm
.struct_type(
&[
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_BYTE as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_BYTE as u32)
.ptr_type(AddressSpace::Generic.into())
.as_basic_type_enum(),
llvm.bool_type().as_basic_type_enum(),
@@ -635,7 +635,7 @@ impl<'ctx> LLVMRuntime<'ctx> {
Self::FUNCTION_RETURN,
llvm.void_type().fn_type(
vec![
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.as_basic_type_enum()
.into();
3
@@ -651,7 +651,7 @@ impl<'ctx> LLVMRuntime<'ctx> {
Self::FUNCTION_REVERT,
llvm.void_type().fn_type(
vec![
llvm.custom_width_int_type(era_compiler_common::BIT_LENGTH_FIELD as u32)
llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32)
.as_basic_type_enum()
.into();
3