Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove some unused features #78

Merged
merged 3 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions crates/llvm-context/src/optimizer/settings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ pub struct Settings {

/// Fallback to optimizing for size if the bytecode is too large.
pub is_fallback_to_size_enabled: bool,
/// Whether the system request memoization is disabled.
pub is_system_request_memoization_disabled: bool,

/// Whether the LLVM `verify each` option is enabled.
pub is_verify_each_enabled: bool,
Expand All @@ -43,7 +41,6 @@ impl Settings {
level_back_end,

is_fallback_to_size_enabled: false,
is_system_request_memoization_disabled: false,

is_verify_each_enabled: false,
is_debug_logging_enabled: false,
Expand All @@ -65,7 +62,6 @@ impl Settings {
level_back_end,

is_fallback_to_size_enabled: false,
is_system_request_memoization_disabled: false,

is_verify_each_enabled,
is_debug_logging_enabled,
Expand Down Expand Up @@ -206,20 +202,10 @@ impl Settings {
self.is_fallback_to_size_enabled = true;
}

/// Disables the system request memoization.
pub fn disable_system_request_memoization(&mut self) {
self.is_system_request_memoization_disabled = true;
}

/// Whether the fallback to optimizing for size is enabled.
pub fn is_fallback_to_size_enabled(&self) -> bool {
self.is_fallback_to_size_enabled
}

/// Whether the system request memoization is disabled.
pub fn is_system_request_memoization_disabled(&self) -> bool {
self.is_system_request_memoization_disabled
}
}

impl PartialEq for Settings {
Expand Down
182 changes: 0 additions & 182 deletions crates/llvm-context/src/polkavm/context/function/llvm_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@ use crate::polkavm::context::function::Function;
/// The functions are automatically linked to the LLVM implementations if the signatures match.
#[derive(Debug)]
pub struct LLVMRuntime<'ctx> {
/// The corresponding LLVM runtime function.
pub shl: FunctionDeclaration<'ctx>,
/// The corresponding LLVM runtime function.
pub shr: FunctionDeclaration<'ctx>,
/// The corresponding LLVM runtime function.
pub sar: FunctionDeclaration<'ctx>,
/// The corresponding LLVM runtime function.
pub byte: FunctionDeclaration<'ctx>,

/// The corresponding LLVM runtime function.
pub add_mod: FunctionDeclaration<'ctx>,
/// The corresponding LLVM runtime function.
Expand All @@ -31,32 +22,9 @@ pub struct LLVMRuntime<'ctx> {

/// The corresponding LLVM runtime function.
pub sha3: FunctionDeclaration<'ctx>,

/// The corresponding LLVM runtime function.
pub r#return: FunctionDeclaration<'ctx>,
/// The corresponding LLVM runtime function.
pub revert: FunctionDeclaration<'ctx>,
}

impl<'ctx> LLVMRuntime<'ctx> {
/// The LLVM personality function name.
pub const FUNCTION_PERSONALITY: &'static str = "__personality";

/// The LLVM exception throwing function name.
pub const FUNCTION_CXA_THROW: &'static str = "__cxa_throw";

/// The corresponding runtime function name.
pub const FUNCTION_SHL: &'static str = "__shl";

/// The corresponding runtime function name.
pub const FUNCTION_SHR: &'static str = "__shr";

/// The corresponding runtime function name.
pub const FUNCTION_SAR: &'static str = "__sar";

/// The corresponding runtime function name.
pub const FUNCTION_BYTE: &'static str = "__byte";

/// The corresponding runtime function name.
pub const FUNCTION_ADDMOD: &'static str = "__addmod";

Expand All @@ -72,121 +40,12 @@ impl<'ctx> LLVMRuntime<'ctx> {
/// The corresponding runtime function name.
pub const FUNCTION_SHA3: &'static str = "__sha3";

/// The corresponding runtime function name.
pub const FUNCTION_SYSTEM_REQUEST: &'static str = "__system_request";

/// The corresponding runtime function name.
pub const FUNCTION_FARCALL: &'static str = "__farcall";

/// The corresponding runtime function name.
pub const FUNCTION_STATICCALL: &'static str = "__staticcall";

/// The corresponding runtime function name.
pub const FUNCTION_DELEGATECALL: &'static str = "__delegatecall";

/// The corresponding runtime function name.
pub const FUNCTION_MIMICCALL: &'static str = "__mimiccall";

/// The corresponding runtime function name.
pub const FUNCTION_FARCALL_BYREF: &'static str = "__farcall_byref";

/// The corresponding runtime function name.
pub const FUNCTION_STATICCALL_BYREF: &'static str = "__staticcall_byref";

/// The corresponding runtime function name.
pub const FUNCTION_DELEGATECALL_BYREF: &'static str = "__delegatecall_byref";

/// The corresponding runtime function name.
pub const FUNCTION_MIMICCALL_BYREF: &'static str = "__mimiccall_byref";

/// The corresponding runtime function name.
pub const FUNCTION_RETURN: &'static str = "__return";

/// The corresponding runtime function name.
pub const FUNCTION_REVERT: &'static str = "__revert";

/// A shortcut constructor.
pub fn new(
llvm: &'ctx inkwell::context::Context,
module: &inkwell::module::Module<'ctx>,
optimizer: &Optimizer,
) -> Self {
let shl = Self::declare(
module,
Self::FUNCTION_SHL,
llvm.custom_width_int_type(revive_common::BIT_LENGTH_WORD as u32)
.fn_type(
vec![
llvm.custom_width_int_type(revive_common::BIT_LENGTH_WORD as u32)
.as_basic_type_enum()
.into();
2
]
.as_slice(),
false,
),
Some(inkwell::module::Linkage::External),
);
Function::set_default_attributes(llvm, shl, optimizer);
Function::set_pure_function_attributes(llvm, shl);

let shr = Self::declare(
module,
Self::FUNCTION_SHR,
llvm.custom_width_int_type(revive_common::BIT_LENGTH_WORD as u32)
.fn_type(
vec![
llvm.custom_width_int_type(revive_common::BIT_LENGTH_WORD as u32)
.as_basic_type_enum()
.into();
2
]
.as_slice(),
false,
),
Some(inkwell::module::Linkage::External),
);
Function::set_default_attributes(llvm, shr, optimizer);
Function::set_pure_function_attributes(llvm, shr);

let sar = Self::declare(
module,
Self::FUNCTION_SAR,
llvm.custom_width_int_type(revive_common::BIT_LENGTH_WORD as u32)
.fn_type(
vec![
llvm.custom_width_int_type(revive_common::BIT_LENGTH_WORD as u32)
.as_basic_type_enum()
.into();
2
]
.as_slice(),
false,
),
Some(inkwell::module::Linkage::External),
);
Function::set_default_attributes(llvm, sar, optimizer);
Function::set_pure_function_attributes(llvm, sar);

let byte = Self::declare(
module,
Self::FUNCTION_BYTE,
llvm.custom_width_int_type(revive_common::BIT_LENGTH_WORD as u32)
.fn_type(
vec![
llvm.custom_width_int_type(revive_common::BIT_LENGTH_WORD as u32)
.as_basic_type_enum()
.into();
2
]
.as_slice(),
false,
),
Some(inkwell::module::Linkage::External),
);
Function::set_default_attributes(llvm, byte, optimizer);
Function::set_pure_function_attributes(llvm, byte);

let add_mod =
Self::define(module, Self::FUNCTION_ADDMOD).expect("should be declared in stdlib");
Function::set_default_attributes(llvm, add_mod, optimizer);
Expand Down Expand Up @@ -236,54 +95,13 @@ impl<'ctx> LLVMRuntime<'ctx> {
false,
);

let r#return = Self::declare(
module,
Self::FUNCTION_RETURN,
llvm.void_type().fn_type(
vec![
llvm.custom_width_int_type(revive_common::BIT_LENGTH_WORD as u32)
.as_basic_type_enum()
.into();
3
]
.as_slice(),
false,
),
Some(inkwell::module::Linkage::External),
);
Function::set_default_attributes(llvm, r#return, optimizer);
let revert = Self::declare(
module,
Self::FUNCTION_REVERT,
llvm.void_type().fn_type(
vec![
llvm.custom_width_int_type(revive_common::BIT_LENGTH_WORD as u32)
.as_basic_type_enum()
.into();
3
]
.as_slice(),
false,
),
Some(inkwell::module::Linkage::External),
);
Function::set_default_attributes(llvm, revert, optimizer);

Self {
shl,
shr,
sar,
byte,

add_mod,
mul_mod,
exp,
sign_extend,

sha3,

r#return,
revert,
}
}

Expand Down
12 changes: 0 additions & 12 deletions crates/llvm-context/src/polkavm/context/function/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ pub struct Function<'ctx> {
}

impl<'ctx> Function<'ctx> {
/// The near call ABI function prefix.
pub const ZKSYNC_NEAR_CALL_ABI_PREFIX: &'static str = "ZKSYNC_NEAR_CALL";

/// The near call ABI exception handler name.
pub const ZKSYNC_NEAR_CALL_ABI_EXCEPTION_HANDLER: &'static str = "ZKSYNC_CATCH_NEAR_CALL";

/// The stack hashmap default capacity.
const STACK_HASHMAP_INITIAL_CAPACITY: usize = 64;

Expand Down Expand Up @@ -95,12 +89,6 @@ impl<'ctx> Function<'ctx> {
&& name != self::runtime::FUNCTION_LOAD_IMMUTABLE_DATA)
}

/// Checks whether the function is related to the near call ABI.
pub fn is_near_call_abi(name: &str) -> bool {
name.starts_with(Self::ZKSYNC_NEAR_CALL_ABI_PREFIX)
|| name == Self::ZKSYNC_NEAR_CALL_ABI_EXCEPTION_HANDLER
}

/// Returns the LLVM function declaration.
pub fn declaration(&self) -> Declaration<'ctx> {
self.declaration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ where
D: Dependency + Clone,
{
fn declare(&mut self, context: &mut Context<D>) -> anyhow::Result<()> {
let function_type =
context.function_type::<inkwell::types::BasicTypeEnum>(vec![], 0, false);
let function_type = context.function_type::<inkwell::types::BasicTypeEnum>(vec![], 0);
context.add_function(
runtime::FUNCTION_DEPLOY_CODE,
function_type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ where
{
fn declare(&mut self, context: &mut Context<D>) -> anyhow::Result<()> {
let entry_arguments = vec![context.bool_type().as_basic_type_enum()];
let entry_function_type = context.function_type(entry_arguments, 0, false);
let entry_function_type = context.function_type(entry_arguments, 0);
context.add_function(
runtime::FUNCTION_ENTRY,
entry_function_type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ where
D: Dependency + Clone,
{
fn declare(&mut self, context: &mut Context<D>) -> anyhow::Result<()> {
let function_type =
context.function_type::<inkwell::types::BasicTypeEnum>(vec![], 0, false);
let function_type = context.function_type::<inkwell::types::BasicTypeEnum>(vec![], 0);
context.add_function(
runtime::FUNCTION_RUNTIME_CODE,
function_type,
Expand Down
Loading