From e284cfaae13e9425eeabb6aea5a348d67cbd8690 Mon Sep 17 00:00:00 2001 From: Edgar Date: Thu, 23 May 2024 15:44:24 +0200 Subject: [PATCH] Apply missed fixes on llvm 18 pr (#620) * apply missed fixes * update readme --- README.md | 26 +++++++++++++------------- src/executor.rs | 4 ++-- src/libfuncs/felt252_dict_entry.rs | 5 +---- src/starknet.rs | 6 ++---- 4 files changed, 18 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index aac890735..451632536 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,7 @@ This is a list of the current progress implementing each **libfunc**. 1. `call_contract_syscall` (StarkNet) 1. `class_hash_to_felt252` (StarkNet) 1. `class_hash_try_from_felt252` (StarkNet) +1. `const_as_box` 1. `contract_address_const` (StarkNet) 1. `contract_address_to_felt252` (StarkNet) 1. `contract_address_try_from_felt252` (StarkNet) @@ -134,6 +135,16 @@ This is a list of the current progress implementing each **libfunc**. 1. `rename` 1. `replace_class_syscall` (StarkNet) 1. `revoke_ap_tracking` +1. `secp256k1_add_syscall` (StarkNet) +1. `secp256k1_get_point_from_x_syscall` (StarkNet) +1. `secp256k1_get_xy_syscall` (StarkNet) +1. `secp256k1_mul_syscall` (StarkNet) +1. `secp256k1_new_syscall` (StarkNet) +1. `secp256r1_add_syscall` (StarkNet) +1. `secp256r1_get_point_from_x_syscall` (StarkNet) +1. `secp256r1_get_xy_syscall` (StarkNet) +1. `secp256r1_mul_syscall` (StarkNet) +1. `secp256r1_new_syscall` (StarkNet) 1. `send_message_to_l1_syscall` (StarkNet) 1. `snapshot_take` (1) 1. `span_from_tuple` @@ -214,18 +225,7 @@ This is a list of the current progress implementing each **libfunc**.
Not yet implemented libfuncs (click to open) - -1. `const_as_box` -1. `secp256k1_add_syscall` (StarkNet) -1. `secp256k1_get_point_from_x_syscall` (StarkNet) -1. `secp256k1_get_xy_syscall` (StarkNet) -1. `secp256k1_mul_syscall` (StarkNet) -1. `secp256k1_new_syscall` (StarkNet) -1. `secp256r1_add_syscall` (StarkNet) -1. `secp256r1_get_point_from_x_syscall` (StarkNet) -1. `secp256r1_get_xy_syscall` (StarkNet) -1. `secp256r1_mul_syscall` (StarkNet) -1. `secp256r1_new_syscall` (StarkNet) +1. coupon
@@ -262,7 +262,7 @@ Footnotes on the libfuncs list: - Linux or macOS (aarch64 included) only for now - LLVM 18 with MLIR: On debian you can use [apt.llvm.org](https://apt.llvm.org/), on macOS you can use brew -- Rust 1.76.0 +- Rust 1.78.0 or later, since we make use of the u128 [abi change](https://blog.rust-lang.org/2024/03/30/i128-layout-update.html). - Git ### Setup diff --git a/src/executor.rs b/src/executor.rs index 580f71ed9..fb15170c3 100644 --- a/src/executor.rs +++ b/src/executor.rs @@ -363,7 +363,7 @@ impl<'a> ArgumentMapper<'a> { #[cfg(target_arch = "x86_64")] const NUM_REGISTER_ARGS: usize = 6; - #[cfg(not(target_arch = "x86_64"))] + #[cfg(target_arch = "aarch64")] const NUM_REGISTER_ARGS: usize = 8; if align == 16 { @@ -380,7 +380,7 @@ impl<'a> ArgumentMapper<'a> { self.invoke_data.push(0); } else { let new_len = self.invoke_data.len() + values.len(); - if new_len >= 8 && new_len % 2 != 0 { + if new_len >= NUM_REGISTER_ARGS && new_len % 2 != 0 { let chunk; (chunk, values) = if values.len() >= 4 { values.split_at(4) diff --git a/src/libfuncs/felt252_dict_entry.rs b/src/libfuncs/felt252_dict_entry.rs index d5b803473..8bc1d4545 100644 --- a/src/libfuncs/felt252_dict_entry.rs +++ b/src/libfuncs/felt252_dict_entry.rs @@ -21,10 +21,7 @@ use cairo_lang_sierra::{ program_registry::ProgramRegistry, }; use melior::{ - dialect::{ - cf, - llvm::{self}, - }, + dialect::{cf, llvm}, ir::{ attribute::IntegerAttribute, operation::OperationBuilder, r#type::IntegerType, Block, Identifier, Location, Value, ValueLike, diff --git a/src/starknet.rs b/src/starknet.rs index 5e7f0da3e..903e1620a 100644 --- a/src/starknet.rs +++ b/src/starknet.rs @@ -15,15 +15,13 @@ pub struct ArrayAbi { /// Binary representation of a `Felt` (in MLIR). #[derive(Debug, Clone)] -#[cfg_attr(target_arch = "x86_64", repr(C, align(16)))] -#[cfg_attr(not(target_arch = "x86_64"), repr(C, align(16)))] +#[repr(C, align(16))] pub struct Felt252Abi(pub [u8; 32]); /// Binary representation of a `u256` (in MLIR). // TODO: This shouldn't need to be public. #[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] #[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(target_arch = "x86_64", repr(C, align(16)))] -#[cfg_attr(not(target_arch = "x86_64"), repr(C, align(16)))] +#[repr(C, align(16))] pub struct U256 { pub hi: u128, pub lo: u128,