Skip to content

Adding support for Machine Integer version of Bytes, List, and MInt functions #1209

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

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from

Conversation

Robertorosmaninho
Copy link
Collaborator

@Robertorosmaninho Robertorosmaninho commented Jun 28, 2025

This PR introduces the concrete implementation of the following new Machine Integer hooks:

1.  syntax {Width} MInt{Width} ::=MInt{Width} "^MInt" MInt{Width}
2.  syntax {Width} Bytes ::= MInt2Bytes(MInt{Width})
3.  syntax {Width} MInt{Width} ::= Bytes2MInt(Bytes)
4.  syntax {Width} MInt{Width} ::= lengthBytes(Bytes)
5.  syntax {Width} Bytes ::= padRightBytes(Bytes, length: MInt{Width}, value: MInt{Width})
6.  syntax {Width} Bytes ::= padLeftBytes(Bytes, length: MInt{Width}, value: MInt{Width})
7.  syntax {Width} Bytes ::= replaceAtBytes(dest: Bytes, index: MInt{Width}, src: Bytes)
8.  syntax {Width} Bytes ::= substrBytes(Bytes, startIndex: MInt{Width}, endIndex: MInt{Width})
9.  syntax {Width} MInt{Width} ::= Bytes "[" MInt{Width} "]"
10. syntax {Width} Bytes ::= Bytes "[" index: MInt{Width} "<-" value: MInt{Width} "]"
11. syntax {Width} MInt{Width} ::= size(List)
12. syntax {Width} List ::= List "[" index: MInt{Width} "<-" value: KItem "]"
13. syntax {Width} KItem ::= List "[" MInt{Width} "]"

Most of these hooks have an initial implementation for 64 and 256-bit Integers, being the former defined in C++ in its respective collection file while the latter is defined in the llvm_header.inc file, as C++ doesn't support 256-bit integer natively.

The only exceptions for now are 12 and 13, which are only implemented for 64-bit, as we have the immer limitation that the index should be a in64_t.

@rv-jenkins rv-jenkins changed the base branch from master to develop June 28, 2025 17:17
…d MInt{64}

Implementing `hook_MINT_pow256` in LLVM IR
Implementing `hook_MINT_pow64` in int.cpp
Adding `mint-pow` unit test
Implementing `hook_MINT_MInt2Bytes` in LLVM IR
Adding `mint2bytes` unit test
Implementing `hook_MINT_Bytes2MInt` in LLVM IR
Adding `bytes2mint` unit test
…} and MInt{64}

Implementing `hook_BYTES_length256` in LLVM IR
Implementing `hook_BYTES_length64` in bytes.cpp
Adding `lengthbytes` unit test
…56} and MInt{64}

Implementing `hook_BYTES_padRight256` in LLVM IR
Implementing `hook_BYTES_padRight64` in bytes.cpp
Adding `padrightbytes` unit test
…6} and MInt{64}

Implementing `hook_BYTES_padLeft256` in LLVM IR
Implementing `hook_BYTES_padLeft64` in bytes.cpp
Adding `padleftbytes` unit test
…256} and MInt{64}

Implementing `hook_BYTES_replaceAt256` in LLVM IR
Implementing `hook_BYTES_replaceAt64` in bytes.cpp
Adding `replaceatbytes` unit test
Declaring functions needed by other functions in the `llvm_hearder.inc`
Defining `interger_overflow` used in used in `hook_BYTES_pad*` functions in `llvm_hearder.inc`
…} and MInt{64}

Implementing `hook_BYTES_substr256` in LLVM IR
Implementing `hook_BYTES_substr64` in bytes.cpp
Adding `substrbytes` unit test
…nd MInt{64}

Implementing `hook_BYTES_get256` in LLVM IR
Implementing `hook_BYTES_get64` in bytes.cpp
Adding `bytes-get` unit test
…} and MInt{64}

Implementing `hook_BYTES_update256` in LLVM IR
Implementing `hook_BYTES_update64` in bytes.cpp
Adding `bytes-update` unit test
…nd MInt{64}

Implementing `hook_LIST_size256` in LLVM IR
Implementing `hook_LIST_size64` in bytes.cpp
Adding `list-size` unit test
Implementing `hook_LIST_get64` in bytes.cpp
Adding `list-get` unit test
@Robertorosmaninho Robertorosmaninho self-assigned this Jul 4, 2025
@Robertorosmaninho Robertorosmaninho marked this pull request as ready for review July 4, 2025 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant